@phis/ui 0.8.2 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/components/calendar/gregory-calendar-adapter-client.js +1 -0
  2. package/components/controls/phi-accordion-control.d.ts +6 -0
  3. package/components/controls/phi-accordion-control.js +8 -13
  4. package/components/controls/phi-background-control.js +2 -5
  5. package/components/controls/phi-builder-insert-picker-control-labels.d.ts +2 -0
  6. package/components/controls/phi-builder-insert-picker-control-labels.js +1 -0
  7. package/components/controls/phi-builder-insert-picker-control.js +10 -11
  8. package/components/controls/phi-cascader-control.d.ts +9 -3
  9. package/components/controls/phi-cascader-control.js +38 -10
  10. package/components/controls/phi-checkbox-group-control.d.ts +3 -1
  11. package/components/controls/phi-checkbox-group-control.js +2 -2
  12. package/components/controls/phi-collapse-control.d.ts +9 -2
  13. package/components/controls/phi-collapse-control.js +14 -2
  14. package/components/controls/phi-color-control.d.ts +3 -1
  15. package/components/controls/phi-color-control.js +2 -2
  16. package/components/controls/phi-color-field-control.d.ts +6 -1
  17. package/components/controls/phi-color-field-control.js +2 -2
  18. package/components/controls/phi-confirm-control.d.ts +1 -1
  19. package/components/controls/phi-confirm-control.js +71 -2
  20. package/components/controls/phi-confirm-dialog.js +2 -1
  21. package/components/controls/phi-date-picker-control.js +1 -1
  22. package/components/controls/phi-dimension-control.d.ts +3 -1
  23. package/components/controls/phi-dimension-control.js +2 -2
  24. package/components/controls/phi-geometry-control.js +1 -1
  25. package/components/controls/phi-length-control.d.ts +6 -1
  26. package/components/controls/phi-length-control.js +3 -2
  27. package/components/controls/phi-multi-select-control.d.ts +6 -1
  28. package/components/controls/phi-multi-select-control.js +3 -3
  29. package/components/controls/phi-segmented-control.d.ts +6 -1
  30. package/components/controls/phi-segmented-control.js +3 -3
  31. package/components/controls/phi-switch-control.d.ts +3 -1
  32. package/components/controls/phi-switch-control.js +3 -3
  33. package/components/controls/phi-table-control.d.ts +8 -1
  34. package/components/controls/phi-table-control.js +8 -2
  35. package/components/forms/compound-form-controls.js +16 -1
  36. package/components/layouts/clients/phi-collapsible-layout-client.js +2 -6
  37. package/components/media/media-widget-labels.d.ts +2 -0
  38. package/components/media/media-widget-labels.js +2 -0
  39. package/components/media/phi-asset-inspector-section.js +19 -1
  40. package/components/regions/presets/phi-area-shell-preset-nodes.js +2 -0
  41. package/components/shell/phi-builder-icon.js +9 -1
  42. package/components/tables/phi-table-surface.d.ts +25 -0
  43. package/components/tables/phi-table-surface.js +25 -0
  44. package/components/widgets/builder/phi-static-rows-editor.js +4 -1
  45. package/components/widgets/client/shared/phi-choice-controller.d.ts +8 -1
  46. package/components/widgets/client/shared/phi-choice-controller.js +16 -1
  47. package/components/widgets/config/choice-shared.d.ts +2 -0
  48. package/components/widgets/config/choice-shared.js +1 -0
  49. package/components/widgets/config/image-variant-options.d.ts +4 -1
  50. package/components/widgets/config/image-variant-options.js +27 -14
  51. package/components/widgets/inspector-field-row.d.ts +14 -1
  52. package/components/widgets/inspector-field-row.js +21 -1
  53. package/components/widgets/label-sets/builder-chrome.js +2 -0
  54. package/components/widgets/label-sets/inspector.js +10 -0
  55. package/components/widgets/label-sets/security.js +2 -0
  56. package/components/widgets/label-types/inspector.d.ts +5 -0
  57. package/components/widgets/label-types/inspector.js +5 -0
  58. package/components/widgets/label-types/security.d.ts +2 -0
  59. package/components/widgets/signals/signal-endpoint-list.js +4 -1
  60. package/helpers/cms-inspector-drawer.d.ts +15 -0
  61. package/helpers/cms-inspector-drawer.js +37 -0
  62. package/helpers/cms-layout-defaults.js +1 -1
  63. package/helpers/preset-tree-contract-check.js +56 -0
  64. package/helpers/text-source.js +2 -0
  65. package/package.json +4 -4
  66. package/plugins/runtime-modules/accounting/definition.d.ts +1 -1
  67. package/plugins/runtime-modules/accounting/definition.js +0 -1
  68. package/plugins/runtime-modules/accounting/ids.d.ts +4 -4
  69. package/plugins/runtime-modules/accounting/ids.js +4 -2
  70. package/plugins/runtime-modules/accounting/module.d.ts +1 -1
  71. package/plugins/runtime-modules/accounting/trees/accounting-customer-file-label-set.js +2 -1
  72. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-customer-file-page-tree.d.ts +5 -4
  73. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-customer-file-page-tree.js +80 -38
  74. package/plugins/runtime-modules/admin/definition.d.ts +1 -1
  75. package/plugins/runtime-modules/admin/definition.js +0 -1
  76. package/plugins/runtime-modules/admin/module.d.ts +1 -1
  77. package/plugins/runtime-modules/app/definition.d.ts +1 -1
  78. package/plugins/runtime-modules/app/definition.js +0 -1
  79. package/plugins/runtime-modules/app/module.d.ts +1 -1
  80. package/plugins/runtime-modules/area-base-definition.d.ts +19 -1
  81. package/plugins/runtime-modules/area-base-definition.js +18 -0
  82. package/plugins/runtime-modules/area-definitions.d.ts +8 -8
  83. package/plugins/runtime-modules/area-definitions.js +4 -3
  84. package/plugins/runtime-modules/area-root-route.d.ts +8 -0
  85. package/plugins/runtime-modules/area-root-route.js +11 -1
  86. package/plugins/runtime-modules/asset/labels.js +4 -0
  87. package/plugins/runtime-modules/asset/metadata-form.d.ts +0 -28
  88. package/plugins/runtime-modules/asset/metadata-form.js +6 -10
  89. package/plugins/runtime-modules/asset/services/options.d.ts +3 -2
  90. package/plugins/runtime-modules/asset/services/options.js +4 -3
  91. package/plugins/runtime-modules/asset/trees/phi-default-admin-media-settings-page-tree.js +2 -1
  92. package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +3 -3
  93. package/plugins/runtime-modules/auth/widgets/security/client.js +2 -2
  94. package/plugins/runtime-modules/builder/addresses.d.ts +1 -1
  95. package/plugins/runtime-modules/builder/addresses.js +1 -1
  96. package/plugins/runtime-modules/builder/area-settings-form.js +1 -1
  97. package/plugins/runtime-modules/builder/clients/inspector-condition-group.d.ts +16 -0
  98. package/plugins/runtime-modules/builder/clients/inspector-condition-group.js +9 -0
  99. package/plugins/runtime-modules/builder/clients/inspector-config-field.js +97 -10
  100. package/plugins/runtime-modules/builder/clients/pages-header.js +7 -6
  101. package/plugins/runtime-modules/builder/clients/region-visibility-fields.js +1 -1
  102. package/plugins/runtime-modules/builder/controller/workspace-controller.js +7 -4
  103. package/plugins/runtime-modules/builder/definition.d.ts +1 -1
  104. package/plugins/runtime-modules/builder/definition.js +0 -1
  105. package/plugins/runtime-modules/builder/offered-page-catalog.d.ts +10 -4
  106. package/plugins/runtime-modules/builder/offered-page-catalog.js +35 -8
  107. package/plugins/runtime-modules/builder/page-meta-form.js +5 -2
  108. package/plugins/runtime-modules/builder/plugin-meta-labels.js +8 -0
  109. package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +4 -2
  110. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +20 -13
  111. package/plugins/runtime-modules/builder/workspace-catalog-actions.js +8 -1
  112. package/plugins/runtime-modules/cdn/trees/phi-default-admin-cdn-page-tree.js +26 -14
  113. package/plugins/runtime-modules/core/authoring-widgets.js +2 -1
  114. package/plugins/runtime-modules/core/messaging/label-defaults.d.ts +49 -0
  115. package/plugins/runtime-modules/core/messaging/label-defaults.js +48 -0
  116. package/plugins/runtime-modules/core/messaging/labels.d.ts +2 -28
  117. package/plugins/runtime-modules/core/messaging/labels.js +52 -23
  118. package/plugins/runtime-modules/core/widgets/card/config.d.ts +14 -0
  119. package/plugins/runtime-modules/core/widgets/command-toolbar/config.d.ts +14 -0
  120. package/plugins/runtime-modules/core/widgets/description/config.d.ts +14 -0
  121. package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +14 -0
  122. package/plugins/runtime-modules/core/widgets/float-button/config.d.ts +14 -0
  123. package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +14 -0
  124. package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +14 -0
  125. package/plugins/runtime-modules/core/widgets/result/config.d.ts +14 -0
  126. package/plugins/runtime-modules/core/widgets/select-box/client.js +13 -4
  127. package/plugins/runtime-modules/core/widgets/select-box/config.js +1 -0
  128. package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +14 -0
  129. package/plugins/runtime-modules/core/widgets/table/client.js +11 -4
  130. package/plugins/runtime-modules/core/widgets/table/config.d.ts +1 -1143
  131. package/plugins/runtime-modules/core/widgets/table/config.js +144 -125
  132. package/plugins/runtime-modules/core/widgets/thread-conversation/authoring.d.ts +2 -0
  133. package/plugins/runtime-modules/core/widgets/thread-conversation/authoring.js +76 -0
  134. package/plugins/runtime-modules/core/widgets/thread-conversation/client.d.ts +44 -1
  135. package/plugins/runtime-modules/core/widgets/thread-conversation/client.js +28 -13
  136. package/plugins/runtime-modules/editor/definition.d.ts +1 -1
  137. package/plugins/runtime-modules/editor/definition.js +0 -1
  138. package/plugins/runtime-modules/editor/module.d.ts +1 -1
  139. package/plugins/runtime-modules/phi-default-site-area-preset-tree.js +16 -8
  140. package/plugins/runtime-modules/public/definition.d.ts +1 -1
  141. package/plugins/runtime-modules/public/definition.js +0 -1
  142. package/plugins/runtime-modules/public/module.d.ts +1 -1
  143. package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +109 -86
  144. package/plugins/runtime-modules/threads/controller/client.js +10 -12
  145. package/plugins/runtime-modules/threads/controller/definition.d.ts +6 -0
  146. package/plugins/runtime-modules/threads/controller/definition.js +17 -6
  147. package/styles/controls.css +49 -1
  148. package/styles/layout.css +3 -2
  149. package/types/calendar.d.ts +5 -0
  150. package/types/cms-plugins.d.ts +30 -10
  151. package/types/table-widget.d.ts +6 -0
