@korzun/design 0.0.4 → 0.0.6

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 (199) hide show
  1. package/AGENTS.md +3 -0
  2. package/dist/component/card/index.d.ts +13 -2
  3. package/dist/component/card/index.d.ts.map +1 -1
  4. package/dist/component/card/index.js +1 -0
  5. package/dist/component/card/index.js.map +1 -1
  6. package/dist/component/card/style.d.ts.map +1 -1
  7. package/dist/component/card/style.js +3 -1
  8. package/dist/component/card/style.js.map +1 -1
  9. package/dist/component/card-divider/index.d.ts +15 -0
  10. package/dist/component/card-divider/index.d.ts.map +1 -1
  11. package/dist/component/card-divider/index.js +4 -0
  12. package/dist/component/card-divider/index.js.map +1 -1
  13. package/dist/component/card-row/index.d.ts +5 -0
  14. package/dist/component/card-row/index.d.ts.map +1 -1
  15. package/dist/component/card-row/index.js +1 -0
  16. package/dist/component/card-row/index.js.map +1 -1
  17. package/dist/component/card-row/style.js +1 -1
  18. package/dist/component/card-row/style.js.map +1 -1
  19. package/dist/component/collapsible-section/index.d.ts +8 -3
  20. package/dist/component/collapsible-section/index.d.ts.map +1 -1
  21. package/dist/component/collapsible-section/index.js +1 -0
  22. package/dist/component/collapsible-section/index.js.map +1 -1
  23. package/dist/component/empty-state/index.d.ts +2 -2
  24. package/dist/component/empty-state/index.d.ts.map +1 -1
  25. package/dist/component/empty-state/index.js.map +1 -1
  26. package/dist/component/index.d.ts +10 -10
  27. package/dist/component/index.d.ts.map +1 -1
  28. package/dist/component/index.js.map +1 -1
  29. package/dist/component/meta-line/index.d.ts +1 -1
  30. package/dist/component/meta-line/index.d.ts.map +1 -1
  31. package/dist/component/meta-line/index.js.map +1 -1
  32. package/dist/component/metadata/index.d.ts +2 -0
  33. package/dist/component/metadata/index.d.ts.map +1 -1
  34. package/dist/component/metadata/index.js +1 -0
  35. package/dist/component/metadata/index.js.map +1 -1
  36. package/dist/component/metadata-list/index.d.ts +6 -2
  37. package/dist/component/metadata-list/index.d.ts.map +1 -1
  38. package/dist/component/metadata-list/index.js +1 -0
  39. package/dist/component/metadata-list/index.js.map +1 -1
  40. package/dist/component/nav-desktop/index.d.ts +6 -0
  41. package/dist/component/nav-desktop/index.d.ts.map +1 -1
  42. package/dist/component/nav-desktop/index.js +5 -2
  43. package/dist/component/nav-desktop/index.js.map +1 -1
  44. package/dist/component/nav-mobile/index.d.ts +11 -3
  45. package/dist/component/nav-mobile/index.d.ts.map +1 -1
  46. package/dist/component/nav-mobile/index.js +5 -0
  47. package/dist/component/nav-mobile/index.js.map +1 -1
  48. package/dist/component/nav-types.d.ts +4 -0
  49. package/dist/component/nav-types.d.ts.map +1 -1
  50. package/dist/component/nav-types.js.map +1 -1
  51. package/dist/component/page/index.d.ts +10 -2
  52. package/dist/component/page/index.d.ts.map +1 -1
  53. package/dist/component/page/index.js +1 -0
  54. package/dist/component/page/index.js.map +1 -1
  55. package/dist/component/progress-indicator/index.d.ts +4 -2
  56. package/dist/component/progress-indicator/index.d.ts.map +1 -1
  57. package/dist/component/progress-indicator/index.js +1 -0
  58. package/dist/component/progress-indicator/index.js.map +1 -1
  59. package/dist/component/tag/index.d.ts +6 -3
  60. package/dist/component/tag/index.d.ts.map +1 -1
  61. package/dist/component/tag/index.js +1 -0
  62. package/dist/component/tag/index.js.map +1 -1
  63. package/dist/component/theme-setting/index.d.ts +6 -0
  64. package/dist/component/theme-setting/index.d.ts.map +1 -1
  65. package/dist/component/theme-setting/index.js +4 -0
  66. package/dist/component/theme-setting/index.js.map +1 -1
  67. package/dist/component/top-fade/index.d.ts +7 -0
  68. package/dist/component/top-fade/index.d.ts.map +1 -1
  69. package/dist/component/top-fade/index.js +5 -2
  70. package/dist/component/top-fade/index.js.map +1 -1
  71. package/dist/control/action-menu-list/index.d.ts +7 -0
  72. package/dist/control/action-menu-list/index.d.ts.map +1 -1
  73. package/dist/control/action-menu-list/index.js.map +1 -1
  74. package/dist/control/back-button/index.d.ts +9 -2
  75. package/dist/control/back-button/index.d.ts.map +1 -1
  76. package/dist/control/back-button/index.js +4 -0
  77. package/dist/control/back-button/index.js.map +1 -1
  78. package/dist/control/button/index.d.ts +30 -1
  79. package/dist/control/button/index.d.ts.map +1 -1
  80. package/dist/control/button/index.js +4 -0
  81. package/dist/control/button/index.js.map +1 -1
  82. package/dist/control/chips-input/index.d.ts +20 -0
  83. package/dist/control/chips-input/index.d.ts.map +1 -1
  84. package/dist/control/chips-input/index.js +4 -0
  85. package/dist/control/chips-input/index.js.map +1 -1
  86. package/dist/control/confirm-modal/index.d.ts +15 -2
  87. package/dist/control/confirm-modal/index.d.ts.map +1 -1
  88. package/dist/control/confirm-modal/index.js +4 -0
  89. package/dist/control/confirm-modal/index.js.map +1 -1
  90. package/dist/control/date-time-input/index.d.ts +4 -0
  91. package/dist/control/date-time-input/index.d.ts.map +1 -1
  92. package/dist/control/date-time-input/index.js.map +1 -1
  93. package/dist/control/field-list/index.d.ts +20 -2
  94. package/dist/control/field-list/index.d.ts.map +1 -1
  95. package/dist/control/field-list/index.js +4 -0
  96. package/dist/control/field-list/index.js.map +1 -1
  97. package/dist/control/index.d.ts +16 -21
  98. package/dist/control/index.d.ts.map +1 -1
  99. package/dist/control/index.js +5 -5
  100. package/dist/control/index.js.map +1 -1
  101. package/dist/control/number-input/index.d.ts +12 -0
  102. package/dist/control/number-input/index.d.ts.map +1 -1
  103. package/dist/control/number-input/index.js +4 -0
  104. package/dist/control/number-input/index.js.map +1 -1
  105. package/dist/control/page-actions-bar/index.d.ts +11 -3
  106. package/dist/control/page-actions-bar/index.d.ts.map +1 -1
  107. package/dist/control/page-actions-bar/index.js +5 -1
  108. package/dist/control/page-actions-bar/index.js.map +1 -1
  109. package/dist/control/page-actions-menu/index.d.ts +6 -1
  110. package/dist/control/page-actions-menu/index.d.ts.map +1 -1
  111. package/dist/control/page-actions-menu/index.js +4 -0
  112. package/dist/control/page-actions-menu/index.js.map +1 -1
  113. package/dist/control/page-footer-actions/index.d.ts +16 -2
  114. package/dist/control/page-footer-actions/index.d.ts.map +1 -1
  115. package/dist/control/page-footer-actions/index.js +4 -0
  116. package/dist/control/page-footer-actions/index.js.map +1 -1
  117. package/dist/control/popover/index.d.ts +6 -3
  118. package/dist/control/popover/index.d.ts.map +1 -1
  119. package/dist/control/popover/index.js +2 -0
  120. package/dist/control/popover/index.js.map +1 -1
  121. package/dist/control/segmented-control/index.d.ts +10 -3
  122. package/dist/control/segmented-control/index.d.ts.map +1 -1
  123. package/dist/control/segmented-control/index.js.map +1 -1
  124. package/dist/control/select/index.d.ts +17 -0
  125. package/dist/control/select/index.d.ts.map +1 -1
  126. package/dist/control/select/index.js +4 -0
  127. package/dist/control/select/index.js.map +1 -1
  128. package/dist/control/switch/index.d.ts +16 -2
  129. package/dist/control/switch/index.d.ts.map +1 -1
  130. package/dist/control/switch/index.js +4 -0
  131. package/dist/control/switch/index.js.map +1 -1
  132. package/dist/control/switch/style.d.ts.map +1 -1
  133. package/dist/control/switch/style.js +1 -3
  134. package/dist/control/switch/style.js.map +1 -1
  135. package/dist/control/text-area/index.d.ts +15 -0
  136. package/dist/control/text-area/index.d.ts.map +1 -1
  137. package/dist/control/text-area/index.js +4 -0
  138. package/dist/control/text-area/index.js.map +1 -1
  139. package/dist/control/text-input/index.d.ts +23 -1
  140. package/dist/control/text-input/index.d.ts.map +1 -1
  141. package/dist/control/text-input/index.js +4 -0
  142. package/dist/control/text-input/index.js.map +1 -1
  143. package/dist/control/use-modal-dialog/index.d.ts +7 -1
  144. package/dist/control/use-modal-dialog/index.d.ts.map +1 -1
  145. package/dist/control/use-modal-dialog/index.js +5 -0
  146. package/dist/control/use-modal-dialog/index.js.map +1 -1
  147. package/dist/theme/theme.d.ts +2 -0
  148. package/dist/theme/theme.d.ts.map +1 -1
  149. package/dist/theme/theme.js +5 -0
  150. package/dist/theme/theme.js.map +1 -1
  151. package/docs/component/card-row.md +11 -12
  152. package/docs/component/card.md +4 -5
  153. package/docs/control/confirm-modal.md +1 -2
  154. package/docs/control/segmented-control.md +2 -2
  155. package/docs/corners.md +4 -4
  156. package/docs/philosophy.md +1 -1
  157. package/docs/theme.md +1 -0
  158. package/docs/tokens.md +1 -0
  159. package/package.json +1 -1
  160. package/src/component/card/index.tsx +14 -2
  161. package/src/component/card/style.ts +3 -1
  162. package/src/component/card-divider/index.tsx +15 -6
  163. package/src/component/card-row/index.tsx +6 -0
  164. package/src/component/card-row/style.ts +1 -1
  165. package/src/component/collapsible-section/index.tsx +8 -2
  166. package/src/component/empty-state/index.tsx +2 -2
  167. package/src/component/index.ts +10 -10
  168. package/src/component/meta-line/index.tsx +1 -1
  169. package/src/component/metadata/index.tsx +6 -1
  170. package/src/component/metadata-list/index.tsx +13 -2
  171. package/src/component/nav-desktop/index.tsx +6 -2
  172. package/src/component/nav-mobile/index.tsx +11 -3
  173. package/src/component/nav-types.ts +4 -0
  174. package/src/component/page/index.tsx +11 -1
  175. package/src/component/progress-indicator/index.tsx +4 -1
  176. package/src/component/tag/index.tsx +6 -3
  177. package/src/component/theme-setting/index.tsx +7 -0
  178. package/src/component/top-fade/index.tsx +8 -2
  179. package/src/control/action-menu-list/index.tsx +7 -0
  180. package/src/control/back-button/index.tsx +9 -1
  181. package/src/control/button/index.tsx +39 -5
  182. package/src/control/chips-input/index.tsx +20 -3
  183. package/src/control/confirm-modal/index.tsx +15 -1
  184. package/src/control/date-time-input/index.tsx +4 -0
  185. package/src/control/field-list/index.tsx +20 -1
  186. package/src/control/index.ts +39 -22
  187. package/src/control/number-input/index.tsx +12 -0
  188. package/src/control/page-actions-bar/index.tsx +16 -2
  189. package/src/control/page-actions-menu/index.tsx +6 -1
  190. package/src/control/page-footer-actions/index.tsx +16 -1
  191. package/src/control/popover/index.tsx +6 -2
  192. package/src/control/segmented-control/index.tsx +10 -3
  193. package/src/control/select/index.tsx +17 -1
  194. package/src/control/switch/index.tsx +17 -1
  195. package/src/control/switch/style.ts +1 -3
  196. package/src/control/text-area/index.tsx +15 -0
  197. package/src/control/text-input/index.tsx +25 -0
  198. package/src/control/use-modal-dialog/index.ts +11 -2
  199. package/src/theme/theme.ts +7 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/number-input/index.tsx"],"names":[],"mappings":"AAMA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAClD,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;IACzC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B,CAAC;AAEF,eAAO,MAAM,WAAW,oFASrB,gBAAgB,gCAgDlB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/number-input/index.tsx"],"names":[],"mappings":"AAMA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,+FAA+F;IAC/F,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,+EAA+E;IAC/E,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC9C,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,mGAAmG;IACnG,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAClD,+EAA+E;IAC/E,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/D,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oGAAoG;IACpG,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;IACzC,0EAA0E;IAC1E,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,oFASrB,gBAAgB,gCAgDlB,CAAC"}
