You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat(settings): support plain field-id keys for dependency lookups
Plugin-ui's formatSettingsData() rebuilds dependency_key as a dot-path
(parent.child.field) and the values map is keyed by that dot-path.
Dependencies declared with a plain field id (e.g., 'commission_type'
instead of 'commission.commission.commission_type') therefore failed to
resolve via values[dep.key].
Add an id-keyed fallback so both formats work side by side:
- Export buildIdIndex(schema) from settings-formatter — produces a
{ field_id: dependency_key } map from the hierarchical schema.
- evaluateDependencies() accepts an optional idIndex argument. When
values[dep.key] is undefined and an idIndex is supplied, the function
resolves dep.key as a field id and re-reads values via the index.
- SettingsProvider builds the idIndex (memoised on schema) and threads
it through shouldDisplay → evaluateDependencies.
Backwards compatible: callers that don't pass idIndex see identical
behavior. Consumers whose backend guarantees globally-unique field ids
(e.g., flat-storage schemas) can now use id-keyed dependencies, which
stay valid across structural moves (no parent path to update).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(settings): formatter preserves server-supplied dependency_key; falls back to id
The formatter used to rebuild `dependency_key` on every render by joining
the parent chain into a dot-path. That silently overwrote whatever the
server sent. Now we prefer the server value and fall back to the element
id when missing (Phase 1 of the dependency_key cleanup; consumers are
updated in Phase 2).
- formatSettingsData: keep `child.dependency_key` if present, else `child.id`
- formatSettingsData: same fallback for the root page (was hard-coded `''`)
- Add jest unit tests covering nested preservation, nested fallback, and
the page-itself case
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(settings): consumers read element.id; dependency_key becomes vestigial
Now that the server emits and consumes flat element ids exclusively
(Phase 2 of the dependency_key cleanup), every plugin-ui consumer was
keying off element.dependency_key for values, errors, dirty tracking,
and onChange callbacks. Replace those reads with element.id:
- field-renderer.tsx: merged element value/validationError lookups
- fields.tsx: all 20 onChange(element.dependency_key!, ...) call sites
- settings-context.tsx: scopeFieldKeysMap, findElement, comments
- settings-formatter.ts:
* extractValues now keys by el.id
* validations/dependencies self pointer uses child.id
* buildIdIndex collapses to identity (kept for API stability;
evaluateDependencies fallback path is now a no-op for properly
keyed schemas, slated for removal in Task 11)
- settings-types.ts: SettingsProps.values doc comment
dependency_key is left on the type and on the formatter back-compat
assignments to avoid breaking external consumers in this commit; Task 11
removes the residue.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(settings): drop dependency_key from types, formatter, and tests
Task 11 of the dependency_key cleanup. Removes:
- dependency_key field from the SettingsElement type
- formatter back-compat assignments (child.dependency_key = ... || id)
- buildIdIndex helper + idIndex parameter on evaluateDependencies (the
helper collapsed to identity in Task 8 and is now dead — dep keys are
plain field ids, read directly from the flat values map)
- buildIdIndex import + idIndex usage in settings-context
- ~472 dependency_key literals from Settings.stories.tsx fixtures
- example dependency_key fields from DeveloperGuide.mdx code samples
Rewrites the formatter unit tests to assert id preservation through
nested parent resolution and that dependency_key no longer materializes
on enriched elements. Settings.mdx prose mentions are left for Task 12
(documentation phase).
* docs(settings): drop dependency_key from developer guides and stories
Add DOKAN_NEXT_MAJOR deprecation callout to CLAUDE.md, DEVELOPER_GUIDE.md,
src/DeveloperGuide.mdx, and src/components/settings/Settings.mdx. Replace
prose and embedded code-example mentions of dependency_key with the field's
id, and update treeValues/flatValues descriptions and examples to the flat
id-keyed shape (no dot-paths).
* feat(settings): add danger_switch and info_preview field variants
danger_switch — a dedicated variant for destructive toggles (e.g. "clear all
data on uninstall"). Renders in a destructive-tinted card, always confirms the
off → on transition through an AlertDialog, and reads confirm_modal (title /
description / confirmText / cancelText / optional checkboxLabel for an
acknowledgement gate) from the schema. Built as a separate variant rather than
overloading SwitchField with should_confirm / switcher_type / is_danger flags,
so the simple switch stays simple.
info_preview — generic "pick a few things to display" field with an optional
preview on the right. Renders label, description, and a checkbox list driven
by element.options; value shape is Record<string, boolean> keyed by
option.value. Preview slot resolution order:
1. ${hookPrefix}_settings_info_preview_field_preview filter
(receives (null, element, value) → may return a React node).
2. element.image_url rendered as <img>.
3. nothing.
The filter-based preview slot lets consumers attach dynamic previews
(charts, mocks, live HTML) without re-implementing the whole field.
Strengthens switcher_type and confirm_modal types in settings-types.ts so
schema authors get autocomplete instead of Record<string, any>.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* feat(settings): cross-field sum_max validation rule + auto re-validation
Add a `sum_max` rule to validateField that accepts either:
params: { field: 'sibling_id', max: 28 } // single sibling
params: { fields: ['a', 'b', 'c'], max: 100 } // N siblings
The rule sums self + every referenced sibling and fails when the total
exceeds `max`. Defensive: when allValues is not supplied or any sibling
value is missing/non-numeric, the rule passes silently to avoid false
positives on partial value snapshots (e.g. during initial hydration).
validateField now takes an optional `allValues` snapshot parameter so any
future cross-field rule can read sibling state without callers having to
re-plumb every site. Single-field rules remain unchanged.
In settings-context, updateValue now:
- Builds a local `nextValues` snapshot and feeds it to validateField.
- Walks the schema to find every sibling whose `validations[*].params`
references the just-changed key (via `field` or `fields[]`) and
re-validates them. So when a user fixes one side of a cross-field
constraint, the OTHER side's stale error auto-clears.
Use case: a schema can now declare `monthly_billing_day + due_period <= 28`
by attaching the same `sum_max` rule to both fields with the symmetric
`field` pointing at the sibling. Editing either field surfaces the
error on that field; fixing it clears both.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(ui): select dropdown overflow, trigger truncation, anchored-mode clipping
Three independent fixes in `Select`, all surfaced while wiring the AI
Assist provider/model selects:
1. Trigger value (SelectValue): add `min-w-0 truncate` so long titles
ellipsis inside the fixed-width trigger instead of pushing the chevron
out of the flex track and rendering over the value.
2. Dropdown options (SelectItem.ItemText): replace `shrink-0 whitespace-nowrap`
with `min-w-0 whitespace-normal break-words text-start`. Pickers must
never truncate the option label — the user needs the full text to
choose. Long titles now wrap to multiple lines within the popup's
`--anchor-width` and the popup scrolls vertically.
3. SelectContent default `alignItemWithTrigger`: flip from `true` to
`false`. base-ui's anchored mode measures item heights at open time to
position the popup so the selected option sits on the trigger; with
wrap-enabled items the pre-paint measurement reports a smaller height
than the actual wrapped height, so first-open positions the popup
above the viewport and clips the top option. Subsequent opens use the
settled heights and render fine. Defaulting to a standard "open below
trigger" dropdown removes the inconsistency. Callers can still opt
into anchored mode explicitly.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: src/DeveloperGuide.mdx
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,12 @@ import { Meta } from "@storybook/addon-docs/blocks";
6
6
7
7
# @wedevs/plugin-ui — Developer Guide
8
8
9
+
> **Note (DOKAN_NEXT_MAJOR):** The `dependency_key` attribute has been removed
10
+
> from the settings schema. Use the field's `id` directly. `show_if` and
11
+
> `dependencies` rule keys are now flat field ids — dot-paths are no longer
12
+
> supported. See the [dependency_key cleanup plan](https://github.com/getdokan/dokan/blob/refactor/simplify-settings-to-flat-array/docs/superpowers/plans/2026-05-18-dependency-key-cleanup.md)
13
+
> for migration context.
14
+
9
15
A ShadCN-style React component library built for WordPress plugins. Provides 50+ themed, accessible UI components powered by Tailwind CSS v4, `@base-ui/react` headless primitives, and first-class WordPress integration.
Copy file name to clipboardExpand all lines: src/components/settings/Settings.mdx
+24-24Lines changed: 24 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,12 @@ import { Meta } from "@storybook/addon-docs/blocks";
6
6
7
7
# Settings Component
8
8
9
+
> **Note (DOKAN_NEXT_MAJOR):** The `dependency_key` attribute has been removed
10
+
> from the settings schema. Use the field's `id` directly. `show_if` and
11
+
> `dependencies` rule keys are now flat field ids — dot-paths are no longer
12
+
> supported. See the [dependency_key cleanup plan](https://github.com/getdokan/dokan/blob/refactor/simplify-settings-to-flat-array/docs/superpowers/plans/2026-05-18-dependency-key-cleanup.md)
13
+
> for migration context.
14
+
9
15
A reusable, schema-driven settings page that renders a full UI from a JSON structure.
10
16
Designed for WordPress plugin settings with built-in extensibility.
0 commit comments