@@ -104,6 +104,7 @@ function renderDatePicker(props) {
104
104
  format: props.format,
105
105
  size: props.controlSize,
106
106
  variant: props.variant,
107
+ "aria-label": props.ariaLabel,
107
108
  "aria-labelledby": props.ariaLabelledBy,
108
109
  minDate: props.min ? dayjs(props.min.isoDate) : undefined,
109
110
  maxDate: props.max ? dayjs(props.max.isoDate) : undefined,
@@ -15,10 +15,16 @@ import type { ReactNode } from "react";
15
15
  *
16
16
  * It is controlled, because every caller already keeps the open section somewhere it survives a reload,
17
17
  * and a Control that also kept its own would give them two answers to the same question.
18
+ *
19
+ * **It draws through `PhiCollapseControl`**, the folding sections the Collapsible Layout draws with, so a
20
+ * section's `description` is the same (i) behind its title in both and the click on it folds nothing.
21
+ * What stays here is the undoing: no ground, no inline inset, the size of chrome.
18
22
  */
19
23
  export type PhiAccordionControlSection = {
20
24
  key: string;
21
25
  label: ReactNode;
26
+ /** What the section is about, behind (i) after its title (`PhiCollapseControlSection.description`). */
27
+ description?: ReactNode;
22
28
  children: ReactNode;
23
29
  };
24
30
  export type PhiAccordionControlProps = {
@@ -1,17 +1,12 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { Collapse } from "antd";
3
+ import { usePhiConfig } from "../root/phi-config-provider";
4
+ import { PhiCollapseControl } from "./phi-collapse-control";
4
5
  export function PhiAccordionControl({ sections, openSection = "", onOpenSectionChange, }) {
5
- return (_jsx(Collapse, { accordion: true, bordered: false, size: "small", activeKey: openSection,
6
- // An accordion closes the last section as it opens the next, so the primitive still answers with a
7
- // list and it is always the one key or none.
8
- onChange: (keys) => onOpenSectionChange?.(Array.isArray(keys) ? keys[0] ?? "" : String(keys ?? "")), styles: {
9
- root: { background: "transparent" },
10
- header: { alignItems: "center", paddingInline: 0 },
11
- body: { paddingInline: 0 },
12
- }, items: sections.map((section) => ({
13
- key: section.key,
14
- label: section.label,
15
- children: section.children,
16
- })) }));
6
+ const { token } = usePhiConfig();
7
+ return (_jsx(PhiCollapseControl, { accordion: true,
8
+ // The whole row folds, as the primitive's own default did.
9
+ collapsible: "row", size: "small", headerClassName: "phi-accordion-control__header", headerPadding: `${token.paddingXS}px 0`, bodyPadding: `0 0 ${token.padding}px`, style: { background: "transparent" }, openKeys: openSection ? [openSection] : [],
10
+ // An accordion closes the last section as it opens the next, so the list is always the one key or none.
11
+ onOpenKeysChange: (keys) => onOpenSectionChange?.(keys[0] ?? ""), sections: sections }));
17
12
  }
@@ -7,7 +7,7 @@ import { PHI_BACKGROUND_BASE_KINDS, PHI_BACKGROUND_IMAGE_SOURCE_KINDS, PHI_BACKG
7
7
  import { PHI_CORE_BACKGROUND_PATTERN_PROVIDERS, resolvePhiBackgroundPatternDefaultValues, resolvePhiBackgroundPatternProvider, } from "../widgets/config/background-pattern-authoring";
8
8
  import { PHI_DEFAULT_BACKGROUND_PATTERN_KEY, } from "../widgets/config/background-pattern-contract";
9
9
  import { mergePhiBackgroundPatternInkEdit, resolvePhiBackgroundOverlayInk, switchPhiBackgroundPatternInkKind, withPhiBackgroundPatternInkDirection, resolvePhiBackgroundPatternLiveLayer, } from "../widgets/config/background-pattern-live";
10
- import { PhiImageAssetVariantKeyName } from "../../constants/media";
10
+ import { PHI_IMAGE_VARIANT_OPTIONS } from "../widgets/config/image-variant-options";
11
11
  import { normalizeMediaFocalRect } from "../media/focal-rect";
12
12
  import { PHI_BACKGROUND_WIDGET_DEFAULT_LABELS, } from "../widgets/label-types/background";
13
13
  import { PHI_BACKGROUND_FILTERS, } from "../../types/layout-style";
@@ -43,10 +43,7 @@ function withoutPhiBackgroundImageSource(base) {
43
43
  }
44
44
  const BACKGROUND_IMAGE_VARIANT_OPTIONS = [
45
45
  { value: "__original__", label: "original" },
46
- ...Object.entries(PhiImageAssetVariantKeyName).map(([value, label]) => ({
47
- value: Number(value),
48
- label,
49
- })),
46
+ ...PHI_IMAGE_VARIANT_OPTIONS,
50
47
  ];
51
48
  function toPickerValue(background) {
52
49
  const normalized = normalizePhiBackgroundWidgetConfig(background ?? null);
@@ -3,6 +3,8 @@ export type PhiBuilderInsertPickerControlLabels = {
3
3
  pickWidget: string;
4
4
  layouts: string;
5
5
  widgets: string;
6
+ /** The accessible name of the switch between Layouts and Widgets, which has no visible label. */
7
+ section: string;
6
8
  searchLayouts: string;
7
9
  searchWidgets: string;
8
10
  filterPackages: string;
@@ -3,6 +3,7 @@ export const PHI_BUILDER_INSERT_PICKER_CONTROL_DEFAULT_LABELS = {
3
3
  pickWidget: "Pick widget",
4
4
  layouts: "Layouts",
5
5
  widgets: "Widgets",
6
+ section: "Insert a layout or a widget",
6
7
  searchLayouts: "Search layouts",
7
8
  searchWidgets: "Search widgets",
8
9
  filterPackages: "Filter packages",
@@ -1,10 +1,14 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useMemo, useState } from "react";
4
- import { Flex, Input, Segmented, Select, Tag, Tooltip, Typography, theme as antdTheme } from "antd";
4
+ import { Flex, Tag, Tooltip, Typography, theme as antdTheme } from "antd";
5
5
  import { PhiIcon } from "../shell/phi-icon";
6
6
  import { PhiFlexControl } from "./phi-flex-control";
7
+ import { PhiMultiSelectControl } from "./phi-multi-select-control";
7
8
  import { PhiPopoverControl } from "./phi-popover-control";
9
+ import { PhiSegmentedControl } from "./phi-segmented-control";
10
+ import { PhiSelectControl } from "./phi-select-control";
11
+ import { PhiTextControl } from "./phi-text-control";
8
12
  import { usePhiImmediatePicker } from "./use-phi-immediate-picker";
9
13
  import { PHI_BUILDER_INSERT_PICKER_CONTROL_DEFAULT_LABELS, } from "./phi-builder-insert-picker-control-labels";
10
14
  function normalizeSearchText(value) {
@@ -180,10 +184,10 @@ export function PhiBuilderInsertPickerControl({ open, trigger, items, section, p
180
184
  display: "flex",
181
185
  flexDirection: "column",
182
186
  overflow: "hidden",
183
- }, onClick: (event) => event.stopPropagation(), onMouseDown: (event) => event.stopPropagation(), onPointerDown: (event) => event.stopPropagation(), onKeyDown: (event) => event.stopPropagation(), children: _jsxs(Flex, { vertical: true, gap: token.paddingSM, style: { width: "100%", minHeight: 0, overflow: "hidden" }, children: [_jsxs(Flex, { align: "center", justify: "space-between", gap: token.paddingSM, wrap: true, children: [_jsx(Typography.Text, { strong: true, style: { fontSize: token.fontSize }, children: title }), packageOptions.length > 1 ? (_jsx(Select, { size: "small", variant: "borderless", showSearch: false, value: packageFilters[0] ?? PHI_INSERT_PICKER_ALL_PACKAGES, onChange: (nextPackage) => onPackageFiltersChange(nextPackage === PHI_INSERT_PICKER_ALL_PACKAGES ? [] : [nextPackage]), options: [
187
+ }, onClick: (event) => event.stopPropagation(), onMouseDown: (event) => event.stopPropagation(), onPointerDown: (event) => event.stopPropagation(), onKeyDown: (event) => event.stopPropagation(), children: _jsxs(Flex, { vertical: true, gap: token.paddingSM, style: { width: "100%", minHeight: 0, overflow: "hidden" }, children: [_jsxs(Flex, { align: "center", justify: "space-between", gap: token.paddingSM, wrap: true, children: [_jsx(Typography.Text, { strong: true, style: { fontSize: token.fontSize }, children: title }), packageOptions.length > 1 ? (_jsx(PhiSelectControl, { size: "small", variant: "borderless", value: packageFilters[0] ?? PHI_INSERT_PICKER_ALL_PACKAGES, onChange: (nextPackage) => onPackageFiltersChange(nextPackage === PHI_INSERT_PICKER_ALL_PACKAGES ? [] : [nextPackage]), options: [
184
188
  { value: PHI_INSERT_PICKER_ALL_PACKAGES, label: labels.allPackages },
185
189
  ...packageOptions.map((packageName) => ({ value: packageName, label: packageName })),
186
- ], "aria-label": labels.filterPackages, style: { flex: "1 1 0", minWidth: 0 } })) : null, section === "widget" && categoryOptions.length > 1 ? (_jsx(Select, { mode: "multiple", size: "small", variant: "borderless", allowClear: true, showSearch: false, value: [...widgetCategoryFilters], onChange: onWidgetCategoryFiltersChange, options: categoryOptions.map((category) => ({ value: category, label: category })), placeholder: labels.filterCategories, "aria-label": labels.filterCategories, maxTagCount: "responsive", style: { flex: "1 1 0", minWidth: 0 } })) : null, _jsx(Segmented, { value: section, onChange: (nextSection) => {
190
+ ], ariaLabel: labels.filterPackages, style: { flex: "1 1 0", minWidth: 0 } })) : null, section === "widget" && categoryOptions.length > 1 ? (_jsx(PhiMultiSelectControl, { size: "small", variant: "borderless", allowClear: true, value: widgetCategoryFilters, onChange: onWidgetCategoryFiltersChange, options: categoryOptions.map((category) => ({ value: category, label: category })), placeholder: labels.filterCategories, ariaLabel: labels.filterCategories, maxTagCount: "responsive", style: { flex: "1 1 0", minWidth: 0 } })) : null, _jsx(PhiSegmentedControl, { ariaLabel: labels.section, value: section, onChange: (nextSection) => {
187
191
  if (nextSection === "layout" && !allowLayoutSection) {
188
192
  onSectionChange("widget");
189
193
  return;
@@ -192,14 +196,9 @@ export function PhiBuilderInsertPickerControl({ open, trigger, items, section, p
192
196
  }, size: "small", options: [
193
197
  { label: labels.layouts, value: "layout", disabled: !allowLayoutSection },
194
198
  { label: labels.widgets, value: "widget", disabled: !allowWidgetSection },
195
- ] })] }), _jsx(Input, { autoFocus: true, allowClear: true, value: search, onChange: (event) => setSearch(event.target.value), placeholder: placeholder, variant: "borderless", style: {
196
- borderBottom: `1px solid ${token.colorBorderSecondary}`,
197
- borderRadius: 0,
198
- paddingInline: 0,
199
- boxShadow: "none",
200
- } }), _jsx("div", { style: {
199
+ ] })] }), _jsx(PhiTextControl, { inputType: "search", size: "small", autoFocus: true, allowClear: true, value: search, onChange: (nextSearch) => setSearch(nextSearch ?? ""), placeholder: placeholder }), _jsx("div", { style: {
201
200
  border: `1px solid ${token.colorBorderSecondary}`,
202
- borderRadius: 0,
201
+ borderRadius: token.borderRadius,
203
202
  background: token.colorBgElevated,
204
203
  padding: token.paddingSM,
205
204
  flex: "0 1 auto",
@@ -220,7 +219,7 @@ export function PhiBuilderInsertPickerControl({ open, trigger, items, section, p
220
219
  paddingInline: 0,
221
220
  paddingBlock: token.paddingSM,
222
221
  borderBottom: isLast ? "none" : `1px solid ${token.colorBorderSecondary}`,
223
- borderRadius: 0,
222
+ borderRadius: token.borderRadiusSM,
224
223
  background: isActive ? token.colorFillQuaternary : "transparent",
225
224
  outline: isActive ? `1px solid ${token.colorPrimary}` : "none",
226
225
  outlineOffset: -1,
@@ -12,7 +12,7 @@ export declare function normalizePhiCascaderValue(value: string | null | undefin
12
12
  rootValue?: string | null;
13
13
  normalize?: PhiCascaderNormalizeMode | null;
14
14
  }): string;
15
- export declare function PhiCascaderControl({ value, options, allowRoot, allowClear, expandTrigger, select, separator, rootValue, normalize, disabled, readOnly, label, placeholder, size, onChange, onFocus, onBlur, classNames, getPopupContainer, style, }: {
15
+ export declare function PhiCascaderControl({ value, options, allowRoot, allowClear, expandTrigger, select, separator, rootValue, normalize, disabled, readOnly, label, ariaLabel, placeholder, size, onChange, onFocus, onBlur, classNames, getPopupContainer, style, }: {
16
16
  value?: string | null;
17
17
  options?: readonly PhiCascaderOption[];
18
18
  allowRoot?: boolean;
@@ -21,7 +21,8 @@ export declare function PhiCascaderControl({ value, options, allowRoot, allowCle
21
21
  /**
22
22
  * What a click may choose. `any` (the default) takes every level, so a path picker can stop at a parent;
23
23
  * `options` takes only a value the options name, and a level the Cascader made up from deeper paths is a
24
- * group that opens and chooses nothing -- a page picker, whose folders are no Pages.
24
+ * group that opens and chooses nothing, drawn under a folder icon -- a page picker, whose folders are no
25
+ * Pages. Neither the root nor the current value is drawn there unless the options name it.
25
26
  */
26
27
  select?: PhiCascaderSelect;
27
28
  separator?: string;
@@ -30,6 +31,8 @@ export declare function PhiCascaderControl({ value, options, allowRoot, allowCle
30
31
  disabled?: boolean;
31
32
  readOnly?: boolean;
32
33
  label?: string;
34
+ /** The accessible name where no visible label stands beside the field; it takes precedence over `label`. */
35
+ ariaLabel?: string;
33
36
  placeholder?: string;
34
37
  size?: PhiControlSize;
35
38
  onChange?: (nextValue: string) => void;
@@ -50,10 +53,13 @@ export declare function PhiCascaderControl({ value, options, allowRoot, allowCle
50
53
  * `disabled` on an option greys its own box only, so a node that cannot be chosen still opens onto the
51
54
  * children that can.
52
55
  */
53
- export declare function PhiTreeCascaderControl({ value, options, disabled, placeholder, size, onChange, getPopupContainer, style, }: {
56
+ export declare function PhiTreeCascaderControl({ value, options, disabled, label, ariaLabel, placeholder, size, onChange, getPopupContainer, style, }: {
54
57
  value?: readonly string[];
55
58
  options: readonly PhiTreeOption[];
56
59
  disabled?: boolean;
60
+ label?: string;
61
+ /** The accessible name where no visible label stands beside the field; it takes precedence over `label`. */
62
+ ariaLabel?: string;
57
63
  placeholder?: string;
58
64
  size?: PhiControlSize;
59
65
  onChange?: (nextValue: string[]) => void;
@@ -123,20 +123,46 @@ function insertCascaderOption(options, option, allowRoot, separator, rootValue,
123
123
  }
124
124
  });
125
125
  }
126
- function buildCascaderOptions(configuredOptions, currentValue, allowRoot, separator, rootValue, normalize) {
126
+ /** What a level the Cascader made up stands under when it chooses nothing: a folder, as in the Page trees. */
127
+ const PHI_CASCADER_GROUP_ICON = "antd:folder";
128
+ /** Every level that holds others and is not an option of its own gets the folder icon. */
129
+ function markCascaderGroups(options, choosableValues) {
130
+ for (const option of options) {
131
+ const children = option.children;
132
+ if (!children?.length) {
133
+ continue;
134
+ }
135
+ if (option.icon == null && !choosableValues.has(String(option.value))) {
136
+ option.icon = PHI_CASCADER_GROUP_ICON;
137
+ }
138
+ markCascaderGroups(children, choosableValues);
139
+ }
140
+ }
141
+ function buildCascaderOptions(configuredOptions, currentValue, allowRoot, separator, rootValue, normalize, choosableValues) {
127
142
  const options = [];
128
- if (allowRoot) {
143
+ /*
144
+ * With `select: "options"` (`choosableValues` set) only what the options name is drawn as an entry of
145
+ * its own. The root and the current value are otherwise added whether or not anybody offered them, and
146
+ * a root nobody offered stood first in the list as a `/` that a click could not choose.
147
+ */
148
+ const offers = (value) => choosableValues == null || choosableValues.has(value);
149
+ if (allowRoot && offers(rootValue)) {
129
150
  const configuredRoot = configuredOptions.find((option) => normalizePhiCascaderValue(option.value, { separator, rootValue, normalize }) === rootValue);
130
151
  insertCascaderOption(options, { value: rootValue, label: configuredRoot?.label ?? rootValue }, allowRoot, separator, rootValue, normalize);
131
152
  }
132
153
  for (const option of configuredOptions) {
133
154
  insertCascaderOption(options, option, allowRoot, separator, rootValue, normalize);
134
155
  }
135
- insertCascaderOption(options, { value: currentValue, label: titleizeSegment(currentValue, rootValue) }, allowRoot, separator, rootValue, normalize);
156
+ if (offers(currentValue)) {
157
+ insertCascaderOption(options, { value: currentValue, label: titleizeSegment(currentValue, rootValue) }, allowRoot, separator, rootValue, normalize);
158
+ }
159
+ if (choosableValues != null) {
160
+ markCascaderGroups(options, choosableValues);
161
+ }
136
162
  return options;
137
163
  }
138
- export function PhiCascaderControl({ value, options, allowRoot = true, allowClear = false, expandTrigger = "click", select = "any", separator = "/", rootValue = "/", normalize = "raw", disabled = false, readOnly = false, label, placeholder, size, onChange, onFocus, onBlur, classNames, getPopupContainer, style, }) {
139
- const { labelId, labelledBy } = usePhiControlLabel(label);
164
+ export function PhiCascaderControl({ value, options, allowRoot = true, allowClear = false, expandTrigger = "click", select = "any", separator = "/", rootValue = "/", normalize = "raw", disabled = false, readOnly = false, label, ariaLabel, placeholder, size, onChange, onFocus, onBlur, classNames, getPopupContainer, style, }) {
165
+ const { labelId, labelledBy } = usePhiControlLabel(label, ariaLabel);
140
166
  const { token } = usePhiConfig();
141
167
  const resolvedSeparator = separator.trim() || "/";
142
168
  const resolvedRootValue = rootValue.trim() || "/";
@@ -153,13 +179,13 @@ export function PhiCascaderControl({ value, options, allowRoot = true, allowClea
153
179
  */
154
180
  const [open, setOpen] = useState(false);
155
181
  const keepOpen = useRef(false);
156
- const cascaderOptions = useMemo(() => buildCascaderOptions(options ?? [], normalizedValue, allowRoot, resolvedSeparator, resolvedRootValue, normalize), [allowRoot, normalize, normalizedValue, options, resolvedRootValue, resolvedSeparator]);
157
- const cascaderValue = findOptionPath(cascaderOptions, normalizedValue, resolvedSeparator, resolvedRootValue) ?? [];
158
182
  const choosableValues = useMemo(() => new Set((options ?? []).map((option) => normalizePhiCascaderValue(option.value, {
159
183
  separator: resolvedSeparator,
160
184
  rootValue: resolvedRootValue,
161
185
  normalize,
162
186
  }))), [normalize, options, resolvedRootValue, resolvedSeparator]);
187
+ const cascaderOptions = useMemo(() => buildCascaderOptions(options ?? [], normalizedValue, allowRoot, resolvedSeparator, resolvedRootValue, normalize, select === "options" ? choosableValues : null), [allowRoot, choosableValues, normalize, normalizedValue, options, resolvedRootValue, resolvedSeparator, select]);
188
+ const cascaderValue = findOptionPath(cascaderOptions, normalizedValue, resolvedSeparator, resolvedRootValue) ?? [];
163
189
  function commit(nextValue) {
164
190
  const normalizedNextValue = normalizePhiCascaderValue(nextValue, {
165
191
  separator: resolvedSeparator,
@@ -176,7 +202,7 @@ export function PhiCascaderControl({ value, options, allowRoot = true, allowClea
176
202
  setSearchValue("");
177
203
  onChange?.(normalizedNextValue);
178
204
  }
179
- const control = (_jsx(Cascader, { "aria-labelledby": labelledBy, allowClear: allowClear, changeOnSelect: true, expandTrigger: expandTrigger, open: open, onOpenChange: (next) => {
205
+ const control = (_jsx(Cascader, { "aria-label": ariaLabel, "aria-labelledby": labelledBy, allowClear: allowClear, changeOnSelect: true, expandTrigger: expandTrigger, open: open, onOpenChange: (next) => {
180
206
  if (!next && keepOpen.current) {
181
207
  keepOpen.current = false;
182
208
  return;
@@ -227,7 +253,8 @@ export function PhiCascaderControl({ value, options, allowRoot = true, allowClea
227
253
  * `disabled` on an option greys its own box only, so a node that cannot be chosen still opens onto the
228
254
  * children that can.
229
255
  */
230
- export function PhiTreeCascaderControl({ value, options, disabled = false, placeholder, size, onChange, getPopupContainer, style, }) {
256
+ export function PhiTreeCascaderControl({ value, options, disabled = false, label, ariaLabel, placeholder, size, onChange, getPopupContainer, style, }) {
257
+ const { labelId, labelledBy } = usePhiControlLabel(label, ariaLabel);
231
258
  const { token } = usePhiConfig();
232
259
  const { cascaderOptions, pathByValue } = useMemo(() => {
233
260
  const paths = new Map();
@@ -248,11 +275,12 @@ export function PhiTreeCascaderControl({ value, options, disabled = false, place
248
275
  const path = pathByValue.get(entry);
249
276
  return path ? [path] : [];
250
277
  });
251
- return (_jsx(Cascader, { multiple: true, showCheckedStrategy: Cascader.SHOW_PARENT, rootClassName: "phi-cascader-control", disabled: disabled || !onChange, options: cascaderOptions, optionRender: (option) => option.description ? (_jsxs("span", { style: { display: "inline-flex", alignItems: "center", gap: token.paddingXS, minWidth: 0 }, children: [_jsx(PhiDescriptionHint, { description: option.description }), option.label] })) : option.label, placeholder: placeholder, size: size, showSearch: true, maxTagCount: "responsive", value: cascaderValue, getPopupContainer: getPopupContainer, onChange: (next) => {
278
+ const control = (_jsx(Cascader, { "aria-label": ariaLabel, "aria-labelledby": labelledBy, multiple: true, showCheckedStrategy: Cascader.SHOW_PARENT, rootClassName: "phi-cascader-control", disabled: disabled || !onChange, options: cascaderOptions, optionRender: (option) => option.description ? (_jsxs("span", { style: { display: "inline-flex", alignItems: "center", gap: token.paddingXS, minWidth: 0 }, children: [_jsx(PhiDescriptionHint, { description: option.description }), option.label] })) : option.label, placeholder: placeholder, size: size, showSearch: true, maxTagCount: "responsive", value: cascaderValue, getPopupContainer: getPopupContainer, onChange: (next) => {
252
279
  const values = (next ?? []).flatMap((path) => {
253
280
  const last = Array.isArray(path) ? path.at(-1) : null;
254
281
  return last == null ? [] : [String(last)];
255
282
  });
256
283
  onChange?.(values);
257
284
  }, style: { width: "100%", ...style } }));
285
+ return (_jsx(PhiLabeledControl, { label: label, labelId: labelId, fill: style?.width === undefined || style.width === "100%", children: control }));
258
286
  }
@@ -1,10 +1,12 @@
1
1
  import type { PhiControlOption } from "./phi-control-options";
2
2
  export type PhiCheckboxGroupControlProps<TValue extends string | number = string> = {
3
3
  value?: readonly TValue[];
4
+ /** The group's accessible name; the group has no visible label of its own. */
5
+ ariaLabel?: string;
4
6
  options: readonly PhiControlOption<TValue>[];
5
7
  disabled?: boolean;
6
8
  readOnly?: boolean;
7
9
  vertical?: boolean;
8
10
  onChange?: (value: TValue[]) => void;
9
11
  };
10
- export declare function PhiCheckboxGroupControl<TValue extends string | number = string>({ value, options, disabled, readOnly, vertical, onChange, }: PhiCheckboxGroupControlProps<TValue>): import("react").JSX.Element;
12
+ export declare function PhiCheckboxGroupControl<TValue extends string | number = string>({ value, ariaLabel, options, disabled, readOnly, vertical, onChange, }: PhiCheckboxGroupControlProps<TValue>): import("react").JSX.Element;
@@ -2,6 +2,6 @@
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { Checkbox, Flex } from "antd";
4
4
  import { PhiControlOptionContent } from "./phi-control-option-content";
5
- export function PhiCheckboxGroupControl({ value, options, disabled, readOnly, vertical, onChange, }) {
6
- return (_jsx(Checkbox.Group, { value: [...(value ?? [])], disabled: disabled || readOnly || !onChange, onChange: (nextValue) => onChange?.(nextValue), style: { width: "100%" }, children: _jsx(Flex, { vertical: vertical, gap: "small", wrap: vertical ? false : "wrap", children: options.map((option) => (_jsx(Checkbox, { value: option.value, disabled: option.disabled, children: _jsx(PhiControlOptionContent, { option: option, presentation: "option" }) }, option.value))) }) }));
5
+ export function PhiCheckboxGroupControl({ value, ariaLabel, options, disabled, readOnly, vertical, onChange, }) {
6
+ return (_jsx(Checkbox.Group, { role: "group", "aria-label": ariaLabel, value: [...(value ?? [])], disabled: disabled || readOnly || !onChange, onChange: (nextValue) => onChange?.(nextValue), style: { width: "100%" }, children: _jsx(Flex, { vertical: vertical, gap: "small", wrap: vertical ? false : "wrap", children: options.map((option) => (_jsx(Checkbox, { value: option.value, disabled: option.disabled, children: _jsx(PhiControlOptionContent, { option: option, presentation: "option" }) }, option.value))) }) }));
7
7
  }
@@ -3,8 +3,9 @@ import type { PhiControlSize } from "../../types/control";
3
3
  /**
4
4
  * Sections that fold, each on its own or one at a time -- the whole surface the CollapsibleLayout needs.
5
5
  *
6
- * PhiAccordionControl is the narrow case (one open, nothing to decide); this is the wide one, and it is
7
- * a Control so that the Layout describes sections and the primitive stays in this folder.
6
+ * PhiAccordionControl is the narrow case (one open, nothing to decide) and draws through this one; this
7
+ * is the wide one, and it is a Control so that the Layout describes sections and the primitive stays in
8
+ * this folder.
8
9
  *
9
10
  * It is controlled: the Layout keeps the open keys where they survive a reload and travel as a signal,
10
11
  * and a Control keeping its own would be a second answer to the same question.
@@ -12,6 +13,12 @@ import type { PhiControlSize } from "../../types/control";
12
13
  export type PhiCollapseControlSection = {
13
14
  key: string;
14
15
  label: ReactNode;
16
+ /**
17
+ * What the section is about, behind (i) after its title -- the one place a folding section says it,
18
+ * for the Collapsible Layout's `slotDescriptions` and a Widget's accordion alike. Reading it does not
19
+ * fold the section.
20
+ */
21
+ description?: ReactNode;
15
22
  children: ReactNode;
16
23
  /** Render the body while folded, so what is inside keeps running. */
17
24
  forceRender?: boolean;
@@ -1,6 +1,8 @@
1
1
  "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Collapse } from "antd";
4
+ import { PHI_SPACE } from "../../theme/antd-css-var-contract";
5
+ import { PhiDescriptionHint } from "./phi-description-tooltip-icon";
4
6
  /*
5
7
  * The grounds are square, because they are not an edge.
6
8
  *
@@ -21,12 +23,22 @@ function resolveSectionStyles(titleStrong, headerPadding, bodyPadding) {
21
23
  body: { ...(bodyPadding == null ? {} : { padding: bodyPadding }), paddingTop: 0, borderRadius: 0 },
22
24
  };
23
25
  }
26
+ /*
27
+ * The hint sits inside the header, and a header toggles its panel: reading the hint must not open or close
28
+ * what it describes, by pointer or by key.
29
+ */
30
+ function renderSectionLabel(section) {
31
+ const { label, description } = section;
32
+ if (description == null || description === "")
33
+ return label;
34
+ return (_jsxs("span", { style: { display: "inline-flex", alignItems: "center", gap: PHI_SPACE.xs }, children: [label, _jsx("span", { style: { display: "inline-flex" }, onClick: (event) => event.stopPropagation(), onKeyDown: (event) => event.stopPropagation(), children: _jsx(PhiDescriptionHint, { description: description }) })] }));
35
+ }
24
36
  export function PhiCollapseControl({ sections, openKeys, onOpenKeysChange, accordion = false, collapsible = "header", ghost = false, expandIconPlacement = "start", size, headerClassName, headerPadding, bodyPadding, titleStrong = false, style, }) {
25
37
  return (_jsx(Collapse, { accordion: accordion, activeKey: accordion ? openKeys[0] ?? undefined : [...openKeys],
26
38
  // The caller's box draws the outline; what stays here is `ghost`, which decides the inside.
27
39
  bordered: false, ghost: ghost, collapsible: collapsible === "row" ? undefined : collapsible, destroyOnHidden: false, expandIconPlacement: expandIconPlacement, size: size, classNames: headerClassName ? { header: headerClassName } : undefined, items: sections.map((section) => ({
28
40
  key: section.key,
29
- label: section.label,
41
+ label: renderSectionLabel(section),
30
42
  collapsible: collapsible === "row" ? undefined : collapsible,
31
43
  forceRender: section.forceRender,
32
44
  ...(section.hidden ? { style: { display: "none" } } : {}),
@@ -17,6 +17,8 @@ export type PhiColorPickerPreset = {
17
17
  export type PhiColorPickerPresets = readonly PhiColorPickerPreset[];
18
18
  export type PhiColorControlProps = PhiPickerTransactionCallbacks<string | null> & {
19
19
  value?: string | null;
20
+ /** The swatch's accessible name; the Control draws no label of its own. */
21
+ ariaLabel?: string;
20
22
  defaultValue?: string;
21
23
  disabled?: boolean;
22
24
  allowClear?: boolean;
@@ -35,4 +37,4 @@ export type PhiColorControlProps = PhiPickerTransactionCallbacks<string | null>
35
37
  renderPanel?: (panel: ReactNode) => ReactNode;
36
38
  onClear?: () => void;
37
39
  };
38
- export declare function PhiColorControl({ value, defaultValue, disabled, allowClear, disabledAlpha, mode, open, showText, trigger, placement, size, children, presets, getPopupContainer, popupClassName, renderPanel, onChange, onCommit, onDiscard, onOpenChange, onClear, }: PhiColorControlProps): import("react").JSX.Element;
40
+ export declare function PhiColorControl({ value, ariaLabel, defaultValue, disabled, allowClear, disabledAlpha, mode, open, showText, trigger, placement, size, children, presets, getPopupContainer, popupClassName, renderPanel, onChange, onCommit, onDiscard, onOpenChange, onClear, }: PhiColorControlProps): import("react").JSX.Element;
@@ -56,7 +56,7 @@ function resolveCssValue(nextValue, fallbackCss) {
56
56
  function resolveAntdMode(mode) {
57
57
  return mode === "both" ? ["single", "gradient"] : mode;
58
58
  }
59
- export function PhiColorControl({ value = null, defaultValue = "#f0f0f0", disabled, allowClear, disabledAlpha, mode = "single", open, showText, trigger, placement = "auto", size, children, presets = [], getPopupContainer, popupClassName, renderPanel, onChange, onCommit, onDiscard, onOpenChange, onClear, }) {
59
+ export function PhiColorControl({ value = null, ariaLabel, defaultValue = "#f0f0f0", disabled, allowClear, disabledAlpha, mode = "single", open, showText, trigger, placement = "auto", size, children, presets = [], getPopupContainer, popupClassName, renderPanel, onChange, onCommit, onDiscard, onOpenChange, onClear, }) {
60
60
  const { token } = theme.useToken();
61
61
  const picker = usePhiImmediatePicker({
62
62
  value,
@@ -93,7 +93,7 @@ export function PhiColorControl({ value = null, defaultValue = "#f0f0f0", disabl
93
93
  colors: [...preset.colors],
94
94
  defaultOpen: preset.defaultOpen,
95
95
  }));
96
- return (_jsx(ColorPicker, { mode: resolveAntdMode(mode), value: resolveAntdColorValue(resolvePhiColorReferences(picker.value, references), defaultValue), open: picker.open, disabled: disabled, allowClear: allowClear, disabledAlpha: disabledAlpha, trigger: trigger, placement: placement === "auto" ? undefined : placement, size: size, showText: resolvedShowText, presets: antdPresets, getPopupContainer: getPopupContainer, classNames: { popup: { root: joinPhiClassNames("phi-color-widget-popup", popupClassName) } }, styles: {
96
+ return (_jsx(ColorPicker, { "aria-label": ariaLabel, mode: resolveAntdMode(mode), value: resolveAntdColorValue(resolvePhiColorReferences(picker.value, references), defaultValue), open: picker.open, disabled: disabled, allowClear: allowClear, disabledAlpha: disabledAlpha, trigger: trigger, placement: placement === "auto" ? undefined : placement, size: size, showText: resolvedShowText, presets: antdPresets, getPopupContainer: getPopupContainer, classNames: { popup: { root: joinPhiClassNames("phi-color-widget-popup", popupClassName) } }, styles: {
97
97
  root: {
98
98
  display: "inline-flex",
99
99
  alignItems: "center",
@@ -7,6 +7,11 @@ import type { PhiThemeTokenKey } from "../../theme/phi-theme-tokens";
7
7
  import { type PhiColorControlCustomColor } from "./use-phi-color-control-presets";
8
8
  export type PhiColorFieldControlProps = {
9
9
  label?: string;
10
+ /**
11
+ * The swatch's accessible name where no visible label stands above it; it takes precedence over
12
+ * `label`, which names the swatch otherwise.
13
+ */
14
+ ariaLabel?: string;
10
15
  value?: string | null;
11
16
  defaultValue?: string;
12
17
  /** A Theme token to fall back to instead of `defaultValue`, read live so it follows the Theme. */
@@ -42,4 +47,4 @@ export type PhiColorFieldControlProps = {
42
47
  * authoring tool buttons. The Color Widget is the Core Module's placement of it, which adds its config
43
48
  * and its signals.
44
49
  */
45
- export declare function PhiColorFieldControl({ label, value, defaultValue: fixedDefaultValue, defaultToken, tokenKey, disabled, mode, showText, placement, allowClear, children, presets, getPopupContainer, popupClassName, renderPanel, onOpenChange, onCommit, onDiscard, onClear, customColors, storeThemeRoles, labels, onChange, onValueChange, }: PhiColorFieldControlProps): import("react").JSX.Element;
50
+ export declare function PhiColorFieldControl({ label, ariaLabel, value, defaultValue: fixedDefaultValue, defaultToken, tokenKey, disabled, mode, showText, placement, allowClear, children, presets, getPopupContainer, popupClassName, renderPanel, onOpenChange, onCommit, onDiscard, onClear, customColors, storeThemeRoles, labels, onChange, onValueChange, }: PhiColorFieldControlProps): import("react").JSX.Element;
@@ -15,7 +15,7 @@ import { PhiTypographyControl } from "./phi-typography-control";
15
15
  * authoring tool buttons. The Color Widget is the Core Module's placement of it, which adds its config
16
16
  * and its signals.
17
17
  */
18
- export function PhiColorFieldControl({ label, value, defaultValue: fixedDefaultValue = "#1677ff", defaultToken, tokenKey, disabled = false, mode = "single", showText, placement, allowClear, children, presets, getPopupContainer, popupClassName, renderPanel, onOpenChange, onCommit, onDiscard, onClear, customColors, storeThemeRoles = false, labels = PHI_COLOR_PICKER_DEFAULT_LABELS, onChange, onValueChange, }) {
18
+ export function PhiColorFieldControl({ label, ariaLabel, value, defaultValue: fixedDefaultValue = "#1677ff", defaultToken, tokenKey, disabled = false, mode = "single", showText, placement, allowClear, children, presets, getPopupContainer, popupClassName, renderPanel, onOpenChange, onCommit, onDiscard, onClear, customColors, storeThemeRoles = false, labels = PHI_COLOR_PICKER_DEFAULT_LABELS, onChange, onValueChange, }) {
19
19
  const { token } = usePhiConfig();
20
20
  const tokenValue = defaultToken ? token[defaultToken] : undefined;
21
21
  const defaultValue = typeof tokenValue === "string" ? tokenValue : fixedDefaultValue;
@@ -30,5 +30,5 @@ export function PhiColorFieldControl({ label, value, defaultValue: fixedDefaultV
30
30
  onChange?.(nextValue, tokenKey);
31
31
  onValueChange?.(nextValue, tokenKey);
32
32
  }
33
- return (_jsxs(PhiFlexControl, { vertical: true, gap: token.paddingXXS, align: "flex-start", style: { width: children ? "auto" : "100%", minWidth: 0, maxWidth: "100%" }, children: [label ? (_jsx(PhiTypographyControl, { type: "secondary", style: { fontSize: token.fontSizeSM }, children: label })) : null, _jsx(PhiColorControl, { mode: mode, showText: showText, placement: placement, disabled: disabled, allowClear: allowClear, value: resolvedValue, defaultValue: defaultValue, getPopupContainer: getPopupContainer, popupClassName: popupClassName, renderPanel: renderPanel, onOpenChange: onOpenChange, onCommit: onCommit, onDiscard: onDiscard, presets: pickerPresets, onChange: publish, children: children })] }));
33
+ return (_jsxs(PhiFlexControl, { vertical: true, gap: token.paddingXXS, align: "flex-start", style: { width: children ? "auto" : "100%", minWidth: 0, maxWidth: "100%" }, children: [label ? (_jsx(PhiTypographyControl, { type: "secondary", style: { fontSize: token.fontSizeSM }, children: label })) : null, _jsx(PhiColorControl, { ariaLabel: ariaLabel ?? label, mode: mode, showText: showText, placement: placement, disabled: disabled, allowClear: allowClear, value: resolvedValue, defaultValue: defaultValue, getPopupContainer: getPopupContainer, popupClassName: popupClassName, renderPanel: renderPanel, onOpenChange: onOpenChange, onCommit: onCommit, onDiscard: onDiscard, presets: pickerPresets, onChange: publish, children: children })] }));
34
34
  }
@@ -1,4 +1,4 @@
1
- import type { ReactNode } from "react";
1
+ import { type ReactNode } from "react";
2
2
  import type { PhiControlSize } from "../../types/control";
3
3
  import type { PhiButtonType } from "./phi-button-types";
4
4
  export declare const PHI_CONFIRM_PLACEMENTS: readonly ["top", "topLeft", "topRight", "bottom", "bottomLeft", "bottomRight", "left", "leftTop", "leftBottom", "right", "rightTop", "rightBottom"];
@@ -1,11 +1,80 @@
1
1
  "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useRef, useState } from "react";
3
4
  import { Popconfirm } from "antd";
5
+ import { PHI_SPACE } from "../../theme/antd-css-var-contract";
6
+ import { PHI_LAYOUT } from "../../theme/phi-tokens";
4
7
  import { PhiButtonControl } from "./phi-button-control";
8
+ import { PhiCompactGroupControl } from "./phi-compact-group-control";
9
+ import { PhiFlexControl } from "./phi-flex-control";
5
10
  import { PHI_POPUP_PLACEMENTS } from "./phi-picker-control-contract";
6
11
  export const PHI_CONFIRM_PLACEMENTS = PHI_POPUP_PLACEMENTS;
12
+ /*
13
+ * How wide a confirmation gets: a confirmation's measure (`contentMaxNarrow`), and never more than the
14
+ * window less its inset on both sides.
15
+ *
16
+ * Ant Design gives a Popconfirm no width of its own, so its text ran on as one line until the window
17
+ * stopped it -- a sentence of a few words drew a box across the whole page, and placed beside its trigger
18
+ * that box reached past the window's edge. A file name, a key or an address has no space to break at, so
19
+ * the text may also break inside a word.
20
+ */
21
+ const PHI_CONFIRM_CONTAINER_STYLE = {
22
+ maxWidth: `min(${PHI_LAYOUT.contentMaxNarrow}px, calc(100vw - 2 * ${PHI_SPACE.base}))`,
23
+ overflowWrap: "anywhere",
24
+ };
25
+ /*
26
+ * Ant Design's own pair stands apart, a gap between Cancel and the answer; this house draws a decision's
27
+ * two ends as one compact group, as a Dialog's footer does (`PhiDialogControl`). Ant Design has no slot
28
+ * for its buttons, so they are switched off and the group stands under the description instead.
29
+ */
30
+ const PHI_CONFIRM_HIDDEN_BUTTON_PROPS = { style: { display: "none" } };
31
+ const PHI_CONFIRM_BODY_STYLE = { marginBottom: "calc(-1 * var(--phi-margin-xs))" };
7
32
  export function PhiConfirmControl({ title, description, confirmLabel, cancelLabel, danger, disabled, placement, onConfirm, onCancel, trigger, children, }) {
8
- return (_jsx(Popconfirm, { title: title, description: description, okText: confirmLabel, cancelText: cancelLabel, okButtonProps: danger ? { danger: true } : undefined, disabled: disabled, placement: placement, onConfirm: onConfirm, onCancel: onCancel, children: trigger ? (_jsx(PhiButtonControl, { label: trigger.label, ariaLabel: trigger.ariaLabel, icon: trigger.icon, type: trigger.type, danger: trigger.danger, size: trigger.size, disabled: disabled,
33
+ const [open, setOpen] = useState(false);
34
+ const [confirming, setConfirming] = useState(false);
35
+ const confirmButtonRef = useRef(null);
36
+ const cancel = () => {
37
+ setOpen(false);
38
+ onCancel?.();
39
+ };
40
+ /*
41
+ * The answer may take a while: the button shows it working and takes no second press. A confirmation
42
+ * whose `onConfirm` throws stays open, because the question was not answered -- what to say about the
43
+ * failure is the caller's, as it was when Ant Design ran it.
44
+ */
45
+ const accept = () => {
46
+ if (confirming)
47
+ return;
48
+ setConfirming(true);
49
+ void (async () => {
50
+ try {
51
+ await onConfirm();
52
+ setOpen(false);
53
+ }
54
+ catch {
55
+ // Left open; the caller reports the failure.
56
+ }
57
+ finally {
58
+ setConfirming(false);
59
+ }
60
+ })();
61
+ };
62
+ return (_jsx(Popconfirm, { open: open, onOpenChange: (next) => {
63
+ if (!disabled)
64
+ setOpen(next);
65
+ },
66
+ // The answer has the focus once the question is up: Enter gives it, Escape takes the question back.
67
+ afterOpenChange: (next) => {
68
+ if (next)
69
+ confirmButtonRef.current?.focus();
70
+ }, title: title, description: (_jsxs(PhiFlexControl, { vertical: true, gap: "small",
71
+ // Ant Design keeps the gap under its message that its own buttons stood in; the group closes it.
72
+ style: PHI_CONFIRM_BODY_STYLE, onKeyDown: (event) => {
73
+ if (event.key !== "Escape")
74
+ return;
75
+ event.stopPropagation();
76
+ cancel();
77
+ }, children: [description, _jsx(PhiFlexControl, { justify: "end", children: _jsxs(PhiCompactGroupControl, { size: "small", children: [_jsx(PhiButtonControl, { label: cancelLabel ?? "Cancel", disabled: confirming, onClick: cancel }), _jsx(PhiButtonControl, { ref: confirmButtonRef, label: confirmLabel ?? "OK", type: "primary", danger: danger, loading: confirming, onClick: accept })] }) })] })), showCancel: false, okButtonProps: PHI_CONFIRM_HIDDEN_BUTTON_PROPS, styles: { container: PHI_CONFIRM_CONTAINER_STYLE }, disabled: disabled, placement: placement, children: trigger ? (_jsx(PhiButtonControl, { label: trigger.label, ariaLabel: trigger.ariaLabel, icon: trigger.icon, type: trigger.type, danger: trigger.danger, size: trigger.size, disabled: disabled,
9
78
  // The confirmation reacts to the press; this only keeps the button a live one.
10
79
  onClick: () => undefined })) : children }));
11
80
  }
@@ -2,6 +2,7 @@
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { useCallback, useRef, useState } from "react";
4
4
  import { PhiDialogControl } from "./phi-dialog-control";
5
+ const PHI_CONFIRM_DIALOG_CONTENT_STYLE = { overflowWrap: "anywhere" };
5
6
  /**
6
7
  * A confirmation that has nothing to hang on.
7
8
  *
@@ -74,6 +75,6 @@ export function usePhiConfirmDialog() {
74
75
  loading: confirming,
75
76
  onClick: accept,
76
77
  },
77
- ], onDismiss: cancel, children: request?.content ?? null }));
78
+ ], onDismiss: cancel, children: request?.content == null ? null : _jsx("div", { style: PHI_CONFIRM_DIALOG_CONTENT_STYLE, children: request.content }) }));
78
79
  return { confirm, confirmDialog };
79
80
  }
@@ -4,6 +4,6 @@ import { usePhiCalendarAdapterClient } from "../runtime/runtime-module-calendar-
4
4
  import { PhiLabeledControl, usePhiControlLabel } from "./phi-labeled-control";
5
5
  export function PhiDatePickerControl({ adapterKey, label, ...props }) {
6
6
  const adapter = usePhiCalendarAdapterClient(adapterKey);
7
- const { labelId, labelledBy } = usePhiControlLabel(label);
7
+ const { labelId, labelledBy } = usePhiControlLabel(label, props.ariaLabel);
8
8
  return (_jsx(PhiLabeledControl, { label: label, labelId: labelId, fill: true, children: adapter.renderDatePicker({ ...props, ariaLabelledBy: labelledBy }) }));
9
9
  }
@@ -2,6 +2,8 @@ import type { CSSProperties } from "react";
2
2
  import { type PhiControlSize, type PhiRenderableBlockSize } from "../../types";
3
3
  export type PhiDimensionControlProps = {
4
4
  value?: PhiRenderableBlockSize | null;
5
+ /** The accessible name of the pair; each field keeps its own, its placeholder. */
6
+ ariaLabel?: string;
5
7
  disabled?: boolean;
6
8
  readOnly?: boolean;
7
9
  onChange?: (nextValue: PhiRenderableBlockSize | null) => void;
@@ -11,4 +13,4 @@ export type PhiDimensionControlProps = {
11
13
  style?: CSSProperties;
12
14
  getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
13
15
  };
14
- export declare function PhiDimensionControl({ value, disabled, readOnly, onChange, widthPlaceholder, heightPlaceholder, size, style, getPopupContainer, }: PhiDimensionControlProps): import("react").JSX.Element;
16
+ export declare function PhiDimensionControl({ value, ariaLabel, disabled, readOnly, onChange, widthPlaceholder, heightPlaceholder, size, style, getPopupContainer, }: PhiDimensionControlProps): import("react").JSX.Element;
@@ -13,9 +13,9 @@ function resolveNextSize(currentSize, key, value) {
13
13
  }
14
14
  return nextSize;
15
15
  }
16
- export function PhiDimensionControl({ value, disabled = false, readOnly = false, onChange, widthPlaceholder = "Width", heightPlaceholder = "Height", size, style, getPopupContainer, }) {
16
+ export function PhiDimensionControl({ value, ariaLabel, disabled = false, readOnly = false, onChange, widthPlaceholder = "Width", heightPlaceholder = "Height", size, style, getPopupContainer, }) {
17
17
  const currentSize = value ?? null;
18
- return (_jsxs("div", { style: {
18
+ return (_jsxs("div", { role: "group", "aria-label": ariaLabel, style: {
19
19
  display: "grid",
20
20
  gridTemplateColumns: "repeat(2, minmax(0, 1fr))",
21
21
  /*