@@ -3,6 +3,10 @@ import cx from 'classnames';
3
3
  import { useCallback, useState } from 'react';
4
4
  import { isNumeric } from '../../utils.js';
5
5
  import { useStyle } from './style.js';
6
+ /**
7
+ * Text field that reports a number: a plain `<input>` (no `type="number"`)
8
+ * that calls `onChange` with the parsed value while the text validates.
9
+ */
6
10
  export const NumberInput = ({ label, layout = 'horizontal', name, onChange = () => { }, onValidChange = () => { }, placeholder, validate = (newValue) => newValue === '' || isNumeric(newValue), value, }) => {
7
11
  const style = useStyle();
8
12
  const [isValid, setIsValid] = useState(true);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/control/number-input/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAatC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAC1B,KAAK,EACL,MAAM,GAAG,YAAY,EACrB,IAAI,EACJ,QAAQ,GAAG,GAAG,EAAE,GAAE,CAAC,EACnB,aAAa,GAAG,GAAG,EAAE,GAAE,CAAC,EACxB,WAAW,EACX,QAAQ,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,KAAK,EAAE,IAAI,SAAS,CAAC,QAAQ,CAAC,EAC/D,KAAK,GACY,EAAE,EAAE;IACrB,MAAM,KAAK,GAAG,QAAQ,E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K,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACpE,CAAC;IAED,OAAO,CACL,eAAK,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,aAC1C,KAAK,IAAI,CACR,gBAAO,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,YAAG,KAAK,GAAS,CACtF,EACD,gBACE,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,EAC7D,QAAQ,EAAE,iBAAiB,EAC3B,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,GACvD,IACE,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import cx from 'classnames';\nimport { useCallback, useState } from 'react';\n\nimport { isNumeric } from '../../utils.js';\nimport { useStyle } from './style.js';\n\nexport type NumberInputProps = {\n label: string | undefined;\n layout?: 'horizontal' | 'vertical' | 'inline';\n name: string;\n onChange?: (newValue: number | undefined) => void;\n onValidChange?: (fieldName: string, newValid: boolean) => void;\n placeholder?: string;\n validate?: (newValue: string) => boolean;\n value: number | undefined;\n};\n\nexport const NumberInput = ({\n label,\n layout = 'horizontal',\n name,\n onChange = () => {},\n onValidChange = () => {},\n placeholder,\n validate = (newValue) => newValue === '' || isNumeric(newValue),\n value,\n}: NumberInputProps) => {\n const style = useStyle();\n\n const [isValid, setIsValid] = useState<boolean>(true);\n const [internalValue, setInternalValue] = useState<string | undefined>(\n value !== undefined ? String(value) : undefined\n );\n const [prevValue, setPrevValue] = useState<number | undefined>(value);\n\n const handleValueChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = event.target.value;\n setInternalValue(newValue);\n if (validate(newValue)) {\n if (isValid === false) {\n setIsValid(true);\n onValidChange(name, true);\n }\n onChange(newValue === '' ? undefined : parseFloat(newValue));\n } else {\n if (isValid === true) {\n setIsValid(false);\n onValidChange(name, false);\n }\n }\n },\n [isValid, name, onChange, onValidChange, validate]\n );\n\n if (value !== prevValue) {\n setPrevValue(value);\n setInternalValue(value !== undefined ? String(value) : undefined);\n }\n\n return (\n <div className={cx(style.root, style[layout])}>\n {label && (\n <label className={cx(style.label, { [`${style.danger}`]: !isValid })}>{label}</label>\n )}\n <input\n name={name}\n className={cx(style.input, { [`${style.danger}`]: !isValid })}\n onChange={handleValueChange}\n placeholder={placeholder}\n value={internalValue === undefined ? '' : internalValue}\n />\n </div>\n );\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/control/number-input/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAqBtC;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAC1B,KAAK,EACL,MAAM,GAAG,YAAY,EACrB,IAAI,EACJ,QAAQ,GAAG,GAAG,EAAE,GAAE,CAAC,EACnB,aAAa,GAAG,GAAG,EAAE,GAAE,CAAC,EACxB,WAAW,EACX,QAAQ,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,KAAK,EAAE,IAAI,SAAS,CAAC,QAAQ,CAAC,EAC/D,KAAK,GACY,EAAE,EAAE;IACrB,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IAEzB,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ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,CACL,eAAK,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,aAC1C,KAAK,IAAI,CACR,gBAAO,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,YAAG,KAAK,GAAS,CACtF,EACD,gBACE,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,EAC7D,QAAQ,EAAE,iBAAiB,EAC3B,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,GACvD,IACE,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import cx from 'classnames';\nimport { useCallback, useState } from 'react';\n\nimport { isNumeric } from '../../utils.js';\nimport { useStyle } from './style.js';\n\nexport type NumberInputProps = {\n /** Required key: pass `label={undefined}` for none. Not linked to the input (no `htmlFor`). */\n label: string | undefined;\n /** Default `'horizontal'`; `horizontal`/`vertical` paint a card-header row. */\n layout?: 'horizontal' | 'vertical' | 'inline';\n /** The input's `name` and the key passed to `onValidChange`. */\n name: string;\n /** Receives `parseFloat(text)`, or `undefined` when emptied; not called while `validate` fails. */\n onChange?: (newValue: number | undefined) => void;\n /** Called with `name` and the new validity; fires only when validity flips. */\n onValidChange?: (fieldName: string, newValid: boolean) => void;\n /** Placeholder text for the input. */\n placeholder?: string;\n /** Receives the raw text. Replacing it drops the default empty-or-numeric check, so include one. */\n validate?: (newValue: string) => boolean;\n /** Current number. Re-syncs into the field only when the prop changes. */\n value: number | undefined;\n};\n\n/**\n * Text field that reports a number: a plain `<input>` (no `type=\"number\"`)\n * that calls `onChange` with the parsed value while the text validates.\n */\nexport const NumberInput = ({\n label,\n layout = 'horizontal',\n name,\n onChange = () => {},\n onValidChange = () => {},\n placeholder,\n validate = (newValue) => newValue === '' || isNumeric(newValue),\n value,\n}: NumberInputProps) => {\n const style = useStyle();\n\n const [isValid, setIsValid] = useState<boolean>(true);\n const [internalValue, setInternalValue] = useState<string | undefined>(\n value !== undefined ? String(value) : undefined\n );\n const [prevValue, setPrevValue] = useState<number | undefined>(value);\n\n const handleValueChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = event.target.value;\n setInternalValue(newValue);\n if (validate(newValue)) {\n if (isValid === false) {\n setIsValid(true);\n onValidChange(name, true);\n }\n onChange(newValue === '' ? undefined : parseFloat(newValue));\n } else {\n if (isValid === true) {\n setIsValid(false);\n onValidChange(name, false);\n }\n }\n },\n [isValid, name, onChange, onValidChange, validate]\n );\n\n if (value !== prevValue) {\n setPrevValue(value);\n setInternalValue(value !== undefined ? String(value) : undefined);\n }\n\n return (\n <div className={cx(style.root, style[layout])}>\n {label && (\n <label className={cx(style.label, { [`${style.danger}`]: !isValid })}>{label}</label>\n )}\n <input\n name={name}\n className={cx(style.input, { [`${style.danger}`]: !isValid })}\n onChange={handleValueChange}\n placeholder={placeholder}\n value={internalValue === undefined ? '' : internalValue}\n />\n </div>\n );\n};\n"]}
@@ -1,11 +1,19 @@
1
- import { type PageActionItem } from '../action-menu-list/index.js';
2
- interface PageActionsBarProps {
1
+ import { type PageActionIntentProps, type PageActionItem } from '../action-menu-list/index.js';
2
+ export type { PageActionIntentProps, PageActionItem };
3
+ export interface PageActionsBarProps {
4
+ /**
5
+ * `primary` items render as inline Buttons (`align: 'leading'` on the left),
6
+ * the rest in the overflow menu. Labels must be unique.
7
+ */
3
8
  items: PageActionItem[];
4
9
  /** Visible label (and accessible name) for the overflow trigger. Defaults to
5
10
  * "More…" — pass e.g. "Actions" on a page whose whole action set lives in the
6
11
  * menu rather than spilling over from inline buttons. */
7
12
  actionsLabel?: string;
8
13
  }
14
+ /**
15
+ * Desktop page-header action row: primary items as inline Buttons, the rest
16
+ * behind a "More…" overflow menu. Usually rendered by `Page headerActions`.
17
+ */
9
18
  export declare function PageActionsBar({ items, actionsLabel }: PageActionsBarProps): import("react").JSX.Element;
10
- export {};
11
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/page-actions-bar/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAKnF,UAAU,mBAAmB;IAC3B,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB;;6DAEyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,mBAAmB,+BAoD1E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/page-actions-bar/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AAKtC,YAAY,EAAE,qBAAqB,EAAE,cAAc,EAAE,CAAC;AAEtD,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB;;6DAEyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,mBAAmB,+BAoD1E"}
@@ -1,9 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useRef, useState } from 'react';
3
- import { ActionMenuList } from '../action-menu-list/index.js';
3
+ import { ActionMenuList, } from '../action-menu-list/index.js';
4
4
  import { useDismiss } from '../action-menu-list/use-dismiss.js';
5
5
  import { Button } from '../button/index.js';
6
6
  import { useStyle } from './style.js';
7
+ /**
8
+ * Desktop page-header action row: primary items as inline Buttons, the rest
9
+ * behind a "More…" overflow menu. Usually rendered by `Page headerActions`.
10
+ */
7
11
  export function PageActionsBar({ items, actionsLabel }) {
8
12
  const styles = useStyle();
9
13
  const [open, setOpen] = useState(false);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/control/page-actions-bar/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAuB,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAUtC,MAAM,UAAU,cAAc,CAAC,EAAE,KAAK,EAAE,YAAY,EAAuB;IACzE,MAAM,MAAM,GAAG,QAAQ,EAAE,CAAC;IAC1B,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IACpD,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAEjC,MAAM,YAAY,GAAG,YAAY,IAAI,OAAO,CAAC;IAC7C,MAAM,gBAAgB,GAAG,YAAY,IAAI,cAAc,CAAC;IAExD,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrD,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,E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,EACR,IAAI,IAAI,CACP,cAAK,SAAS,EAAE,MAAM,CAAC,aAAa,YAClC,KAAC,cAAc,IAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAC,OAAO,EAAC,QAAQ,EAAE,YAAY,GAAI,GACvE,CACP,IACG,CACP,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useRef, useState } from 'react';\n\nimport { ActionMenuList, type PageActionItem } from '../action-menu-list/index.js';\nimport { useDismiss } from '../action-menu-list/use-dismiss.js';\nimport { Button } from '../button/index.js';\nimport { useStyle } from './style.js';\n\ninterface PageActionsBarProps {\n items: PageActionItem[];\n /** Visible label (and accessible name) for the overflow trigger. Defaults to\n * \"More…\" — pass e.g. \"Actions\" on a page whose whole action set lives in the\n * menu rather than spilling over from inline buttons. */\n actionsLabel?: string;\n}\n\nexport function PageActionsBar({ items, actionsLabel }: PageActionsBarProps) {\n const styles = useStyle();\n const [open, setOpen] = useState(false);\n const moreRef = useRef<HTMLDivElement>(null);\n const close = useCallback(() => setOpen(false), []);\n useDismiss(open, close, moreRef);\n\n const triggerLabel = actionsLabel ?? 'More…';\n const triggerAriaLabel = actionsLabel ?? 'More actions';\n\n const primary = items.filter((item) => item.primary);\n const leading = primary.filter((item) => item.align === 'leading');\n const trailing = primary.filter((item) => item.align !== 'leading');\n const overflow = items.filter((item) => !item.primary);\n\n const handleSelect = useCallback((item: PageActionItem) => {\n setOpen(false);\n item.onClick();\n }, []);\n\n const renderButton = (item: PageActionItem) => (\n <Button key={item.label} onClick={item.onClick} disabled={item.disabled} danger={item.danger}>\n {item.label}\n </Button>\n );\n\n return (\n <div className={styles.root}>\n {leading.map(renderButton)}\n <div className={styles.spacer} />\n {trailing.map(renderButton)}\n {overflow.length > 0 && (\n <div className={styles.more} ref={moreRef}>\n <button\n type=\"button\"\n className={styles.moreTrigger}\n aria-label={triggerAriaLabel}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n onClick={() => setOpen((value) => !value)}\n >\n {triggerLabel}\n </button>\n {open && (\n <div className={styles.popoverAnchor}>\n <ActionMenuList items={overflow} surface=\"solid\" onSelect={handleSelect} />\n </div>\n )}\n </div>\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/control/page-actions-bar/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EACL,cAAc,GAGf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAgBtC;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,EAAE,KAAK,EAAE,YAAY,EAAuB;IACzE,MAAM,MAAM,GAAG,QAAQ,EAAE,CAAC;IAC1B,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IACpD,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAEjC,MAAM,YAAY,GAAG,YAAY,IAAI,OAAO,CAAC;IAC7C,MAAM,gBAAgB,GAAG,YAAY,IAAI,cAAc,CAAC;IAExD,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrD,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IACnE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,KAAC,cAAc,IAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAC,OAAO,EAAC,QAAQ,EAAE,YAAY,GAAI,GACvE,CACP,IACG,CACP,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useRef, useState } from 'react';\n\nimport {\n ActionMenuList,\n type PageActionIntentProps,\n type PageActionItem,\n} from '../action-menu-list/index.js';\nimport { useDismiss } from '../action-menu-list/use-dismiss.js';\nimport { Button } from '../button/index.js';\nimport { useStyle } from './style.js';\n\nexport type { PageActionIntentProps, PageActionItem };\n\nexport interface PageActionsBarProps {\n /**\n * `primary` items render as inline Buttons (`align: 'leading'` on the left),\n * the rest in the overflow menu. Labels must be unique.\n */\n items: PageActionItem[];\n /** Visible label (and accessible name) for the overflow trigger. Defaults to\n * \"More…\" — pass e.g. \"Actions\" on a page whose whole action set lives in the\n * menu rather than spilling over from inline buttons. */\n actionsLabel?: string;\n}\n\n/**\n * Desktop page-header action row: primary items as inline Buttons, the rest\n * behind a \"More…\" overflow menu. Usually rendered by `Page headerActions`.\n */\nexport function PageActionsBar({ items, actionsLabel }: PageActionsBarProps) {\n const styles = useStyle();\n const [open, setOpen] = useState(false);\n const moreRef = useRef<HTMLDivElement>(null);\n const close = useCallback(() => setOpen(false), []);\n useDismiss(open, close, moreRef);\n\n const triggerLabel = actionsLabel ?? 'More…';\n const triggerAriaLabel = actionsLabel ?? 'More actions';\n\n const primary = items.filter((item) => item.primary);\n const leading = primary.filter((item) => item.align === 'leading');\n const trailing = primary.filter((item) => item.align !== 'leading');\n const overflow = items.filter((item) => !item.primary);\n\n const handleSelect = useCallback((item: PageActionItem) => {\n setOpen(false);\n item.onClick();\n }, []);\n\n const renderButton = (item: PageActionItem) => (\n <Button key={item.label} onClick={item.onClick} disabled={item.disabled} danger={item.danger}>\n {item.label}\n </Button>\n );\n\n return (\n <div className={styles.root}>\n {leading.map(renderButton)}\n <div className={styles.spacer} />\n {trailing.map(renderButton)}\n {overflow.length > 0 && (\n <div className={styles.more} ref={moreRef}>\n <button\n type=\"button\"\n className={styles.moreTrigger}\n aria-label={triggerAriaLabel}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n onClick={() => setOpen((value) => !value)}\n >\n {triggerLabel}\n </button>\n {open && (\n <div className={styles.popoverAnchor}>\n <ActionMenuList items={overflow} surface=\"solid\" onSelect={handleSelect} />\n </div>\n )}\n </div>\n )}\n </div>\n );\n}\n"]}
@@ -1,7 +1,12 @@
1
1
  import { type PageActionIntentProps, type PageActionItem } from '../action-menu-list/index.js';
2
2
  export type { PageActionIntentProps, PageActionItem };
3
- interface PageActionsMenuProps {
3
+ export interface PageActionsMenuProps {
4
+ /** All items appear in the menu, in order; `primary` and `align` are ignored here. Labels must be unique. */
4
5
  items: PageActionItem[];
5
6
  }
7
+ /**
8
+ * Mobile page-header "More actions" button that opens a glass menu of
9
+ * `items`. Usually rendered by `Page headerActions`.
10
+ */
6
11
  export declare function PageActionsMenu({ items }: PageActionsMenuProps): import("react").JSX.Element;
7
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/page-actions-menu/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AAItC,YAAY,EAAE,qBAAqB,EAAE,cAAc,EAAE,CAAC;AAEtD,UAAU,oBAAoB;IAC5B,KAAK,EAAE,cAAc,EAAE,CAAC;CACzB;AAED,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,EAAE,oBAAoB,+BA+B9D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/page-actions-menu/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AAItC,YAAY,EAAE,qBAAqB,EAAE,cAAc,EAAE,CAAC;AAEtD,MAAM,WAAW,oBAAoB;IACnC,6GAA6G;IAC7G,KAAK,EAAE,cAAc,EAAE,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,EAAE,oBAAoB,+BA+B9D"}
@@ -4,6 +4,10 @@ import { MoreIcon } from '../../icon/index.js';
4
4
  import { ActionMenuList, } from '../action-menu-list/index.js';
5
5
  import { useDismiss } from '../action-menu-list/use-dismiss.js';
6
6
  import { useStyle } from './style.js';
7
+ /**
8
+ * Mobile page-header "More actions" button that opens a glass menu of
9
+ * `items`. Usually rendered by `Page headerActions`.
10
+ */
7
11
  export function PageActionsMenu({ items }) {
8
12
  const styles = useStyle();
9
13
  const [open, setOpen] = useState(false);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/control/page-actions-menu/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EACL,cAAc,GAGf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAQtC,MAAM,UAAU,eAAe,CAAC,EAAE,KAAK,EAAwB;IAC7D,MAAM,MAAM,GAAG,QAAQ,EAAE,CAAC;IAC1B,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAClD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IACpD,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;IAEtC,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,IAAoB,EAAE,EAAE;QACxD,OAAO,CAAC,KAAK,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,eAAK,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,YAAY,aAC5C,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,MAAM,CAAC,OAAO,gBACd,cAAc,mBACX,MAAM,mBACL,IAAI,EACnB,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,YAEzC,KAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,iBAAc,MAAM,GAAG,GAC/C,EACR,IAAI,IAAI,CACP,cAAK,SAAS,EAAE,MAAM,CAAC,aAAa,YAClC,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAC,OAAO,EAAC,QAAQ,EAAE,YAAY,GAAI,GACpE,CACP,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useRef, useState } from 'react';\n\nimport { MoreIcon } from '../../icon/index.js';\nimport {\n ActionMenuList,\n type PageActionIntentProps,\n type PageActionItem,\n} from '../action-menu-list/index.js';\nimport { useDismiss } from '../action-menu-list/use-dismiss.js';\nimport { useStyle } from './style.js';\n\nexport type { PageActionIntentProps, PageActionItem };\n\ninterface PageActionsMenuProps {\n items: PageActionItem[];\n}\n\nexport function PageActionsMenu({ items }: PageActionsMenuProps) {\n const styles = useStyle();\n const [open, setOpen] = useState(false);\n const containerRef = useRef<HTMLDivElement>(null);\n const close = useCallback(() => setOpen(false), []);\n useDismiss(open, close, containerRef);\n\n const handleSelect = useCallback((item: PageActionItem) => {\n setOpen(false);\n item.onClick();\n }, []);\n\n return (\n <div className={styles.root} ref={containerRef}>\n <button\n type=\"button\"\n className={styles.trigger}\n aria-label=\"More actions\"\n aria-haspopup=\"menu\"\n aria-expanded={open}\n onClick={() => setOpen((value) => !value)}\n >\n <MoreIcon width={20} height={20} aria-hidden=\"true\" />\n </button>\n {open && (\n <div className={styles.popoverAnchor}>\n <ActionMenuList items={items} surface=\"glass\" onSelect={handleSelect} />\n </div>\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/control/page-actions-menu/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EACL,cAAc,GAGf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAStC;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,EAAE,KAAK,EAAwB;IAC7D,MAAM,MAAM,GAAG,QAAQ,EAAE,CAAC;IAC1B,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAClD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IACpD,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;IAEtC,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,IAAoB,EAAE,EAAE;QACxD,OAAO,CAAC,KAAK,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,eAAK,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,YAAY,aAC5C,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,MAAM,CAAC,OAAO,gBACd,cAAc,mBACX,MAAM,mBACL,IAAI,EACnB,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,YAEzC,KAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,iBAAc,MAAM,GAAG,GAC/C,EACR,IAAI,IAAI,CACP,cAAK,SAAS,EAAE,MAAM,CAAC,aAAa,YAClC,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAC,OAAO,EAAC,QAAQ,EAAE,YAAY,GAAI,GACpE,CACP,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useRef, useState } from 'react';\n\nimport { MoreIcon } from '../../icon/index.js';\nimport {\n ActionMenuList,\n type PageActionIntentProps,\n type PageActionItem,\n} from '../action-menu-list/index.js';\nimport { useDismiss } from '../action-menu-list/use-dismiss.js';\nimport { useStyle } from './style.js';\n\nexport type { PageActionIntentProps, PageActionItem };\n\nexport interface PageActionsMenuProps {\n /** All items appear in the menu, in order; `primary` and `align` are ignored here. Labels must be unique. */\n items: PageActionItem[];\n}\n\n/**\n * Mobile page-header \"More actions\" button that opens a glass menu of\n * `items`. Usually rendered by `Page headerActions`.\n */\nexport function PageActionsMenu({ items }: PageActionsMenuProps) {\n const styles = useStyle();\n const [open, setOpen] = useState(false);\n const containerRef = useRef<HTMLDivElement>(null);\n const close = useCallback(() => setOpen(false), []);\n useDismiss(open, close, containerRef);\n\n const handleSelect = useCallback((item: PageActionItem) => {\n setOpen(false);\n item.onClick();\n }, []);\n\n return (\n <div className={styles.root} ref={containerRef}>\n <button\n type=\"button\"\n className={styles.trigger}\n aria-label=\"More actions\"\n aria-haspopup=\"menu\"\n aria-expanded={open}\n onClick={() => setOpen((value) => !value)}\n >\n <MoreIcon width={20} height={20} aria-hidden=\"true\" />\n </button>\n {open && (\n <div className={styles.popoverAnchor}>\n <ActionMenuList items={items} surface=\"glass\" onSelect={handleSelect} />\n </div>\n )}\n </div>\n );\n}\n"]}
@@ -1,17 +1,31 @@
1
+ /** One button in a `PageFooterActions` row. */
1
2
  export interface FooterAction {
3
+ /** Button text; may change between renders (`Save` → `Saving…`) without remounting. */
2
4
  label: string;
5
+ /** Required even for a `submit` item, and ignored there (pass `() => {}`). Receives no event. */
3
6
  onClick: () => void;
7
+ /** Greys the button out and blocks clicks. */
4
8
  disabled?: boolean;
9
+ /** Spinner; blocks clicks. */
5
10
  loading?: boolean;
11
+ /** Red treatment. */
6
12
  danger?: boolean;
13
+ /** Renders `type="primary"`; otherwise `type="default"`. */
7
14
  emphasis?: boolean;
15
+ /** Side of the row; default `'trailing'`. */
8
16
  align?: 'leading' | 'trailing';
17
+ /** Render a native submit button (`onClick` is then ignored). */
9
18
  submit?: boolean;
19
+ /** Id of the `<form>` to submit; needed because the row sits outside the form. */
10
20
  form?: string;
11
21
  }
12
- interface PageFooterActionsProps {
22
+ export interface PageFooterActionsProps {
23
+ /** Rendered in order within each side (leading, then trailing). */
13
24
  items: FooterAction[];
14
25
  }
26
+ /**
27
+ * Row of page-level buttons below the cards, split into leading and trailing
28
+ * sides. Sits on the page background; don't put it inside a `Card`.
29
+ */
15
30
  export declare function PageFooterActions({ items }: PageFooterActionsProps): import("react").JSX.Element;
16
- export {};
17
31
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/page-footer-actions/index.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,sBAAsB;IAC9B,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,KAAK,EAAE,EAAE,sBAAsB,+BA8BlE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/page-footer-actions/index.tsx"],"names":[],"mappings":"AAGA,+CAA+C;AAC/C,MAAM,WAAW,YAAY;IAC3B,uFAAuF;IACvF,KAAK,EAAE,MAAM,CAAC;IACd,iGAAiG;IACjG,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qBAAqB;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IAC/B,iEAAiE;IACjE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kFAAkF;IAClF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACrC,mEAAmE;IACnE,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,KAAK,EAAE,EAAE,sBAAsB,+BA8BlE"}
@@ -1,6 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Button } from '../button/index.js';
3
3
  import { useStyle } from './style.js';
4
+ /**
5
+ * Row of page-level buttons below the cards, split into leading and trailing
6
+ * sides. Sits on the page background; don't put it inside a `Card`.
7
+ */
4
8
  export function PageFooterActions({ items }) {
5
9
  const styles = useStyle();
6
10
  const leading = items.filter((item) => item.align === 'leading');
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/control/page-footer-actions/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAkBtC,MAAM,UAAU,iBAAiB,CAAC,EAAE,KAAK,EAA0B;IACjE,MAAM,MAAM,GAAG,QAAQ,EAAE,CAAC;IAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IAElE,0EAA0E;IAC1E,8EAA8E;IAC9E,iDAAiD;IACjD,MAAM,YAAY,GAAG,CAAC,IAAkB,EAAE,GAAW,EAAE,EAAE,CAAC,CACxD,KAAC,MAAM,IAEL,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAC3C,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,IAAI,EAAE,IAAI,CAAC,IAAI,YAEd,IAAI,CAAC,KAAK,IATN,GAAG,CAUD,CACV,CAAC;IAEF,OAAO,CACL,eAAK,SAAS,EAAE,MAAM,CAAC,IAAI,aACxB,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC,EAC7D,cAAK,SAAS,EAAE,MAAM,CAAC,MAAM,GAAI,EAChC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC,IAC3D,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { Button } from '../button/index.js';\nimport { useStyle } from './style.js';\n\nexport interface FooterAction {\n label: string;\n onClick: () => void;\n disabled?: boolean;\n loading?: boolean;\n danger?: boolean;\n emphasis?: boolean;\n align?: 'leading' | 'trailing';\n submit?: boolean;\n form?: string;\n}\n\ninterface PageFooterActionsProps {\n items: FooterAction[];\n}\n\nexport function PageFooterActions({ items }: PageFooterActionsProps) {\n const styles = useStyle();\n const leading = items.filter((item) => item.align === 'leading');\n const trailing = items.filter((item) => item.align !== 'leading');\n\n // Key by position within the row, not by label: a label can change across\n // renders (e.g. Save → Saving…) or repeat, and keying on it would remount the\n // button — dropping focus and its loading state.\n const renderButton = (item: FooterAction, key: string) => (\n <Button\n key={key}\n onClick={item.onClick}\n disabled={item.disabled}\n loading={item.loading}\n danger={item.danger}\n type={item.emphasis ? 'primary' : 'default'}\n submit={item.submit}\n form={item.form}\n >\n {item.label}\n </Button>\n );\n\n return (\n <div className={styles.root}>\n {leading.map((item, i) => renderButton(item, `leading-${i}`))}\n <div className={styles.spacer} />\n {trailing.map((item, i) => renderButton(item, `trailing-${i}`))}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/control/page-footer-actions/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA6BtC;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAE,KAAK,EAA0B;IACjE,MAAM,MAAM,GAAG,QAAQ,EAAE,CAAC;IAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IAElE,0EAA0E;IAC1E,8EAA8E;IAC9E,iDAAiD;IACjD,MAAM,YAAY,GAAG,CAAC,IAAkB,EAAE,GAAW,EAAE,EAAE,CAAC,CACxD,KAAC,MAAM,IAEL,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAC3C,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,IAAI,EAAE,IAAI,CAAC,IAAI,YAEd,IAAI,CAAC,KAAK,IATN,GAAG,CAUD,CACV,CAAC;IAEF,OAAO,CACL,eAAK,SAAS,EAAE,MAAM,CAAC,IAAI,aACxB,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC,EAC7D,cAAK,SAAS,EAAE,MAAM,CAAC,MAAM,GAAI,EAChC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC,IAC3D,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { Button } from '../button/index.js';\nimport { useStyle } from './style.js';\n\n/** One button in a `PageFooterActions` row. */\nexport interface FooterAction {\n /** Button text; may change between renders (`Save` → `Saving…`) without remounting. */\n label: string;\n /** Required even for a `submit` item, and ignored there (pass `() => {}`). Receives no event. */\n onClick: () => void;\n /** Greys the button out and blocks clicks. */\n disabled?: boolean;\n /** Spinner; blocks clicks. */\n loading?: boolean;\n /** Red treatment. */\n danger?: boolean;\n /** Renders `type=\"primary\"`; otherwise `type=\"default\"`. */\n emphasis?: boolean;\n /** Side of the row; default `'trailing'`. */\n align?: 'leading' | 'trailing';\n /** Render a native submit button (`onClick` is then ignored). */\n submit?: boolean;\n /** Id of the `<form>` to submit; needed because the row sits outside the form. */\n form?: string;\n}\n\nexport interface PageFooterActionsProps {\n /** Rendered in order within each side (leading, then trailing). */\n items: FooterAction[];\n}\n\n/**\n * Row of page-level buttons below the cards, split into leading and trailing\n * sides. Sits on the page background; don't put it inside a `Card`.\n */\nexport function PageFooterActions({ items }: PageFooterActionsProps) {\n const styles = useStyle();\n const leading = items.filter((item) => item.align === 'leading');\n const trailing = items.filter((item) => item.align !== 'leading');\n\n // Key by position within the row, not by label: a label can change across\n // renders (e.g. Save → Saving…) or repeat, and keying on it would remount the\n // button — dropping focus and its loading state.\n const renderButton = (item: FooterAction, key: string) => (\n <Button\n key={key}\n onClick={item.onClick}\n disabled={item.disabled}\n loading={item.loading}\n danger={item.danger}\n type={item.emphasis ? 'primary' : 'default'}\n submit={item.submit}\n form={item.form}\n >\n {item.label}\n </Button>\n );\n\n return (\n <div className={styles.root}>\n {leading.map((item, i) => renderButton(item, `leading-${i}`))}\n <div className={styles.spacer} />\n {trailing.map((item, i) => renderButton(item, `trailing-${i}`))}\n </div>\n );\n}\n"]}
@@ -1,10 +1,12 @@
1
1
  import { ReactNode, RefObject } from 'react';
2
- type Props = {
2
+ export type PopoverProps = {
3
3
  /** Element the popover aligns to (positioned directly beneath it). */
4
4
  anchorRef: RefObject<HTMLElement | null>;
5
5
  /** Whether the popover is rendered. */
6
6
  open: boolean;
7
+ /** Your surface: give it its own background, border, and radius. */
7
8
  children: ReactNode;
9
+ /** Applied to the fixed wrapper; win specificity with `'&&'`, never `!important`. */
8
10
  className?: string;
9
11
  /** Vertical gap between the anchor and the popover, in pixels. */
10
12
  gap?: number;
@@ -21,7 +23,8 @@ type Props = {
21
23
  * coordinates directly under `anchorRef`. This lets dropdowns escape ancestors
22
24
  * that clip overflow (e.g. cards with rounded corners) without those ancestors
23
25
  * having to opt out of clipping.
26
+ *
27
+ * No Escape handling or focus management, and it never flips above the anchor.
24
28
  */
25
- export declare const Popover: ({ anchorRef, open, children, className, gap, matchWidth, onClose, }: Props) => import("react").ReactPortal | null;
26
- export {};
29
+ export declare const Popover: ({ anchorRef, open, children, className, gap, matchWidth, onClose, }: PopoverProps) => import("react").ReactPortal | null;
27
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/popover/index.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,SAAS,EAMV,MAAM,OAAO,CAAC;AAOf,KAAK,KAAK,GAAG;IACX,sEAAsE;IACtE,SAAS,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACzC,uCAAuC;IACvC,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,OAAO,wEAQjB,KAAK,uCAqDP,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/popover/index.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,SAAS,EAMV,MAAM,OAAO,CAAC;AAOf,MAAM,MAAM,YAAY,GAAG;IACzB,sEAAsE;IACtE,SAAS,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACzC,uCAAuC;IACvC,IAAI,EAAE,OAAO,CAAC;IACd,oEAAoE;IACpE,QAAQ,EAAE,SAAS,CAAC;IACpB,qFAAqF;IACrF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,wEAQjB,YAAY,uCAqDd,CAAC"}
@@ -8,6 +8,8 @@ import { useStyle } from './style.js';
8
8
  * coordinates directly under `anchorRef`. This lets dropdowns escape ancestors
9
9
  * that clip overflow (e.g. cards with rounded corners) without those ancestors
10
10
  * having to opt out of clipping.
11
+ *
12
+ * No Escape handling or focus management, and it never flips above the anchor.
11
13
  */
12
14
  export const Popover = ({ anchorRef, open, children, className, gap = 4, matchWidth = true, onClose, }) => {
13
15
  const style = useStyle();
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/control/popover/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAGL,WAAW,EACX,SAAS,EACT,eAAe,EACf,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAsBtC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,EACtB,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,GAAG,GAAG,CAAC,EACP,UAAU,GAAG,IAAI,EACjB,OAAO,GACD,EAAE,EAAE;IACV,MAAM,KAAK,GAAG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AiB,EAAE,EAAE;YAC5C,MAAM,MAAM,GAAG,KAAK,CAAC,MAAc,CAAC;YACpC,IAAI,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC;gBAAE,OAAO;YAChD,IAAI,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC;gBAAE,OAAO;YACjD,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC;QACF,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;QACxD,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAC1E,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;IAE/B,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAEpC,OAAO,YAAY,CACjB,cACE,GAAG,EAAE,UAAU,EACf,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,EACvC,KAAK,EAAE;YACL,GAAG,EAAE,QAAQ,CAAC,GAAG;YACjB,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;SAC/C,YAEA,QAAQ,GACL,EACN,QAAQ,CAAC,IAAI,CACd,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import cx from 'classnames';\nimport {\n ReactNode,\n RefObject,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { useStyle } from './style.js';\n\ntype Position = { top: number; left: number; width: number };\n\ntype Props = {\n /** Element the popover aligns to (positioned directly beneath it). */\n anchorRef: RefObject<HTMLElement | null>;\n /** Whether the popover is rendered. */\n open: boolean;\n children: ReactNode;\n className?: string;\n /** Vertical gap between the anchor and the popover, in pixels. */\n gap?: number;\n /** Match the popover width to the anchor width (default true). */\n matchWidth?: boolean;\n /**\n * Called on a pointer-down outside both the anchor and the popover content.\n * Omit to opt out of outside-close handling.\n */\n onClose?: () => void;\n};\n\n/**\n * Renders `children` in a portal on `document.body`, positioned with `fixed`\n * coordinates directly under `anchorRef`. This lets dropdowns escape ancestors\n * that clip overflow (e.g. cards with rounded corners) without those ancestors\n * having to opt out of clipping.\n */\nexport const Popover = ({\n anchorRef,\n open,\n children,\n className,\n gap = 4,\n matchWidth = true,\n onClose,\n}: Props) => {\n const style = useStyle();\n const contentRef = useRef<HTMLDivElement>(null);\n const [position, setPosition] = useState<Position | null>(null);\n\n const updatePosition = useCallback(() => {\n const anchor = anchorRef.current;\n if (!anchor) return;\n const rect = anchor.getBoundingClientRect();\n setPosition({ top: rect.bottom + gap, left: rect.left, width: rect.width });\n }, [anchorRef, gap]);\n\n useLayoutEffect(() => {\n if (!open) return;\n updatePosition();\n const handle = () => updatePosition();\n // Capture-phase scroll so nested scroll containers reposition too.\n window.addEventListener('scroll', handle, true);\n window.addEventListener('resize', handle);\n return () => {\n window.removeEventListener('scroll', handle, true);\n window.removeEventListener('resize', handle);\n };\n }, [open, updatePosition]);\n\n useEffect(() => {\n if (!open || !onClose) return;\n const handleMouseDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (anchorRef.current?.contains(target)) return;\n if (contentRef.current?.contains(target)) return;\n onClose();\n };\n document.addEventListener('mousedown', handleMouseDown);\n return () => document.removeEventListener('mousedown', handleMouseDown);\n }, [open, onClose, anchorRef]);\n\n if (!open || !position) return null;\n\n return createPortal(\n <div\n ref={contentRef}\n className={cx(style.popover, className)}\n style={{\n top: position.top,\n left: position.left,\n width: matchWidth ? position.width : undefined,\n }}\n >\n {children}\n </div>,\n document.body\n );\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/control/popover/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC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;SAC/C,YAEA,QAAQ,GACL,EACN,QAAQ,CAAC,IAAI,CACd,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import cx from 'classnames';\nimport {\n ReactNode,\n RefObject,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { useStyle } from './style.js';\n\ntype Position = { top: number; left: number; width: number };\n\nexport type PopoverProps = {\n /** Element the popover aligns to (positioned directly beneath it). */\n anchorRef: RefObject<HTMLElement | null>;\n /** Whether the popover is rendered. */\n open: boolean;\n /** Your surface: give it its own background, border, and radius. */\n children: ReactNode;\n /** Applied to the fixed wrapper; win specificity with `'&&'`, never `!important`. */\n className?: string;\n /** Vertical gap between the anchor and the popover, in pixels. */\n gap?: number;\n /** Match the popover width to the anchor width (default true). */\n matchWidth?: boolean;\n /**\n * Called on a pointer-down outside both the anchor and the popover content.\n * Omit to opt out of outside-close handling.\n */\n onClose?: () => void;\n};\n\n/**\n * Renders `children` in a portal on `document.body`, positioned with `fixed`\n * coordinates directly under `anchorRef`. This lets dropdowns escape ancestors\n * that clip overflow (e.g. cards with rounded corners) without those ancestors\n * having to opt out of clipping.\n *\n * No Escape handling or focus management, and it never flips above the anchor.\n */\nexport const Popover = ({\n anchorRef,\n open,\n children,\n className,\n gap = 4,\n matchWidth = true,\n onClose,\n}: PopoverProps) => {\n const style = useStyle();\n const contentRef = useRef<HTMLDivElement>(null);\n const [position, setPosition] = useState<Position | null>(null);\n\n const updatePosition = useCallback(() => {\n const anchor = anchorRef.current;\n if (!anchor) return;\n const rect = anchor.getBoundingClientRect();\n setPosition({ top: rect.bottom + gap, left: rect.left, width: rect.width });\n }, [anchorRef, gap]);\n\n useLayoutEffect(() => {\n if (!open) return;\n updatePosition();\n const handle = () => updatePosition();\n // Capture-phase scroll so nested scroll containers reposition too.\n window.addEventListener('scroll', handle, true);\n window.addEventListener('resize', handle);\n return () => {\n window.removeEventListener('scroll', handle, true);\n window.removeEventListener('resize', handle);\n };\n }, [open, updatePosition]);\n\n useEffect(() => {\n if (!open || !onClose) return;\n const handleMouseDown = (event: MouseEvent) => {\n const target = event.target as Node;\n if (anchorRef.current?.contains(target)) return;\n if (contentRef.current?.contains(target)) return;\n onClose();\n };\n document.addEventListener('mousedown', handleMouseDown);\n return () => document.removeEventListener('mousedown', handleMouseDown);\n }, [open, onClose, anchorRef]);\n\n if (!open || !position) return null;\n\n return createPortal(\n <div\n ref={contentRef}\n className={cx(style.popover, className)}\n style={{\n top: position.top,\n left: position.left,\n width: matchWidth ? position.width : undefined,\n }}\n >\n {children}\n </div>,\n document.body\n );\n};\n"]}
@@ -1,14 +1,20 @@
1
1
  import type { IconProps } from '../../icon/index.js';
2
+ /** One segment of a `SegmentedControl`. */
2
3
  export type SegmentedOption<V extends string> = {
4
+ /** The value passed to `onChange` when this segment is picked. */
3
5
  value: V;
4
6
  /** The segment's accessible name, and its visible text unless `showLabels` is off. */
5
7
  label: string;
6
- /** Drawn above the label, which then becomes a small caption under it. */
8
+ /**
9
+ * Icon component (`Icon: SearchIcon`), not an element. Drawn above the label,
10
+ * which then becomes a small caption under it.
11
+ */
7
12
  Icon?: (props: IconProps) => React.JSX.Element;
8
13
  };
9
14
  type BaseProps<V extends string> = {
10
- /** The group's accessible name, e.g. the setting or field it edits. */
15
+ /** The group's accessible name, e.g. the setting or field it edits. Not rendered visibly. */
11
16
  label: string;
17
+ /** The segments, in order. Declare them `as const` or type them as `SegmentedOption<V>`. */
12
18
  options: ReadonlyArray<SegmentedOption<V>>;
13
19
  /** The checked option; `null` (or a value no option has) checks nothing and draws no lens. */
14
20
  value: V | null;
@@ -25,12 +31,13 @@ type BaseProps<V extends string> = {
25
31
  */
26
32
  surface?: 'card' | 'row';
27
33
  };
28
- type SegmentedControlProps<V extends string> = BaseProps<V> & ({
34
+ export type SegmentedControlProps<V extends string> = BaseProps<V> & ({
29
35
  /** Clicking (or Space/Enter on) the checked segment, Backspace and Delete clear the value. */
30
36
  clearable: true;
31
37
  /** Absent means read-only: the control shows the value and ignores input. */
32
38
  onChange?: (value: V | null) => void;
33
39
  } | {
40
+ /** Off by default: clicking the checked segment does nothing and there is no way to clear. */
34
41
  clearable?: false;
35
42
  /** Absent means read-only: the control shows the value and ignores input. */
36
43
  onChange?: (value: V) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/segmented-control/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,MAAM,IAAI;IAC9C,KAAK,EAAE,CAAC,CAAC;IACT,sFAAsF;IACtF,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;CAChD,CAAC;AAEF,KAAK,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI;IACjC,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,8FAA8F;IAC9F,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAChB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CAC1B,CAAC;AAEF,KAAK,qBAAqB,CAAC,CAAC,SAAS,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,GACzD,CACI;IACE,8FAA8F;IAC9F,SAAS,EAAE,IAAI,CAAC;IAChB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;CACtC,GACD;IACE,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,6EAA6E;IAC7E,QAAQ,CAAC,EA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OAAO,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAC3D,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,YAErD,OAAO,CAAC,MAAM,CAAC,IAbX,MAAM,CAAC,KAAK,CAcV,CACV,CAAC;YACJ,CAAC,CAAC,EACD,OAAO,KAAK,IAAI,IAAI,CACnB,cAAK,SAAS,EAAE,KAAK,CAAC,MAAM,iBAAc,MAAM,iBAAa,kBAAkB,YAC5E,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACvB,eAAyB,SAAS,EAAE,KAAK,CAAC,SAAS,YAChD,OAAO,CAAC,MAAM,CAAC,IADP,MAAM,CAAC,KAAK,CAEhB,CACR,CAAC,GACE,CACP,IACG,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import cx from 'classnames';\nimport { type CSSProperties, type KeyboardEvent, useRef } from 'react';\n\nimport type { IconProps } from '../../icon/index.js';\nimport { useStyle } from './style.js';\n\nexport type SegmentedOption<V extends string> = {\n value: V;\n /** The segment's accessible name, and its visible text unless `showLabels` is off. */\n label: string;\n /** Drawn above the label, which then becomes a small caption under it. */\n Icon?: (props: IconProps) => React.JSX.Element;\n};\n\ntype BaseProps<V extends string> = {\n /** The group's accessible name, e.g. the setting or field it edits. */\n label: string;\n options: ReadonlyArray<SegmentedOption<V>>;\n /** The checked option; `null` (or a value no option has) checks nothing and draws no lens. */\n value: V | null;\n /**\n * Render each option's label. Only an option with an `Icon` can go without\n * one; a text-only option always shows its label.\n */\n showLabels?: boolean;\n /**\n * What the control sits on. `card` (default) paints its own `bg.track`\n * rail. `row` paints nothing: the shaded input row it sits in is the track\n * and only the lens shows, the way the white field shows in a `TextInput`\n * row.\n */\n surface?: 'card' | 'row';\n};\n\ntype SegmentedControlProps<V extends string> = BaseProps<V> &\n (\n | {\n /** Clicking (or Space/Enter on) the checked segment, Backspace and Delete clear the value. */\n clearable: true;\n /** Absent means read-only: the control shows the value and ignores input. */\n onChange?: (value: V | null) => void;\n }\n | {\n clearable?: false;\n /** Absent means read-only: the control shows the value and ignores input. */\n onChange?: (value: V) => void;\n }\n );\n\nconst ICON_SIZE = 20;\n\n/**\n * A row of radios in a track, with a lens that slides to the checked one.\n *\n * The checked segment is not coloured itself. The brand colour is painted on\n * a second copy of the row, clipped to the lens's window and animated with\n * the same spring, so a segment the lens crosses on its way lights up as it\n * passes and dims as it leaves — what a native segmented control does, and\n * what the mobile nav's reveal does. Both rows share one grid and one set of\n * classes, so the copy sits on the real segments pixel for pixel.\n *\n * Keyboard, on the group: ArrowRight/ArrowUp and ArrowLeft/ArrowDown step one\n * option without wrapping (from nothing checked, \"next\" is the first); Home\n * and End jump to the ends; a digit selects that option directly; Backspace\n * and Delete clear when `clearable`. Space and Enter toggle the focused radio.\n */\nexport const SegmentedControl = <V extends string>(props: SegmentedControlProps<V>) => {\n const { label, options, value, showLabels = true, surface = 'card' } = props;\n const style = useStyle();\n const buttons = useRef<Array<HTMLButtonElement | null>>([]);\n const readOnly = props.onChange === undefined;\n const iconic = options.some((option) => option.Icon !== undefined);\n const checkedIndex = options.findIndex((option) => option.value === value);\n const checked = checkedIndex === -1 ? null : options[checkedIndex];\n\n const select = (next: V | null) => {\n if (props.onChange === undefined) return;\n if (next === null) {\n if (props.clearable) props.onChange(null);\n return;\n }\n props.onChange(next);\n buttons.current[options.findIndex((option) => option.value === next)]?.focus();\n };\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (readOnly) return;\n // Leave modified keys to the browser and OS: Cmd/Ctrl+digit switches tabs,\n // Alt/Cmd+arrow walks history, Cmd+Backspace and so on.\n if (event.ctrlKey || event.metaKey || event.altKey) return;\n const last = options.length - 1;\n let nextIndex: number | null | undefined;\n switch (event.key) {\n case 'ArrowRight':\n case 'ArrowUp':\n if (checkedIndex < last) nextIndex = checkedIndex + 1;\n break;\n case 'ArrowLeft':\n case 'ArrowDown':\n if (checkedIndex > 0) nextIndex = checkedIndex - 1;\n break;\n case 'Home':\n nextIndex = 0;\n break;\n case 'End':\n nextIndex = last;\n break;\n case 'Backspace':\n case 'Delete':\n if (!props.clearable) return;\n nextIndex = null;\n break;\n default: {\n // A digit picks that option; anything else (Space and Enter included)\n // falls through to the focused button's own handling.\n const digit = /^[1-9]$/.test(event.key) ? Number(event.key) - 1 : -1;\n if (digit === -1 || digit > last) return;\n nextIndex = digit;\n }\n }\n // Every handled key is consumed, including an arrow at the end of the\n // row, so it never scrolls the page instead.\n event.preventDefault();\n if (nextIndex !== undefined) select(nextIndex === null ? null : options[nextIndex].value);\n };\n\n // The lens is one segment wide and slides to the checked segment; the\n // segments are equal columns, so its position is just the checked index.\n const rootStyle = {\n '--seg-count': options.length,\n '--seg-index': Math.max(0, checkedIndex),\n } as CSSProperties;\n\n const content = ({ label: optionLabel, Icon }: SegmentedOption<V>) => (\n <>\n {Icon && <Icon aria-hidden width={ICON_SIZE} height={ICON_SIZE} />}\n {(showLabels || !Icon) && (\n <span className={cx(style.label, { [style.caption]: Icon !== undefined })} aria-hidden>\n {optionLabel}\n </span>\n )}\n </>\n );\n\n return (\n <div\n role=\"radiogroup\"\n aria-label={label}\n aria-disabled={readOnly ? 'true' : undefined}\n // An icon-led control names its value on hover; a text one already shows it.\n title={iconic ? checked?.label : undefined}\n className={cx(style.root, style[surface], {\n [style.readOnly]: readOnly,\n [style.iconic]: iconic,\n })}\n style={rootStyle}\n onKeyDown={handleKeyDown}\n >\n {checked !== null && <div className={style.lens} aria-hidden=\"true\" />}\n {options.map((option, index) => {\n const isChecked = index === checkedIndex;\n const isTabStop = !readOnly && (checked ? isChecked : index === 0);\n return (\n <button\n key={option.value}\n ref={(element) => {\n buttons.current[index] = element;\n }}\n type=\"button\"\n role=\"radio\"\n aria-checked={isChecked}\n aria-label={option.label}\n aria-disabled={readOnly ? 'true' : undefined}\n tabIndex={isTabStop ? 0 : -1}\n className={cx(style.segment, { [style.active]: isChecked })}\n onClick={() => select(isChecked ? null : option.value)}\n >\n {content(option)}\n </button>\n );\n })}\n {checked !== null && (\n <div className={style.reveal} aria-hidden=\"true\" data-testid=\"segmented-reveal\">\n {options.map((option) => (\n <span key={option.value} className={style.layerItem}>\n {content(option)}\n </span>\n ))}\n </div>\n )}\n </div>\n );\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/control/segmented-control/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAA0C,MAAM,EAAE,MAAM,OAAO,CAAC;AAGvE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAoDtC,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAmB,KAA+B,EAAE,EAAE;IACpF,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,EAAE,OAAO,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC;IAC7E,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,MAAM,OAAO,GAAG,MAAM,CAAkC,EAAE,CAAC,CAAC;IAC5D,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC;IAC9C,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IACnE,MAAM,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;IAC3E,MAAM,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,C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AAE,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAC3D,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,YAErD,OAAO,CAAC,MAAM,CAAC,IAbX,MAAM,CAAC,KAAK,CAcV,CACV,CAAC;YACJ,CAAC,CAAC,EACD,OAAO,KAAK,IAAI,IAAI,CACnB,cAAK,SAAS,EAAE,KAAK,CAAC,MAAM,iBAAc,MAAM,iBAAa,kBAAkB,YAC5E,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACvB,eAAyB,SAAS,EAAE,KAAK,CAAC,SAAS,YAChD,OAAO,CAAC,MAAM,CAAC,IADP,MAAM,CAAC,KAAK,CAEhB,CACR,CAAC,GACE,CACP,IACG,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import cx from 'classnames';\nimport { type CSSProperties, type KeyboardEvent, useRef } from 'react';\n\nimport type { IconProps } from '../../icon/index.js';\nimport { useStyle } from './style.js';\n\n/** One segment of a `SegmentedControl`. */\nexport type SegmentedOption<V extends string> = {\n /** The value passed to `onChange` when this segment is picked. */\n value: V;\n /** The segment's accessible name, and its visible text unless `showLabels` is off. */\n label: string;\n /**\n * Icon component (`Icon: SearchIcon`), not an element. Drawn above the label,\n * which then becomes a small caption under it.\n */\n Icon?: (props: IconProps) => React.JSX.Element;\n};\n\ntype BaseProps<V extends string> = {\n /** The group's accessible name, e.g. the setting or field it edits. Not rendered visibly. */\n label: string;\n /** The segments, in order. Declare them `as const` or type them as `SegmentedOption<V>`. */\n options: ReadonlyArray<SegmentedOption<V>>;\n /** The checked option; `null` (or a value no option has) checks nothing and draws no lens. */\n value: V | null;\n /**\n * Render each option's label. Only an option with an `Icon` can go without\n * one; a text-only option always shows its label.\n */\n showLabels?: boolean;\n /**\n * What the control sits on. `card` (default) paints its own `bg.track`\n * rail. `row` paints nothing: the shaded input row it sits in is the track\n * and only the lens shows, the way the white field shows in a `TextInput`\n * row.\n */\n surface?: 'card' | 'row';\n};\n\nexport type SegmentedControlProps<V extends string> = BaseProps<V> &\n (\n | {\n /** Clicking (or Space/Enter on) the checked segment, Backspace and Delete clear the value. */\n clearable: true;\n /** Absent means read-only: the control shows the value and ignores input. */\n onChange?: (value: V | null) => void;\n }\n | {\n /** Off by default: clicking the checked segment does nothing and there is no way to clear. */\n clearable?: false;\n /** Absent means read-only: the control shows the value and ignores input. */\n onChange?: (value: V) => void;\n }\n );\n\nconst ICON_SIZE = 20;\n\n/**\n * A row of radios in a track, with a lens that slides to the checked one.\n *\n * The checked segment is not coloured itself. The brand colour is painted on\n * a second copy of the row, clipped to the lens's window and animated with\n * the same spring, so a segment the lens crosses on its way lights up as it\n * passes and dims as it leaves — what a native segmented control does, and\n * what the mobile nav's reveal does. Both rows share one grid and one set of\n * classes, so the copy sits on the real segments pixel for pixel.\n *\n * Keyboard, on the group: ArrowRight/ArrowUp and ArrowLeft/ArrowDown step one\n * option without wrapping (from nothing checked, \"next\" is the first); Home\n * and End jump to the ends; a digit selects that option directly; Backspace\n * and Delete clear when `clearable`. Space and Enter toggle the focused radio.\n */\nexport const SegmentedControl = <V extends string>(props: SegmentedControlProps<V>) => {\n const { label, options, value, showLabels = true, surface = 'card' } = props;\n const style = useStyle();\n const buttons = useRef<Array<HTMLButtonElement | null>>([]);\n const readOnly = props.onChange === undefined;\n const iconic = options.some((option) => option.Icon !== undefined);\n const checkedIndex = options.findIndex((option) => option.value === value);\n const checked = checkedIndex === -1 ? null : options[checkedIndex];\n\n const select = (next: V | null) => {\n if (props.onChange === undefined) return;\n if (next === null) {\n if (props.clearable) props.onChange(null);\n return;\n }\n props.onChange(next);\n buttons.current[options.findIndex((option) => option.value === next)]?.focus();\n };\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (readOnly) return;\n // Leave modified keys to the browser and OS: Cmd/Ctrl+digit switches tabs,\n // Alt/Cmd+arrow walks history, Cmd+Backspace and so on.\n if (event.ctrlKey || event.metaKey || event.altKey) return;\n const last = options.length - 1;\n let nextIndex: number | null | undefined;\n switch (event.key) {\n case 'ArrowRight':\n case 'ArrowUp':\n if (checkedIndex < last) nextIndex = checkedIndex + 1;\n break;\n case 'ArrowLeft':\n case 'ArrowDown':\n if (checkedIndex > 0) nextIndex = checkedIndex - 1;\n break;\n case 'Home':\n nextIndex = 0;\n break;\n case 'End':\n nextIndex = last;\n break;\n case 'Backspace':\n case 'Delete':\n if (!props.clearable) return;\n nextIndex = null;\n break;\n default: {\n // A digit picks that option; anything else (Space and Enter included)\n // falls through to the focused button's own handling.\n const digit = /^[1-9]$/.test(event.key) ? Number(event.key) - 1 : -1;\n if (digit === -1 || digit > last) return;\n nextIndex = digit;\n }\n }\n // Every handled key is consumed, including an arrow at the end of the\n // row, so it never scrolls the page instead.\n event.preventDefault();\n if (nextIndex !== undefined) select(nextIndex === null ? null : options[nextIndex].value);\n };\n\n // The lens is one segment wide and slides to the checked segment; the\n // segments are equal columns, so its position is just the checked index.\n const rootStyle = {\n '--seg-count': options.length,\n '--seg-index': Math.max(0, checkedIndex),\n } as CSSProperties;\n\n const content = ({ label: optionLabel, Icon }: SegmentedOption<V>) => (\n <>\n {Icon && <Icon aria-hidden width={ICON_SIZE} height={ICON_SIZE} />}\n {(showLabels || !Icon) && (\n <span className={cx(style.label, { [style.caption]: Icon !== undefined })} aria-hidden>\n {optionLabel}\n </span>\n )}\n </>\n );\n\n return (\n <div\n role=\"radiogroup\"\n aria-label={label}\n aria-disabled={readOnly ? 'true' : undefined}\n // An icon-led control names its value on hover; a text one already shows it.\n title={iconic ? checked?.label : undefined}\n className={cx(style.root, style[surface], {\n [style.readOnly]: readOnly,\n [style.iconic]: iconic,\n })}\n style={rootStyle}\n onKeyDown={handleKeyDown}\n >\n {checked !== null && <div className={style.lens} aria-hidden=\"true\" />}\n {options.map((option, index) => {\n const isChecked = index === checkedIndex;\n const isTabStop = !readOnly && (checked ? isChecked : index === 0);\n return (\n <button\n key={option.value}\n ref={(element) => {\n buttons.current[index] = element;\n }}\n type=\"button\"\n role=\"radio\"\n aria-checked={isChecked}\n aria-label={option.label}\n aria-disabled={readOnly ? 'true' : undefined}\n tabIndex={isTabStop ? 0 : -1}\n className={cx(style.segment, { [style.active]: isChecked })}\n onClick={() => select(isChecked ? null : option.value)}\n >\n {content(option)}\n </button>\n );\n })}\n {checked !== null && (\n <div className={style.reveal} aria-hidden=\"true\" data-testid=\"segmented-reveal\">\n {options.map((option) => (\n <span key={option.value} className={style.layerItem}>\n {content(option)}\n </span>\n ))}\n </div>\n )}\n </div>\n );\n};\n"]}
@@ -1,18 +1,29 @@
1
+ /** A `Select` option: a plain string (label and value alike), or `{ label, value, description? }`. */
1
2
  export type SelectOption = string | {
2
3
  label: string;
3
4
  value: string;
4
5
  description?: string;
5
6
  };
6
7
  export type SelectProps = {
8
+ /** With a search query that matches no label exactly, offers an "Add: *query*" option. */
7
9
  allowCreate?: boolean;
10
+ /** Show the inline "clear" (✕) control when a value is selected (default true). */
8
11
  clearable?: boolean;
12
+ /** Faded; can't open; no clear button. */
9
13
  disabled?: boolean;
14
+ /** Visible label; it targets the search box, not the closed trigger. */
10
15
  label?: string;
16
+ /** Default `'horizontal'`; `horizontal`/`vertical` paint a card-header row. */
11
17
  layout?: 'horizontal' | 'vertical' | 'inline';
18
+ /** Shows a spinner and "Loading…"; can't open. */
12
19
  loading?: boolean;
20
+ /** Only lands on the search box while open: form data never carries the selection. */
13
21
  name: string;
22
+ /** Receives the option's `value`, `undefined` from clear, or the trimmed typed text from "Add:"; not an event. */
14
23
  onChange?: (value: string | undefined) => void;
24
+ /** Strings or `{ label, value, description? }` objects, mixed freely. */
15
25
  options: SelectOption[];
26
+ /** Shown when nothing is selected. Default `'Select…'`. */
16
27
  placeholder?: string;
17
28
  /**
18
29
  * Which surface this select sits on, which decides its corner radius AND its
@@ -30,8 +41,14 @@ export type SelectProps = {
30
41
  * because here the radius is a consequence, not the choice.
31
42
  */
32
43
  surface?: 'card' | 'page';
44
+ /** Opening swaps the trigger for a search box (default `true`); `false` is a plain list, arrow keys only. */
33
45
  searchable?: boolean;
46
+ /** Controlled selection; a value not in `options` displays as the raw string. */
34
47
  value: string | undefined;
35
48
  };
49
+ /**
50
+ * Controlled single-value picker with an optional search box and "Add:" entry,
51
+ * its list in a `Popover`. No hidden input: submit `value` from state.
52
+ */
36
53
  export declare const Select: ({ allowCreate, clearable, disabled, label, layout, loading, name, onChange, options, placeholder, surface, searchable, value, }: SelectProps) => import("react").JSX.Element;
37
54
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/select/index.tsx"],"names":[],"mappings":"AAOA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAI3F,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/C,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B,CAAC;AAmBF,eAAO,MAAM,MAAM,oIAchB,WAAW,gCA2Pb,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/select/index.tsx"],"names":[],"mappings":"AAOA,sGAAsG;AACtG,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAI3F,MAAM,MAAM,WAAW,GAAG;IACxB,0FAA0F;IAC1F,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,mFAAmF;IACnF,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+EAA+E;IAC/E,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC9C,kDAAkD;IAClD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sFAAsF;IACtF,IAAI,EAAE,MAAM,CAAC;IACb,kHAAkH;IAClH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/C,yEAAyE;IACzE,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,6GAA6G;IAC7G,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iFAAiF;IACjF,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B,CAAC;AAmBF;;;GAGG;AACH,eAAO,MAAM,MAAM,oIAchB,WAAW,gCA2Pb,CAAC"}
@@ -15,6 +15,10 @@ function highlight(text, query, className) {
15
15
  return text;
16
16
  return (_jsxs(_Fragment, { children: [text.slice(0, idx), _jsx("span", { className: className, children: text.slice(idx, idx + query.length) }), text.slice(idx + query.length)] }));
17
17
  }
18
+ /**
19
+ * Controlled single-value picker with an optional search box and "Add:" entry,
20
+ * its list in a `Popover`. No hidden input: submit `value` from state.
21
+ */
18
22
  export const Select = ({ allowCreate = false, clearable = true, disabled = false, label, layout = 'horizontal', loading = false, name, onChange = () => { }, options, placeholder = 'Select…', surface = 'card', searchable = true, value, }) => {
19
23
  const style = useStyle();
20
24
  // Per-instance DOM id so label/input association stays unique when two forms