@trellixio/roaster-react 2.1.0 → 2.1.2

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 (175) hide show
  1. package/cjs/components/ActionList/components/ActionListDropdown.js +13 -5
  2. package/cjs/components/ActionList/components/ActionListDropdown.js.map +1 -1
  3. package/cjs/components/ActionList/components/ActionListItem.js +7 -6
  4. package/cjs/components/ActionList/components/ActionListItem.js.map +1 -1
  5. package/cjs/components/ActionList/components/ActionListSearch.js +24 -6
  6. package/cjs/components/ActionList/components/ActionListSearch.js.map +1 -1
  7. package/cjs/components/ActionList/components/ActionListSubmenu.js +4 -3
  8. package/cjs/components/ActionList/components/ActionListSubmenu.js.map +1 -1
  9. package/cjs/components/ActionList/components/ActionListSwitchItem.js +6 -5
  10. package/cjs/components/ActionList/components/ActionListSwitchItem.js.map +1 -1
  11. package/cjs/components/AppFrame/AppFrame.js.map +1 -1
  12. package/cjs/components/Avatar/Avatar.js +1 -1
  13. package/cjs/components/Avatar/Avatar.js.map +1 -1
  14. package/cjs/components/Checkbox/Checkbox.js +4 -4
  15. package/cjs/components/Checkbox/Checkbox.js.map +1 -1
  16. package/cjs/components/ColorField/ColorField.js +42 -29
  17. package/cjs/components/ColorField/ColorField.js.map +1 -1
  18. package/cjs/components/DatePicker/DatePicker.js +2 -2
  19. package/cjs/components/DatePicker/DatePicker.js.map +1 -1
  20. package/cjs/components/DropdownCard/components/DropdownCardDropdown.js +10 -6
  21. package/cjs/components/DropdownCard/components/DropdownCardDropdown.js.map +1 -1
  22. package/cjs/components/Field/Field.js +26 -6
  23. package/cjs/components/Field/Field.js.map +1 -1
  24. package/cjs/components/FileField/FileField.js +42 -29
  25. package/cjs/components/FileField/FileField.js.map +1 -1
  26. package/cjs/components/Modal/Modal.js +7 -1
  27. package/cjs/components/Modal/Modal.js.map +1 -1
  28. package/cjs/components/RangeField/RangeField.js +34 -21
  29. package/cjs/components/RangeField/RangeField.js.map +1 -1
  30. package/cjs/components/Select/Select.js +8 -6
  31. package/cjs/components/Select/Select.js.map +1 -1
  32. package/cjs/components/Sidebar/Sidebar.js +35 -22
  33. package/cjs/components/Sidebar/Sidebar.js.map +1 -1
  34. package/cjs/components/Switch/Switch.js +7 -1
  35. package/cjs/components/Switch/Switch.js.map +1 -1
  36. package/cjs/components/Table/Table.js +4 -1
  37. package/cjs/components/Table/Table.js.map +1 -1
  38. package/cjs/components/Table/components/TableCell.js +3 -1
  39. package/cjs/components/Table/components/TableCell.js.map +1 -1
  40. package/cjs/components/Table/components/TableHeadCell.js +2 -2
  41. package/cjs/components/Table/components/TableHeadCell.js.map +1 -1
  42. package/cjs/components/TextField/TextField.js +3 -1
  43. package/cjs/components/TextField/TextField.js.map +1 -1
  44. package/cjs/components/Textarea/Textarea.js +36 -4
  45. package/cjs/components/Textarea/Textarea.js.map +1 -1
  46. package/cjs/components/Tooltip/Tooltip.js +6 -5
  47. package/cjs/components/Tooltip/Tooltip.js.map +1 -1
  48. package/cjs/tokens/tokens.js +3 -0
  49. package/cjs/tokens/tokens.js.map +1 -1
  50. package/cjs/utils/Slot/index.js +5 -5
  51. package/cjs/utils/Slot/index.js.map +1 -1
  52. package/cjs/utils/useDropdown/DropdownTrigger.js +4 -4
  53. package/cjs/utils/useDropdown/DropdownTrigger.js.map +1 -1
  54. package/cjs/utils/useMediaQuery/index.js +41 -0
  55. package/cjs/utils/useMediaQuery/index.js.map +1 -0
  56. package/cjs/utils/useMergeRefs/index.js +51 -0
  57. package/cjs/utils/useMergeRefs/index.js.map +1 -0
  58. package/esm/components/ActionList/components/ActionListDropdown.js +12 -4
  59. package/esm/components/ActionList/components/ActionListDropdown.js.map +1 -1
  60. package/esm/components/ActionList/components/ActionListItem.js +3 -2
  61. package/esm/components/ActionList/components/ActionListItem.js.map +1 -1
  62. package/esm/components/ActionList/components/ActionListSearch.js +21 -3
  63. package/esm/components/ActionList/components/ActionListSearch.js.map +1 -1
  64. package/esm/components/ActionList/components/ActionListSubmenu.js +2 -1
  65. package/esm/components/ActionList/components/ActionListSubmenu.js.map +1 -1
  66. package/esm/components/ActionList/components/ActionListSwitchItem.js +2 -1
  67. package/esm/components/ActionList/components/ActionListSwitchItem.js.map +1 -1
  68. package/esm/components/AppFrame/AppFrame.js.map +1 -1
  69. package/esm/components/Avatar/Avatar.js +1 -1
  70. package/esm/components/Avatar/Avatar.js.map +1 -1
  71. package/esm/components/Checkbox/Checkbox.js +1 -1
  72. package/esm/components/Checkbox/Checkbox.js.map +1 -1
  73. package/esm/components/ColorField/ColorField.js +42 -29
  74. package/esm/components/ColorField/ColorField.js.map +1 -1
  75. package/esm/components/DatePicker/DatePicker.js +1 -1
  76. package/esm/components/DatePicker/DatePicker.js.map +1 -1
  77. package/esm/components/DropdownCard/components/DropdownCardDropdown.js +8 -4
  78. package/esm/components/DropdownCard/components/DropdownCardDropdown.js.map +1 -1
  79. package/esm/components/Field/Field.js +26 -6
  80. package/esm/components/Field/Field.js.map +1 -1
  81. package/esm/components/FileField/FileField.js +42 -29
  82. package/esm/components/FileField/FileField.js.map +1 -1
  83. package/esm/components/Modal/Modal.js +7 -1
  84. package/esm/components/Modal/Modal.js.map +1 -1
  85. package/esm/components/RangeField/RangeField.js +34 -21
  86. package/esm/components/RangeField/RangeField.js.map +1 -1
  87. package/esm/components/Select/Select.js +4 -2
  88. package/esm/components/Select/Select.js.map +1 -1
  89. package/esm/components/Sidebar/Sidebar.js +35 -22
  90. package/esm/components/Sidebar/Sidebar.js.map +1 -1
  91. package/esm/components/Switch/Switch.js +7 -1
  92. package/esm/components/Switch/Switch.js.map +1 -1
  93. package/esm/components/Table/Table.js +4 -1
  94. package/esm/components/Table/Table.js.map +1 -1
  95. package/esm/components/Table/components/TableCell.js +3 -1
  96. package/esm/components/Table/components/TableCell.js.map +1 -1
  97. package/esm/components/Table/components/TableHeadCell.js +2 -2
  98. package/esm/components/Table/components/TableHeadCell.js.map +1 -1
  99. package/esm/components/TextField/TextField.js +3 -1
  100. package/esm/components/TextField/TextField.js.map +1 -1
  101. package/esm/components/Textarea/Textarea.js +38 -6
  102. package/esm/components/Textarea/Textarea.js.map +1 -1
  103. package/esm/components/Tooltip/Tooltip.js +2 -1
  104. package/esm/components/Tooltip/Tooltip.js.map +1 -1
  105. package/esm/package.json +4 -1
  106. package/esm/tokens/tokens.js +3 -0
  107. package/esm/tokens/tokens.js.map +1 -1
  108. package/esm/utils/Slot/index.js +1 -1
  109. package/esm/utils/Slot/index.js.map +1 -1
  110. package/esm/utils/useDropdown/DropdownTrigger.js +1 -1
  111. package/esm/utils/useDropdown/DropdownTrigger.js.map +1 -1
  112. package/esm/utils/useMediaQuery/index.js +25 -0
  113. package/esm/utils/useMediaQuery/index.js.map +1 -0
  114. package/esm/utils/useMergeRefs/index.js +36 -0
  115. package/esm/utils/useMergeRefs/index.js.map +1 -0
  116. package/lib/components/ActionList/ActionList.d.ts +1 -1
  117. package/lib/components/ActionList/components/ActionListDropdown.d.ts +10 -2
  118. package/lib/components/ActionList/components/ActionListDropdown.d.ts.map +1 -1
  119. package/lib/components/ActionList/components/ActionListItem.d.ts +4 -1
  120. package/lib/components/ActionList/components/ActionListItem.d.ts.map +1 -1
  121. package/lib/components/ActionList/components/ActionListSearch.d.ts.map +1 -1
  122. package/lib/components/ActionList/components/ActionListSubmenu.d.ts.map +1 -1
  123. package/lib/components/AppFrame/AppFrame.d.ts +5 -1
  124. package/lib/components/AppFrame/AppFrame.d.ts.map +1 -1
  125. package/lib/components/Avatar/Avatar.d.ts +4 -1
  126. package/lib/components/Avatar/Avatar.d.ts.map +1 -1
  127. package/lib/components/Checkbox/Checkbox.d.ts.map +1 -1
  128. package/lib/components/ColorField/ColorField.d.ts.map +1 -1
  129. package/lib/components/DatePicker/DatePicker.d.ts.map +1 -1
  130. package/lib/components/DatePicker/utils/index.d.ts +2 -1
  131. package/lib/components/DatePicker/utils/index.d.ts.map +1 -1
  132. package/lib/components/DropdownCard/components/DropdownCardDropdown.d.ts +7 -0
  133. package/lib/components/DropdownCard/components/DropdownCardDropdown.d.ts.map +1 -1
  134. package/lib/components/Field/Field.d.ts +13 -7
  135. package/lib/components/Field/Field.d.ts.map +1 -1
  136. package/lib/components/FileField/FileField.d.ts.map +1 -1
  137. package/lib/components/Modal/Modal.d.ts.map +1 -1
  138. package/lib/components/Modal/types/index.d.ts +6 -0
  139. package/lib/components/Modal/types/index.d.ts.map +1 -1
  140. package/lib/components/Modal/utils/reducer.d.ts +1 -0
  141. package/lib/components/Modal/utils/reducer.d.ts.map +1 -1
  142. package/lib/components/RangeField/RangeField.d.ts.map +1 -1
  143. package/lib/components/Select/Select.d.ts.map +1 -1
  144. package/lib/components/Sidebar/Sidebar.d.ts +6 -3
  145. package/lib/components/Sidebar/Sidebar.d.ts.map +1 -1
  146. package/lib/components/Switch/Switch.d.ts.map +1 -1
  147. package/lib/components/Table/Table.d.ts +4 -2
  148. package/lib/components/Table/Table.d.ts.map +1 -1
  149. package/lib/components/Table/Table.types.d.ts +9 -0
  150. package/lib/components/Table/Table.types.d.ts.map +1 -1
  151. package/lib/components/Table/components/TableCell.d.ts +3 -1
  152. package/lib/components/Table/components/TableCell.d.ts.map +1 -1
  153. package/lib/components/Table/components/TableHeadCell.d.ts +3 -1
  154. package/lib/components/Table/components/TableHeadCell.d.ts.map +1 -1
  155. package/lib/components/TextField/TextField.d.ts.map +1 -1
  156. package/lib/components/Textarea/Textarea.d.ts +6 -1
  157. package/lib/components/Textarea/Textarea.d.ts.map +1 -1
  158. package/lib/components/Tooltip/Tooltip.d.ts.map +1 -1
  159. package/lib/index.d.ts +1 -1
  160. package/lib/index.d.ts.map +1 -1
  161. package/lib/tokens/tokens.d.ts +3 -0
  162. package/lib/tokens/tokens.d.ts.map +1 -1
  163. package/lib/utils/Slot/index.d.ts.map +1 -1
  164. package/lib/utils/index.d.ts +2 -0
  165. package/lib/utils/index.d.ts.map +1 -1
  166. package/lib/utils/useDropdown/DropdownTrigger.d.ts.map +1 -1
  167. package/lib/utils/useMediaQuery/index.d.ts +8 -0
  168. package/lib/utils/useMediaQuery/index.d.ts.map +1 -0
  169. package/lib/utils/useMergeRefs/index.d.ts +11 -0
  170. package/lib/utils/useMergeRefs/index.d.ts.map +1 -0
  171. package/package.json +1 -1
  172. package/roaster.css +1 -1
  173. package/themes/azoth.css +1 -1
  174. package/themes/coffee.css +1 -1
  175. package/themes/scalar.css +1 -1
@@ -13,6 +13,7 @@ const RangeField = React.forwardRef((props, ref) => {
13
13
  value,
14
14
  min = 0,
15
15
  description,
16
+ keepDescription,
16
17
  disabled,
17
18
  onChange,
18
19
  onValueChange,
@@ -37,27 +38,39 @@ const RangeField = React.forwardRef((props, ref) => {
37
38
  onChange?.(event);
38
39
  setInternalValue(Number(event.currentTarget.value));
39
40
  };
40
- return /* @__PURE__ */ jsx(Field, { controlId: uid, label, description, error, className, style, children: /* @__PURE__ */ jsxs("div", { className: "roaster-range", children: [
41
- /* @__PURE__ */ jsx(
42
- "input",
43
- {
44
- ...others,
45
- ...fieldControlProps(uid, { description, error }, others),
46
- ref,
47
- className: "roaster-range__input",
48
- min,
49
- max,
50
- name,
51
- step,
52
- type: "range",
53
- disabled,
54
- value: current,
55
- onChange: handleChange,
56
- style: { "--roaster-range-percent": `${fillPercentage}%` }
57
- }
58
- ),
59
- /* @__PURE__ */ jsx("output", { className: "roaster-range__value", htmlFor: uid, children: current })
60
- ] }) });
41
+ return /* @__PURE__ */ jsx(
42
+ Field,
43
+ {
44
+ controlId: uid,
45
+ label,
46
+ description,
47
+ keepDescription,
48
+ error,
49
+ className,
50
+ style,
51
+ children: /* @__PURE__ */ jsxs("div", { className: "roaster-range", children: [
52
+ /* @__PURE__ */ jsx(
53
+ "input",
54
+ {
55
+ ...others,
56
+ ...fieldControlProps(uid, { description, error, keepDescription }, others),
57
+ ref,
58
+ className: "roaster-range__input",
59
+ min,
60
+ max,
61
+ name,
62
+ step,
63
+ type: "range",
64
+ disabled,
65
+ value: current,
66
+ onChange: handleChange,
67
+ style: { "--roaster-range-percent": `${fillPercentage}%` }
68
+ }
69
+ ),
70
+ /* @__PURE__ */ jsx("output", { className: "roaster-range__value", htmlFor: uid, children: current })
71
+ ] })
72
+ }
73
+ );
61
74
  });
62
75
  RangeField.displayName = "RangeField";
63
76
 
@@ -1 +1 @@
1
- {"version":3,"file":"RangeField.js","sources":["../../../../src/components/RangeField/RangeField.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useUid, useControllableState } from '@/utils';\nimport { Field, fieldControlProps, type FieldBaseProps } from '../Field';\n\n/**\n * Every native `<input>` prop (`name`, `required`, `aria-*`, ...) is accepted and forwarded to the range input, with the\n * ref. `className` and `style` go to the field's wrapper.\n */\nexport interface RangeFieldProps\n extends FieldBaseProps, Omit<React.ComponentPropsWithoutRef<'input'>, 'type' | 'className' | 'style'> {\n /** The HTML ID attribute to be applied to the range input element (optional). */\n id?: string;\n /** The minimum value of the range input field (optional). */\n min?: number;\n /** The maximum value of the range input field (optional). */\n max?: number;\n /** The step value of the range input field (optional). */\n step?: number;\n /** The name attribute to be applied to the range input element (optional). */\n name?: string;\n /** The value of the range input field (optional). */\n value?: number;\n /** Whether the range input field should be disabled (optional). */\n disabled?: boolean;\n /** The default value of the range input field (optional). */\n defaultValue?: number;\n /** Called with the new value when the user moves the slider. The native `onChange` gets the event. */\n onValueChange?(value: number): void;\n}\n\n/** A slider to pick a number between a minimum and a maximum, with its current value shown. */\nexport const RangeField = React.forwardRef<HTMLInputElement, RangeFieldProps>((props, ref) => {\n const {\n id,\n name,\n label,\n value,\n min = 0,\n description,\n disabled,\n onChange,\n onValueChange,\n step = 1,\n max = 100,\n error,\n className,\n style,\n defaultValue = 0,\n ...others\n } = props;\n\n const [internalValue, setInternalValue] = useControllableState<number>({\n value,\n defaultValue,\n onChange: onValueChange,\n });\n const uid = useUid(id);\n\n // The browser clamps what the slider shows; clamp what we display and fill with the same number.\n const current = Math.min(Math.max(Number(internalValue), min), max);\n const range = max - min;\n const fillPercentage = range > 0 ? (100 * (current - min)) / range : 0;\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n setInternalValue(Number(event.currentTarget.value));\n };\n\n return (\n <Field controlId={uid} label={label} description={description} error={error} className={className} style={style}>\n <div className=\"roaster-range\">\n <input\n {...others}\n {...fieldControlProps(uid, { label, description, error }, others)}\n ref={ref}\n className=\"roaster-range__input\"\n min={min}\n max={max}\n name={name}\n step={step}\n type=\"range\"\n disabled={disabled}\n value={current}\n onChange={handleChange}\n // The CSS fills the track up to this percentage, in the theme's colors.\n style={{ '--roaster-range-percent': `${fillPercentage}%` } as React.CSSProperties}\n />\n <output className=\"roaster-range__value\" htmlFor={uid}>\n {current}\n </output>\n </div>\n </Field>\n );\n});\n\nRangeField.displayName = 'RangeField';\n"],"names":[],"mappings":";;;;;;;AAKY,MAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AAC3D,EAAE,MAAM;AACR,IAAI,EAAE;AACN,IAAI,IAAI;AACR,IAAI,KAAK;AACT,IAAI,KAAK;AACT,IAAI,GAAG,GAAG,CAAC;AACX,IAAI,WAAW;AACf,IAAI,QAAQ;AACZ,IAAI,QAAQ;AACZ,IAAI,aAAa;AACjB,IAAI,IAAI,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,GAAG;AACb,IAAI,KAAK;AACT,IAAI,SAAS;AACb,IAAI,KAAK;AACT,IAAI,YAAY,GAAG,CAAC;AACpB,IAAI,GAAG;AACP,GAAG,GAAG,KAAK;AACX,EAAE,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,oBAAoB,CAAC;AACjE,IAAI,KAAK;AACT,IAAI,YAAY;AAChB,IAAI,QAAQ,EAAE;AACd,GAAG,CAAC;AACJ,EAAE,MAAM,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC;AACxB,EAAE,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,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E;AACxG,GAAG,EAAE,CAAC,EAAE,CAAC;AACT,CAAC;AACD,UAAU,CAAC,WAAW,GAAG,YAAY;;"}
1
+ {"version":3,"file":"RangeField.js","sources":["../../../../src/components/RangeField/RangeField.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useUid, useControllableState } from '@/utils';\nimport { Field, fieldControlProps, type FieldBaseProps } from '../Field';\n\n/**\n * Every native `<input>` prop (`name`, `required`, `aria-*`, ...) is accepted and forwarded to the range input, with the\n * ref. `className` and `style` go to the field's wrapper.\n */\nexport interface RangeFieldProps\n extends FieldBaseProps, Omit<React.ComponentPropsWithoutRef<'input'>, 'type' | 'className' | 'style'> {\n /** The HTML ID attribute to be applied to the range input element (optional). */\n id?: string;\n /** The minimum value of the range input field (optional). */\n min?: number;\n /** The maximum value of the range input field (optional). */\n max?: number;\n /** The step value of the range input field (optional). */\n step?: number;\n /** The name attribute to be applied to the range input element (optional). */\n name?: string;\n /** The value of the range input field (optional). */\n value?: number;\n /** Whether the range input field should be disabled (optional). */\n disabled?: boolean;\n /** The default value of the range input field (optional). */\n defaultValue?: number;\n /** Called with the new value when the user moves the slider. The native `onChange` gets the event. */\n onValueChange?(value: number): void;\n}\n\n/** A slider to pick a number between a minimum and a maximum, with its current value shown. */\nexport const RangeField = React.forwardRef<HTMLInputElement, RangeFieldProps>((props, ref) => {\n const {\n id,\n name,\n label,\n value,\n min = 0,\n description,\n keepDescription,\n disabled,\n onChange,\n onValueChange,\n step = 1,\n max = 100,\n error,\n className,\n style,\n defaultValue = 0,\n ...others\n } = props;\n\n const [internalValue, setInternalValue] = useControllableState<number>({\n value,\n defaultValue,\n onChange: onValueChange,\n });\n const uid = useUid(id);\n\n // The browser clamps what the slider shows; clamp what we display and fill with the same number.\n const current = Math.min(Math.max(Number(internalValue), min), max);\n const range = max - min;\n const fillPercentage = range > 0 ? (100 * (current - min)) / range : 0;\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n setInternalValue(Number(event.currentTarget.value));\n };\n\n return (\n <Field\n controlId={uid}\n label={label}\n description={description}\n keepDescription={keepDescription}\n error={error}\n className={className}\n style={style}\n >\n <div className=\"roaster-range\">\n <input\n {...others}\n {...fieldControlProps(uid, { label, description, error, keepDescription }, others)}\n ref={ref}\n className=\"roaster-range__input\"\n min={min}\n max={max}\n name={name}\n step={step}\n type=\"range\"\n disabled={disabled}\n value={current}\n onChange={handleChange}\n // The CSS fills the track up to this percentage, in the theme's colors.\n style={{ '--roaster-range-percent': `${fillPercentage}%` } as React.CSSProperties}\n />\n <output className=\"roaster-range__value\" htmlFor={uid}>\n {current}\n </output>\n </div>\n </Field>\n );\n});\n\nRangeField.displayName = 'RangeField';\n"],"names":[],"mappings":";;;;;;;AAKY,MAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AAC3D,EAAE,MAAM;AACR,IAAI,EAAE;AACN,IAAI,IAAI;AACR,IAAI,KAAK;AACT,IAAI,KAAK;AACT,IAAI,GAAG,GAAG,CAAC;AACX,IAAI,WAAW;AACf,IAAI,eAAe;AACnB,IAAI,QAAQ;AACZ,IAAI,QAAQ;AACZ,IAAI,aAAa;AACjB,IAAI,IAAI,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,GAAG;AACb,IAAI,KAAK;AACT,IAAI,SAAS;AACb,IAAI,KAAK;AACT,IAAI,YAAY,GAAG,CAAC;AACpB,IAAI,GAAG;AACP,GAAG,GAAG,KAAK;AACX,EAAE,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,oBAAoB,CAAC;AACjE,IAAI,KAAK;AACT,IAAI,YAAY;AAChB,IAAI,QAAQ,EAAE;AACd,GAAG,CAAC;AACJ,EAAE,MAAM,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC;AACxB,EAAE,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,EAA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AAsB,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE;AAC5G,OAAO,EAAE;AACT;AACA,GAAG;AACH,CAAC;AACD,UAAU,CAAC,WAAW,GAAG,YAAY;;"}
@@ -1,9 +1,9 @@
1
1
  'use client';
2
2
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
- import { useMergeRefs } from '@floating-ui/react';
4
3
  import * as React from 'react';
5
4
  import { Field, fieldControlProps } from '../Field/Field.js';
6
5
  import { useUid } from '../../utils/useUid/index.js';
6
+ import { useMergeRefs } from '../../utils/useMergeRefs/index.js';
7
7
  import { classNames } from '../../utils/classNames/index.js';
8
8
 
9
9
  function defaultOptionResolver(item) {
@@ -31,6 +31,7 @@ const SelectBase = React.forwardRef((props, ref) => {
31
31
  options,
32
32
  placeholder,
33
33
  description,
34
+ keepDescription,
34
35
  prefix,
35
36
  prefixWidth = prefix ? 24 : 12,
36
37
  onChange,
@@ -68,6 +69,7 @@ const SelectBase = React.forwardRef((props, ref) => {
68
69
  controlId: uid,
69
70
  label,
70
71
  description,
72
+ keepDescription,
71
73
  error,
72
74
  inline,
73
75
  className,
@@ -78,7 +80,7 @@ const SelectBase = React.forwardRef((props, ref) => {
78
80
  "select",
79
81
  {
80
82
  ...others,
81
- ...fieldControlProps(uid, { description, error }, others),
83
+ ...fieldControlProps(uid, { description, error, keepDescription }, others),
82
84
  ref: mergedRef,
83
85
  className: classNames("roaster-select", { "roaster-select--prefixed": prefix, "roaster-select--rich": rich }),
84
86
  style: { paddingLeft: prefixWidth },
@@ -1 +1 @@
1
- {"version":3,"file":"Select.js","sources":["../../../../src/components/Select/Select.tsx"],"sourcesContent":["import { useMergeRefs } from '@floating-ui/react';\nimport * as React from 'react';\nimport { classNames, useUid } from '@/utils';\nimport { Field, fieldControlProps, type FieldBaseProps, type InlineFieldProps } from '../Field';\n\n/** One option of the select, as rendered. */\nexport interface SelectOption {\n /** The submitted value. */\n value: string;\n /** The text shown. */\n label: string;\n /** Whether the option can't be chosen. */\n disabled?: boolean;\n /**\n * A line under the label in a `rich` select's list. Where the browser shows its own list, it follows the label after\n * a dot.\n */\n description?: string;\n}\n\n/** The items the select understands without an `optionResolver`. */\nexport type SelectItem = string | SelectOption | { id: string | number; name?: string; title?: string };\n\n/** Turns one item of `data` into the option to render. */\nexport type OptionResolver<T> = (item: T) => SelectOption;\n\n/**\n * Strings are their own value and label, `{ id, name }` and `{ id, title }` objects use the id as the value, and any\n * other object is read as an option (`{ value, label, disabled }`).\n */\nfunction defaultOptionResolver(item: unknown): SelectOption {\n if (typeof item === 'string') return { label: item, value: item };\n\n const record = (item ?? {}) as Record<string, unknown>;\n if ('id' in record && ('name' in record || 'title' in record)) {\n return { label: String(record.name ?? record.title), value: String(record.id) };\n }\n return { ...record, value: String(record.value), label: String(record.label) } as SelectOption;\n}\n\n/**\n * Every native `<select>` prop (`name`, `value`, `required`, `aria-*`, ...) is accepted and forwarded to the select,\n * with the ref. `className` and `style` go to the field's wrapper.\n */\nexport interface SelectProps<T = SelectItem>\n extends\n FieldBaseProps,\n InlineFieldProps,\n Omit<React.ComponentPropsWithoutRef<'select'>, 'prefix' | 'className' | 'style'> {\n /**\n * The options: strings, `{ value, label }` objects, `{ id, name }` objects, or any other shape together with an\n * `optionResolver`.\n */\n options: T[];\n /** A first, empty option such as \"Choose a country\", shown until one is chosen. It can't be chosen back. */\n placeholder?: string;\n /** The element to be displayed to the left of the select field (optional). */\n prefix?: React.ReactNode;\n /** The width of the prefix element (optional). */\n prefixWidth?: number;\n /** Called with the new value when the user picks an option. The native `onChange` gets the event. */\n onValueChange?(value: string): void;\n /** Turns each item of `options` into an option (`{ value, label, disabled }`). Needed for shapes the select doesn't know. */\n optionResolver?: OptionResolver<T>;\n /**\n * Draws the list itself, where the browser allows it (the customizable select: Chrome, Edge, Safari): a check on the\n * chosen option, the theme's hover, and the options' descriptions. Other browsers (Firefox) show their own list.\n */\n rich?: boolean;\n}\n\n/**\n * Keeps the descriptions out of a rich select's field: the field then shows the chosen option's content (a\n * `<selectedcontent>` in a `<button>`, first in the select), whose description the CSS hides. Added after rendering,\n * and only where the browser draws the list itself: React 18 doesn't allow a button in a select, and the other\n * browsers show the option's text.\n */\nfunction useSelectedContent(ref: React.RefObject<HTMLSelectElement | null>, enabled: boolean) {\n React.useEffect(() => {\n const select = ref.current;\n // jsdom has `CSS` without `supports`.\n const drawsItsList = typeof CSS?.supports === 'function' && CSS.supports('appearance', 'base-select');\n if (!enabled || !select || !drawsItsList) return undefined;\n const button = document.createElement('button');\n button.append(document.createElement('selectedcontent'));\n select.prepend(button);\n return () => button.remove();\n }, [ref, enabled]);\n}\n\nconst SelectBase = React.forwardRef<HTMLSelectElement, SelectProps<unknown>>((props, ref) => {\n const {\n label,\n options,\n placeholder,\n description,\n prefix,\n prefixWidth = prefix ? 24 : 12,\n onChange,\n onValueChange,\n id,\n error,\n optionResolver = defaultOptionResolver,\n rich = false,\n inline,\n className,\n style,\n defaultValue,\n ...others\n } = props;\n const uid = useUid(id);\n const selectRef = React.useRef<HTMLSelectElement>(null);\n const mergedRef = useMergeRefs([selectRef, ref]);\n const items = options.map(optionResolver);\n useSelectedContent(selectRef, rich && items.some((item) => item.description));\n const optionElements = items.map((item) => (\n <option key={item.value} value={item.value} disabled={item.disabled}>\n {item.label}\n {item.description && (\n <>\n <span className=\"roaster-select__separator\"> · </span>\n <small className=\"roaster-select__description\">{item.description}</small>\n </>\n )}\n </option>\n ));\n // Uncontrolled with a placeholder and no default: start on the placeholder, which a browser would skip as disabled.\n const startValue = defaultValue ?? (placeholder !== undefined && others.value === undefined ? '' : undefined);\n\n const handleChange = (event: React.ChangeEvent<HTMLSelectElement>) => {\n onChange?.(event);\n onValueChange?.(event.currentTarget.value);\n };\n\n return (\n <Field\n controlId={uid}\n label={label}\n description={description}\n error={error}\n inline={inline}\n className={className}\n style={style}\n >\n <div className={classNames({ 'roaster-input-group': prefix })}>\n {prefix && <span className=\"roaster-input-group__prefix\">{prefix}</span>}\n <select\n {...others}\n {...fieldControlProps(uid, { label, description, error }, others)}\n ref={mergedRef}\n className={classNames('roaster-select', { 'roaster-select--prefixed': prefix, 'roaster-select--rich': rich })}\n style={{ paddingLeft: prefixWidth }}\n defaultValue={startValue}\n onChange={handleChange}\n >\n {placeholder !== undefined && (\n <option value=\"\" disabled>\n {placeholder}\n </option>\n )}\n {optionElements}\n </select>\n </div>\n </Field>\n );\n});\n\nSelectBase.displayName = 'Select';\n\n/**\n * A dropdown to choose one option, from a list of strings or objects, with an optional prefix. The type of `options`'\n * items is passed to `optionResolver`.\n */\nexport const Select = SelectBase as (<T = SelectItem>(\n props: SelectProps<T> & React.RefAttributes<HTMLSelectElement>\n) => React.ReactElement | null) & { displayName?: string };\n"],"names":[],"mappings":";;;;;;;;AAMA,SAAS,qBAAqB,CAAC,IAAI,EAAE;AACrC,EAAE,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;AACnE,EAAE,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE;AAC3B,EAAE,IAAI,IAAI,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,IAAI,OAAO,IAAI,MAAM,CAAC,EAAE;AACjE,IAAI,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;AACnF,EAAE;AACF,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;AAChF;AACA,SAAS,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE;AAC1C,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM;AACxB,IAAI,MAAM,MAAM,GAAG,GAAG,CAAC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AK;AACX,MAAM,QAAQ,kBAAkB,IAAI,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,qBAAqB,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE;AAClH,QAAQ,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,6BAA6B,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAC7G,wBAAwB,IAAI;AAC5B,UAAU,QAAQ;AAClB,UAAU;AACV,YAAY,GAAG,MAAM;AACrB,YAAY,GAAG,iBAAiB,CAAC,GAAG,EAAE,EAAS,WAAW,EAAE,KAAK,EAAE,EAAE,MAAM,CAAC;AAC5E,YAAY,GAAG,EAAE,SAAS;AAC1B,YAAY,SAAS,EAAE,UAAU,CAAC,gBAAgB,EAAE,EAAE,0BAA0B,EAAE,MAAM,EAAE,sBAAsB,EAAE,IAAI,EAAE,CAAC;AACzH,YAAY,KAAK,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE;AAC/C,YAAY,YAAY,EAAE,UAAU;AACpC,YAAY,QAAQ,EAAE,YAAY;AAClC,YAAY,QAAQ,EAAE;AACtB,cAAc,WAAW,KAAK,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;AAC3H,cAAc;AACd;AACA;AACA;AACA,OAAO,EAAE;AACT;AACA,GAAG;AACH,CAAC,CAAC;AACF,UAAU,CAAC,WAAW,GAAG,QAAQ;AACrB,MAAC,MAAM,GAAG;;"}
1
+ {"version":3,"file":"Select.js","sources":["../../../../src/components/Select/Select.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames, useMergeRefs, useUid } from '@/utils';\nimport { Field, fieldControlProps, type FieldBaseProps, type InlineFieldProps } from '../Field';\n\n/** One option of the select, as rendered. */\nexport interface SelectOption {\n /** The submitted value. */\n value: string;\n /** The text shown. */\n label: string;\n /** Whether the option can't be chosen. */\n disabled?: boolean;\n /**\n * A line under the label in a `rich` select's list. Where the browser shows its own list, it follows the label after\n * a dot.\n */\n description?: string;\n}\n\n/** The items the select understands without an `optionResolver`. */\nexport type SelectItem = string | SelectOption | { id: string | number; name?: string; title?: string };\n\n/** Turns one item of `data` into the option to render. */\nexport type OptionResolver<T> = (item: T) => SelectOption;\n\n/**\n * Strings are their own value and label, `{ id, name }` and `{ id, title }` objects use the id as the value, and any\n * other object is read as an option (`{ value, label, disabled }`).\n */\nfunction defaultOptionResolver(item: unknown): SelectOption {\n if (typeof item === 'string') return { label: item, value: item };\n\n const record = (item ?? {}) as Record<string, unknown>;\n if ('id' in record && ('name' in record || 'title' in record)) {\n return { label: String(record.name ?? record.title), value: String(record.id) };\n }\n return { ...record, value: String(record.value), label: String(record.label) } as SelectOption;\n}\n\n/**\n * Every native `<select>` prop (`name`, `value`, `required`, `aria-*`, ...) is accepted and forwarded to the select,\n * with the ref. `className` and `style` go to the field's wrapper.\n */\nexport interface SelectProps<T = SelectItem>\n extends\n FieldBaseProps,\n InlineFieldProps,\n Omit<React.ComponentPropsWithoutRef<'select'>, 'prefix' | 'className' | 'style'> {\n /**\n * The options: strings, `{ value, label }` objects, `{ id, name }` objects, or any other shape together with an\n * `optionResolver`.\n */\n options: T[];\n /** A first, empty option such as \"Choose a country\", shown until one is chosen. It can't be chosen back. */\n placeholder?: string;\n /** The element to be displayed to the left of the select field (optional). */\n prefix?: React.ReactNode;\n /** The width of the prefix element (optional). */\n prefixWidth?: number;\n /** Called with the new value when the user picks an option. The native `onChange` gets the event. */\n onValueChange?(value: string): void;\n /** Turns each item of `options` into an option (`{ value, label, disabled }`). Needed for shapes the select doesn't know. */\n optionResolver?: OptionResolver<T>;\n /**\n * Draws the list itself, where the browser allows it (the customizable select: Chrome, Edge, Safari): a check on the\n * chosen option, the theme's hover, and the options' descriptions. Other browsers (Firefox) show their own list.\n */\n rich?: boolean;\n}\n\n/**\n * Keeps the descriptions out of a rich select's field: the field then shows the chosen option's content (a\n * `<selectedcontent>` in a `<button>`, first in the select), whose description the CSS hides. Added after rendering,\n * and only where the browser draws the list itself: React 18 doesn't allow a button in a select, and the other\n * browsers show the option's text.\n */\nfunction useSelectedContent(ref: React.RefObject<HTMLSelectElement | null>, enabled: boolean) {\n React.useEffect(() => {\n const select = ref.current;\n // jsdom has `CSS` without `supports`.\n const drawsItsList = typeof CSS?.supports === 'function' && CSS.supports('appearance', 'base-select');\n if (!enabled || !select || !drawsItsList) return undefined;\n const button = document.createElement('button');\n button.append(document.createElement('selectedcontent'));\n select.prepend(button);\n return () => button.remove();\n }, [ref, enabled]);\n}\n\nconst SelectBase = React.forwardRef<HTMLSelectElement, SelectProps<unknown>>((props, ref) => {\n const {\n label,\n options,\n placeholder,\n description,\n keepDescription,\n prefix,\n prefixWidth = prefix ? 24 : 12,\n onChange,\n onValueChange,\n id,\n error,\n optionResolver = defaultOptionResolver,\n rich = false,\n inline,\n className,\n style,\n defaultValue,\n ...others\n } = props;\n const uid = useUid(id);\n const selectRef = React.useRef<HTMLSelectElement>(null);\n const mergedRef = useMergeRefs([selectRef, ref]);\n const items = options.map(optionResolver);\n useSelectedContent(selectRef, rich && items.some((item) => item.description));\n const optionElements = items.map((item) => (\n <option key={item.value} value={item.value} disabled={item.disabled}>\n {item.label}\n {item.description && (\n <>\n <span className=\"roaster-select__separator\"> · </span>\n <small className=\"roaster-select__description\">{item.description}</small>\n </>\n )}\n </option>\n ));\n // Uncontrolled with a placeholder and no default: start on the placeholder, which a browser would skip as disabled.\n const startValue = defaultValue ?? (placeholder !== undefined && others.value === undefined ? '' : undefined);\n\n const handleChange = (event: React.ChangeEvent<HTMLSelectElement>) => {\n onChange?.(event);\n onValueChange?.(event.currentTarget.value);\n };\n\n return (\n <Field\n controlId={uid}\n label={label}\n description={description}\n keepDescription={keepDescription}\n error={error}\n inline={inline}\n className={className}\n style={style}\n >\n <div className={classNames({ 'roaster-input-group': prefix })}>\n {prefix && <span className=\"roaster-input-group__prefix\">{prefix}</span>}\n <select\n {...others}\n {...fieldControlProps(uid, { label, description, error, keepDescription }, others)}\n ref={mergedRef}\n className={classNames('roaster-select', { 'roaster-select--prefixed': prefix, 'roaster-select--rich': rich })}\n style={{ paddingLeft: prefixWidth }}\n defaultValue={startValue}\n onChange={handleChange}\n >\n {placeholder !== undefined && (\n <option value=\"\" disabled>\n {placeholder}\n </option>\n )}\n {optionElements}\n </select>\n </div>\n </Field>\n );\n});\n\nSelectBase.displayName = 'Select';\n\n/**\n * A dropdown to choose one option, from a list of strings or objects, with an optional prefix. The type of `options`'\n * items is passed to `optionResolver`.\n */\nexport const Select = SelectBase as (<T = SelectItem>(\n props: SelectProps<T> & React.RefAttributes<HTMLSelectElement>\n) => React.ReactElement | null) & { displayName?: string };\n"],"names":[],"mappings":";;;;;;;;AAKA,SAAS,qBAAqB,CAAC,IAAI,EAAE;AACrC,EAAE,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;AACnE,EAAE,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE;AAC3B,EAAE,IAAI,IAAI,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,IAAI,OAAO,IAAI,MAAM,CAAC,EAAE;AACjE,IAAI,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;AACnF,EAAE;AACF,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;AAChF;AACA,SAAS,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE;AAC1C,EAAE,KAAK,CAAC,SAAS,CAAC,M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jB,MAAM,eAAe;AACrB,MAAM,KAAK;AACX,MAAM,MAAM;AACZ,MAAM,SAAS;AACf,MAAM,KAAK;AACX,MAAM,QAAQ,kBAAkB,IAAI,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,qBAAqB,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE;AAClH,QAAQ,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,6BAA6B,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAC7G,wBAAwB,IAAI;AAC5B,UAAU,QAAQ;AAClB,UAAU;AACV,YAAY,GAAG,MAAM;AACrB,YAAY,GAAG,iBAAiB,CAAC,GAAG,EAAE,EAAS,WAAW,EAAE,KAAK,EAAE,eAAe,EAAE,EAAE,MAAM,CAAC;AAC7F,YAAY,GAAG,EAAE,SAAS;AAC1B,YAAY,SAAS,EAAE,UAAU,CAAC,gBAAgB,EAAE,EAAE,0BAA0B,EAAE,MAAM,EAAE,sBAAsB,EAAE,IAAI,EAAE,CAAC;AACzH,YAAY,KAAK,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE;AAC/C,YAAY,YAAY,EAAE,UAAU;AACpC,YAAY,QAAQ,EAAE,YAAY;AAClC,YAAY,QAAQ,EAAE;AACtB,cAAc,WAAW,KAAK,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;AAC3H,cAAc;AACd;AACA;AACA;AACA,OAAO,EAAE;AACT;AACA,GAAG;AACH,CAAC,CAAC;AACF,UAAU,CAAC,WAAW,GAAG,QAAQ;AACrB,MAAC,MAAM,GAAG;;"}
@@ -10,7 +10,7 @@ import { useUid } from '../../utils/useUid/index.js';
10
10
  import { classNames } from '../../utils/classNames/index.js';
11
11
 
12
12
  const isSection = (entry) => !Array.isArray(entry) && "items" in entry && "title" in entry;
13
- const defaultSidebarLabels = { navigation: "Main", open: "Open the menu" };
13
+ const defaultSidebarLabels = { navigation: "Main", open: "Open the menu", close: "Close the menu" };
14
14
  const keyOf = (item, index) => item.pathname ?? `item-${index}`;
15
15
  const SidebarBase = React.forwardRef((props, ref) => {
16
16
  const { mobileHeader, header, footer, activePath, onMenuItemClick, items, labels, className, id, ...others } = props;
@@ -111,27 +111,40 @@ const SidebarBase = React.forwardRef((props, ref) => {
111
111
  ),
112
112
  mobileHeader
113
113
  ] }),
114
- /* @__PURE__ */ jsx("aside", { ...others, ...popover, id: sidebarId, ref: setRefs, className: classNames("roaster-sidebar", className), children: /* @__PURE__ */ jsxs("nav", { className: "roaster-sidebar__nav", "aria-label": text.navigation, children: [
115
- /* @__PURE__ */ jsx(Section, { className: "roaster-sidebar__header", children: header }),
116
- /* @__PURE__ */ jsx(Section, { className: "roaster-sidebar__body", children: items.map(
117
- (item, index) => isSection(item) ? /* @__PURE__ */ jsxs(
118
- "section",
119
- {
120
- className: "roaster-sidebar__section",
121
- "aria-labelledby": `${sidebarId}-section-${index}`,
122
- children: [
123
- /* @__PURE__ */ jsxs("h2", { className: "roaster-sidebar__label", id: `${sidebarId}-section-${index}`, children: [
124
- item.title,
125
- item.action
126
- ] }),
127
- /* @__PURE__ */ jsx(Menu, { children: item.items.map(renderItem) })
128
- ]
129
- },
130
- `section-${index}`
131
- ) : Array.isArray(item) ? /* @__PURE__ */ jsx(Menu, { children: item.map(renderItem) }, `group-${keyOf(item[0] ?? { }, index)}`) : /* @__PURE__ */ jsx(Menu, { children: renderItem(item, index) }, `group-${keyOf(item, index)}`)
132
- ) }),
133
- /* @__PURE__ */ jsx(Section, { className: "roaster-sidebar__footer", children: footer })
134
- ] }) })
114
+ /* @__PURE__ */ jsxs("aside", { ...others, ...popover, id: sidebarId, ref: setRefs, className: classNames("roaster-sidebar", className), children: [
115
+ /* @__PURE__ */ jsx(
116
+ Button,
117
+ {
118
+ variant: "secondary",
119
+ iconOnly: true,
120
+ className: "roaster-sidebar__close",
121
+ "aria-label": text.close,
122
+ onClick: () => panelRef.current?.hidePopover?.(),
123
+ children: /* @__PURE__ */ jsx(Icon, { name: "xmark" })
124
+ }
125
+ ),
126
+ /* @__PURE__ */ jsxs("nav", { className: "roaster-sidebar__nav", "aria-label": text.navigation, children: [
127
+ /* @__PURE__ */ jsx(Section, { className: "roaster-sidebar__header", children: header }),
128
+ /* @__PURE__ */ jsx(Section, { className: "roaster-sidebar__body", children: items.map(
129
+ (item, index) => isSection(item) ? /* @__PURE__ */ jsxs(
130
+ "section",
131
+ {
132
+ className: "roaster-sidebar__section",
133
+ "aria-labelledby": `${sidebarId}-section-${index}`,
134
+ children: [
135
+ /* @__PURE__ */ jsxs("h2", { className: "roaster-sidebar__label", id: `${sidebarId}-section-${index}`, children: [
136
+ item.title,
137
+ item.action
138
+ ] }),
139
+ /* @__PURE__ */ jsx(Menu, { children: item.items.map(renderItem) })
140
+ ]
141
+ },
142
+ `section-${index}`
143
+ ) : Array.isArray(item) ? /* @__PURE__ */ jsx(Menu, { children: item.map(renderItem) }, `group-${keyOf(item[0] ?? { }, index)}`) : /* @__PURE__ */ jsx(Menu, { children: renderItem(item, index) }, `group-${keyOf(item, index)}`)
144
+ ) }),
145
+ /* @__PURE__ */ jsx(Section, { className: "roaster-sidebar__footer", children: footer })
146
+ ] })
147
+ ] })
135
148
  ] });
136
149
  });
137
150
  SidebarBase.displayName = "Sidebar";
@@ -1 +1 @@
1
- {"version":3,"file":"Sidebar.js","sources":["../../../../src/components/Sidebar/Sidebar.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames, useUid } from '@/utils';\nimport { Button } from '../Button';\nimport { Icon } from '@/components/Icon';\nimport { Section } from './components/Section';\nimport { Menu } from './components/Menu';\nimport type { MenuItemProps } from './components/MenuItem';\nimport { Back } from './components/Back';\n\n/** An item of the sidebar. Its other props (`href`, `onClick`...) go to its link. */\nexport interface SidebarItemProps extends Omit<MenuItemProps, 'children' | 'current'> {\n /** The text of the item. */\n label: React.ReactNode;\n /** The item's path: it is the current page when it matches `activePath`, and is passed to `onMenuItemClick`. */\n pathname?: string;\n /** The items under it, in a sub-menu that opens and closes. */\n subMenu?: SidebarItemProps[];\n}\n\n/** A labeled section of the sidebar, such as \"Company\" or \"Team\": a label over its items. */\nexport interface SidebarSection {\n /** The label, over the items. */\n title: React.ReactNode;\n /** A small button at the label's end, such as one that adds an item. */\n action?: React.ReactNode;\n /** The items of the section. */\n items: SidebarItemProps[];\n}\n\nconst isSection = (entry: SidebarItemProps | SidebarItemProps[] | SidebarSection): entry is SidebarSection =>\n !Array.isArray(entry) && 'items' in entry && 'title' in entry;\n\n/** The text of the sidebar, for other languages. */\nexport interface SidebarLabels {\n /** The name of the navigation, read by screen readers. */\n navigation: string;\n /** The name of the button that opens the sidebar on phones. */\n open: string;\n}\n\nconst defaultSidebarLabels: SidebarLabels = { navigation: 'Main', open: 'Open the menu' };\n\n/** Every native `<aside>` prop (`id`, `aria-*`, `data-*`, ...) is accepted and forwarded to it. */\nexport interface SidebarProps extends React.ComponentPropsWithoutRef<'aside'> {\n /** The top of the sidebar: the logo, buttons. */\n header?: React.ReactNode;\n /** The bottom of the sidebar: settings, the account. */\n footer?: React.ReactNode;\n /** The path of the current page: its item gets `aria-current=\"page\"`, and its sub-menu starts open. */\n activePath?: string;\n /** Next to the button that opens the sidebar on phones, such as the logo. */\n mobileHeader?: React.ReactNode;\n /**\n * The items. An array of items is a group, set apart from the next by a line or room; a section (`{ title, items }`)\n * is a group with a label over it.\n */\n items: (SidebarItemProps | SidebarItemProps[] | SidebarSection)[];\n /** Called when an item is clicked, with its pathname. */\n onMenuItemClick?: ({ itemId }: { itemId: string }) => void;\n /** The text of the sidebar, in English by default. */\n labels?: Partial<SidebarLabels>;\n}\n\nconst keyOf = (item: SidebarItemProps, index: number) => item.pathname ?? `item-${index}`;\n\nconst SidebarBase = React.forwardRef<HTMLElement, SidebarProps>((props, ref) => {\n const { mobileHeader, header, footer, activePath, onMenuItemClick, items, labels, className, id, ...others } = props;\n const text = { ...defaultSidebarLabels, ...labels };\n const sidebarId = useUid(id);\n const panelRef = React.useRef<HTMLElement | null>(null);\n const setRefs = React.useCallback(\n (panel: HTMLElement | null) => {\n panelRef.current = panel;\n if (typeof ref === 'function') ref(panel);\n else if (ref) ref.current = panel;\n },\n [ref]\n );\n\n // Whether the drawer is open on phones, for the opener's aria-expanded. The browser opens and closes it (popover).\n const [drawerOpen, setDrawerOpen] = React.useState(false);\n React.useEffect(() => {\n const panel = panelRef.current;\n const onToggle = (event: Event) => setDrawerOpen((event as ToggleEvent).newState === 'open');\n panel?.addEventListener('toggle', onToggle);\n return () => panel?.removeEventListener('toggle', onToggle);\n }, []);\n\n // The open sub-menus, by pathname: the current page's opens with it.\n const groupOf = React.useCallback(\n (path: string | undefined) =>\n items\n .flatMap((entry) => (isSection(entry) ? entry.items : entry))\n .find((item) => item.subMenu?.some((sub) => sub.pathname === path) || (item.subMenu && item.pathname === path))\n ?.pathname,\n [items]\n );\n const [openGroups, setOpenGroups] = React.useState(() => new Set([groupOf(activePath)].filter(Boolean)));\n React.useEffect(() => {\n const group = groupOf(activePath);\n if (group) setOpenGroups((open) => (open.has(group) ? open : new Set([...open, group])));\n }, [activePath, groupOf]);\n\n function onItemClick(item: SidebarItemProps) {\n if (item.pathname !== undefined) onMenuItemClick?.({ itemId: item.pathname });\n // On phones, choosing a page closes the drawer.\n if (!item.subMenu?.length && drawerOpen) panelRef.current?.hidePopover?.();\n }\n\n function renderItem(item: SidebarItemProps, index: number) {\n const { pathname, subMenu, icon, label, onClick, action, suffix, detail, ...linkProps } = item;\n if (subMenu && subMenu.length > 0) {\n const groupKey = keyOf(item, index);\n return (\n <li key={groupKey}>\n <details\n className=\"roaster-sidebar__group\"\n open={openGroups.has(groupKey)}\n onToggle={(event) => {\n const isOpen = event.currentTarget.open;\n setOpenGroups((open) => {\n if (open.has(groupKey) === isOpen) return open;\n const next = new Set(open);\n if (isOpen) next.add(groupKey);\n else next.delete(groupKey);\n return next;\n });\n }}\n >\n <summary className=\"roaster-sidebar__item\" onClick={() => onItemClick(item)}>\n {icon && <span className=\"roaster-sidebar__icon\">{icon}</span>}\n {label}\n {suffix != null && <span className=\"roaster-sidebar__end\">{suffix}</span>}\n {action && <span className=\"roaster-sidebar__end\">{action}</span>}\n </summary>\n <Menu.SubMenu>{subMenu.map((sub, subIndex) => renderItem(sub, subIndex))}</Menu.SubMenu>\n </details>\n </li>\n );\n }\n return (\n <Menu.Item\n key={keyOf(item, index)}\n {...linkProps}\n icon={icon}\n action={action}\n suffix={suffix}\n detail={detail}\n current={pathname !== undefined && pathname === activePath}\n onClick={(event) => {\n onClick?.(event);\n onItemClick(item);\n }}\n >\n {label}\n </Menu.Item>\n );\n }\n\n // `popover` isn't in React 18's types.\n const popover = { popover: 'auto' } as React.HTMLAttributes<HTMLElement>;\n\n return (\n <>\n <div className=\"roaster-sidebar-opener\">\n <Button\n variant=\"ghost\"\n iconOnly\n aria-label={text.open}\n aria-controls={sidebarId}\n aria-expanded={drawerOpen}\n onClick={() => panelRef.current?.showPopover?.()}\n >\n <Icon name=\"bars\" />\n </Button>\n {mobileHeader}\n </div>\n\n <aside {...others} {...popover} id={sidebarId} ref={setRefs} className={classNames('roaster-sidebar', className)}>\n <nav className=\"roaster-sidebar__nav\" aria-label={text.navigation}>\n <Section className=\"roaster-sidebar__header\">{header}</Section>\n <Section className=\"roaster-sidebar__body\">\n {items.map((item, index) =>\n isSection(item) ? (\n <section\n key={`section-${index}`}\n className=\"roaster-sidebar__section\"\n aria-labelledby={`${sidebarId}-section-${index}`}\n >\n <h2 className=\"roaster-sidebar__label\" id={`${sidebarId}-section-${index}`}>\n {item.title}\n {item.action}\n </h2>\n <Menu>{item.items.map(renderItem)}</Menu>\n </section>\n ) : Array.isArray(item) ? (\n <Menu key={`group-${keyOf(item[0] ?? { label: '' }, index)}`}>{item.map(renderItem)}</Menu>\n ) : (\n <Menu key={`group-${keyOf(item, index)}`}>{renderItem(item, index)}</Menu>\n )\n )}\n </Section>\n <Section className=\"roaster-sidebar__footer\">{footer}</Section>\n </nav>\n </aside>\n </>\n );\n});\n\nSidebarBase.displayName = 'Sidebar';\n\n/**\n * The navigation of an application: a header (the logo, or the account button with a Sidebar.Back under it), groups\n * of items with sub-menus (`<details>`), labeled sections, and a footer. The current\n * page's item has `aria-current=\"page\"`. On phones, it is a drawer (a popover) that a bar at the top opens.\n */\nexport const Sidebar = Object.assign(SidebarBase, { Section: Section, Menu: Menu, Back: Back });\n"],"names":[],"mappings":";;;;;;;;;;;AASA,MAAM,SAAS,GAAG,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,IAAI,KAAK,IAAI,OAAO,IAAI,KAAK;AAC1F,MAAM,oBAAoB,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE;AAC1E,MAAM,KAAK,GAAG,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,CAAC,QAAQ,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC/D,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AACrD,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,KAAK;AACtH,EAAE,MAAM,IAAI,GAAG,EAAE,GAAG,oBAAoB,EAAE,GAAG,MAAM,EAAE;AACrD,EAAE,MAAM,SAAS,GAAG,MAAM,CAAC,EAAE,CAAC;AAC9B,EAAE,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;AACrC,EAAE,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW;AACnC,IAAI,CAAC,KAAK,KAAK;AACf,MAAM,QAAQ,CAAC,OAA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C,IAAI,CAAC,CAAC,CAAC,IAAI,EAAY,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,mBAAmB,GAAG,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AACnP,OAAO,EAAE,CAAC;AACV,sBAAsB,GAAG,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,yBAAyB,EAAE,QAAQ,EAAE,MAAM,EAAE;AAC7F,KAAK,EAAE,CAAC,EAAE;AACV,GAAG,EAAE,CAAC;AACN,CAAC,CAAC;AACF,WAAW,CAAC,WAAW,GAAG,SAAS;AACvB,MAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE;;"}
1
+ {"version":3,"file":"Sidebar.js","sources":["../../../../src/components/Sidebar/Sidebar.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames, useUid } from '@/utils';\nimport { Button } from '../Button';\nimport { Icon } from '@/components/Icon';\nimport { Section } from './components/Section';\nimport { Menu } from './components/Menu';\nimport type { MenuItemProps } from './components/MenuItem';\nimport { Back } from './components/Back';\n\n/** An item of the sidebar. Its other props (`href`, `onClick`...) go to its link. */\nexport interface SidebarItemProps extends Omit<MenuItemProps, 'children' | 'current'> {\n /** The text of the item. */\n label: React.ReactNode;\n /** The item's path: it is the current page when it matches `activePath`, and is passed to `onMenuItemClick`. */\n pathname?: string;\n /** The items under it, in a sub-menu that opens and closes. */\n subMenu?: SidebarItemProps[];\n}\n\n/** A labeled section of the sidebar, such as \"Company\" or \"Team\": a label over its items. */\nexport interface SidebarSection {\n /** The label, over the items. */\n title: React.ReactNode;\n /** A small button at the label's end, such as one that adds an item. */\n action?: React.ReactNode;\n /** The items of the section. */\n items: SidebarItemProps[];\n}\n\nconst isSection = (entry: SidebarItemProps | SidebarItemProps[] | SidebarSection): entry is SidebarSection =>\n !Array.isArray(entry) && 'items' in entry && 'title' in entry;\n\n/** The text of the sidebar, for other languages. */\nexport interface SidebarLabels {\n /** The name of the navigation, read by screen readers. */\n navigation: string;\n /** The name of the button that opens the sidebar where it is a drawer (up to 1024px). */\n open: string;\n /** The name of the button that closes it there. */\n close: string;\n}\n\nconst defaultSidebarLabels: SidebarLabels = { navigation: 'Main', open: 'Open the menu', close: 'Close the menu' };\n\n/** Every native `<aside>` prop (`id`, `aria-*`, `data-*`, ...) is accepted and forwarded to it. */\nexport interface SidebarProps extends React.ComponentPropsWithoutRef<'aside'> {\n /** The top of the sidebar: the logo, buttons. */\n header?: React.ReactNode;\n /** The bottom of the sidebar: settings, the account. */\n footer?: React.ReactNode;\n /** The path of the current page: its item gets `aria-current=\"page\"`, and its sub-menu starts open. */\n activePath?: string;\n /** Next to the button that opens the sidebar where it is a drawer, such as the logo. */\n mobileHeader?: React.ReactNode;\n /**\n * The items. An array of items is a group, set apart from the next by a line or room; a section (`{ title, items }`)\n * is a group with a label over it.\n */\n items: (SidebarItemProps | SidebarItemProps[] | SidebarSection)[];\n /** Called when an item is clicked, with its pathname. */\n onMenuItemClick?: ({ itemId }: { itemId: string }) => void;\n /** The text of the sidebar, in English by default. */\n labels?: Partial<SidebarLabels>;\n}\n\nconst keyOf = (item: SidebarItemProps, index: number) => item.pathname ?? `item-${index}`;\n\nconst SidebarBase = React.forwardRef<HTMLElement, SidebarProps>((props, ref) => {\n const { mobileHeader, header, footer, activePath, onMenuItemClick, items, labels, className, id, ...others } = props;\n const text = { ...defaultSidebarLabels, ...labels };\n const sidebarId = useUid(id);\n const panelRef = React.useRef<HTMLElement | null>(null);\n const setRefs = React.useCallback(\n (panel: HTMLElement | null) => {\n panelRef.current = panel;\n if (typeof ref === 'function') ref(panel);\n else if (ref) ref.current = panel;\n },\n [ref]\n );\n\n // Whether the drawer is open, for the opener's aria-expanded. The browser opens and closes it (popover).\n const [drawerOpen, setDrawerOpen] = React.useState(false);\n React.useEffect(() => {\n const panel = panelRef.current;\n const onToggle = (event: Event) => setDrawerOpen((event as ToggleEvent).newState === 'open');\n panel?.addEventListener('toggle', onToggle);\n return () => panel?.removeEventListener('toggle', onToggle);\n }, []);\n\n // The open sub-menus, by pathname: the current page's opens with it.\n const groupOf = React.useCallback(\n (path: string | undefined) =>\n items\n .flatMap((entry) => (isSection(entry) ? entry.items : entry))\n .find((item) => item.subMenu?.some((sub) => sub.pathname === path) || (item.subMenu && item.pathname === path))\n ?.pathname,\n [items]\n );\n const [openGroups, setOpenGroups] = React.useState(() => new Set([groupOf(activePath)].filter(Boolean)));\n React.useEffect(() => {\n const group = groupOf(activePath);\n if (group) setOpenGroups((open) => (open.has(group) ? open : new Set([...open, group])));\n }, [activePath, groupOf]);\n\n function onItemClick(item: SidebarItemProps) {\n if (item.pathname !== undefined) onMenuItemClick?.({ itemId: item.pathname });\n // Where the sidebar is a drawer, choosing a page closes it.\n if (!item.subMenu?.length && drawerOpen) panelRef.current?.hidePopover?.();\n }\n\n function renderItem(item: SidebarItemProps, index: number) {\n const { pathname, subMenu, icon, label, onClick, action, suffix, detail, ...linkProps } = item;\n if (subMenu && subMenu.length > 0) {\n const groupKey = keyOf(item, index);\n return (\n <li key={groupKey}>\n <details\n className=\"roaster-sidebar__group\"\n open={openGroups.has(groupKey)}\n onToggle={(event) => {\n const isOpen = event.currentTarget.open;\n setOpenGroups((open) => {\n if (open.has(groupKey) === isOpen) return open;\n const next = new Set(open);\n if (isOpen) next.add(groupKey);\n else next.delete(groupKey);\n return next;\n });\n }}\n >\n <summary className=\"roaster-sidebar__item\" onClick={() => onItemClick(item)}>\n {icon && <span className=\"roaster-sidebar__icon\">{icon}</span>}\n {label}\n {suffix != null && <span className=\"roaster-sidebar__end\">{suffix}</span>}\n {action && <span className=\"roaster-sidebar__end\">{action}</span>}\n </summary>\n <Menu.SubMenu>{subMenu.map((sub, subIndex) => renderItem(sub, subIndex))}</Menu.SubMenu>\n </details>\n </li>\n );\n }\n return (\n <Menu.Item\n key={keyOf(item, index)}\n {...linkProps}\n icon={icon}\n action={action}\n suffix={suffix}\n detail={detail}\n current={pathname !== undefined && pathname === activePath}\n onClick={(event) => {\n onClick?.(event);\n onItemClick(item);\n }}\n >\n {label}\n </Menu.Item>\n );\n }\n\n // `popover` isn't in React 18's types.\n const popover = { popover: 'auto' } as React.HTMLAttributes<HTMLElement>;\n\n return (\n <>\n <div className=\"roaster-sidebar-opener\">\n <Button\n variant=\"ghost\"\n iconOnly\n aria-label={text.open}\n aria-controls={sidebarId}\n aria-expanded={drawerOpen}\n onClick={() => panelRef.current?.showPopover?.()}\n >\n <Icon name=\"bars\" />\n </Button>\n {mobileHeader}\n </div>\n\n <aside {...others} {...popover} id={sidebarId} ref={setRefs} className={classNames('roaster-sidebar', className)}>\n <Button\n variant=\"secondary\"\n iconOnly\n className=\"roaster-sidebar__close\"\n aria-label={text.close}\n onClick={() => panelRef.current?.hidePopover?.()}\n >\n <Icon name=\"xmark\" />\n </Button>\n <nav className=\"roaster-sidebar__nav\" aria-label={text.navigation}>\n <Section className=\"roaster-sidebar__header\">{header}</Section>\n <Section className=\"roaster-sidebar__body\">\n {items.map((item, index) =>\n isSection(item) ? (\n <section\n key={`section-${index}`}\n className=\"roaster-sidebar__section\"\n aria-labelledby={`${sidebarId}-section-${index}`}\n >\n <h2 className=\"roaster-sidebar__label\" id={`${sidebarId}-section-${index}`}>\n {item.title}\n {item.action}\n </h2>\n <Menu>{item.items.map(renderItem)}</Menu>\n </section>\n ) : Array.isArray(item) ? (\n <Menu key={`group-${keyOf(item[0] ?? { label: '' }, index)}`}>{item.map(renderItem)}</Menu>\n ) : (\n <Menu key={`group-${keyOf(item, index)}`}>{renderItem(item, index)}</Menu>\n )\n )}\n </Section>\n <Section className=\"roaster-sidebar__footer\">{footer}</Section>\n </nav>\n </aside>\n </>\n );\n});\n\nSidebarBase.displayName = 'Sidebar';\n\n/**\n * The navigation of an application: a header (the logo, or the account button with a Sidebar.Back under it), groups\n * of items with sub-menus (`<details>`), labeled sections, and a footer. The current\n * page's item has `aria-current=\"page\"`. Up to a tablet's width (1024px), it is a drawer (a popover) that a bar at the\n * top opens, with a close button beside it.\n */\nexport const Sidebar = Object.assign(SidebarBase, { Section: Section, Menu: Menu, Back: Back });\n"],"names":[],"mappings":";;;;;;;;;;;AASA,MAAM,SAAS,GAAG,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,IAAI,KAAK,IAAI,OAAO,IAAI,KAAK;AAC1F,MAAM,oBAAoB,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,gBAAgB,EAAE;AACnG,MAAM,KAAK,GAAG,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,CAAC,QAAQ,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC/D,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AACrD,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,KAAK;AACtH,EAAE,MAAM,IAAI,GAAG,EAAE,GAAG,oBAAoB,EAAE,GAAG,MAAM,EAAE;AACrD,EAAE,MAAM,SAAS,GAAG,MAAM,CAAC,EAAE,CAAC;AAC9B,EAAE,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;AACrC,EAAE,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW;AACnC,IAAI,CAAC,KAAK,KAAK;AACf,MAAM,QAAQ,CAAC,OAAO,GAAG,KAAK;AAC9B,MAAM,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,GAAG,CAAC,KAAK,CAAC;AAC/C,WA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G,CAAC,UAAU,CAAC,EAAE;AAClF;AACA,aAAa;AACb,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC;AAC7B,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,GAAG,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAY,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,mBAAmB,GAAG,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AACrP,SAAS,EAAE,CAAC;AACZ,wBAAwB,GAAG,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,yBAAyB,EAAE,QAAQ,EAAE,MAAM,EAAE;AAC/F,OAAO,EAAE;AACT,KAAK,EAAE;AACP,GAAG,EAAE,CAAC;AACN,CAAC,CAAC;AACF,WAAW,CAAC,WAAW,GAAG,SAAS;AACvB,MAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE;;"}
@@ -14,6 +14,7 @@ const Switch = React.forwardRef((props, ref) => {
14
14
  checked: checkedProp,
15
15
  defaultChecked = false,
16
16
  description,
17
+ keepDescription,
17
18
  error,
18
19
  className,
19
20
  style,
@@ -39,6 +40,7 @@ const Switch = React.forwardRef((props, ref) => {
39
40
  controlId: uid,
40
41
  label: beside ? void 0 : label,
41
42
  description,
43
+ keepDescription,
42
44
  error,
43
45
  className,
44
46
  style,
@@ -47,7 +49,11 @@ const Switch = React.forwardRef((props, ref) => {
47
49
  "input",
48
50
  {
49
51
  ...others,
50
- ...fieldControlProps(uid, { description, error }, others),
52
+ ...fieldControlProps(
53
+ uid,
54
+ { description, error, keepDescription },
55
+ others
56
+ ),
51
57
  ref,
52
58
  type: "checkbox",
53
59
  role: "switch",
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.js","sources":["../../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useUid, useControllableState } from '@/utils';\nimport { Field, fieldControlProps, type FieldBaseProps } from '../Field';\n\n/**\n * Every native `<input>` prop (`name`, `required`, `aria-*`, ...) is accepted and forwarded to the switch input, with the\n * ref. `className` and `style` go to the field's wrapper.\n */\nexport interface SwitchProps\n extends FieldBaseProps, Omit<React.ComponentPropsWithoutRef<'input'>, 'type' | 'className' | 'style'> {\n /** The HTML ID attribute to be applied to the switch element (optional). */\n id?: string;\n /** The name attribute to be applied to the switch element (optional). */\n name?: string;\n /** Whether the switch toggle should be disabled (optional). */\n disabled?: boolean;\n /** The checked state of the switch toggle, for a controlled switch (optional). */\n checked?: boolean;\n /** The default checked state of the switch toggle, for an uncontrolled switch (optional). */\n defaultChecked?: boolean;\n /** Called with the new state when the user toggles the switch. The native `onChange` gets the event. */\n onCheckedChange?(value: boolean): void;\n /**\n * Where the label goes: over the switch, as a field's label (`top`), or beside it (`end`), as a checkbox's, such as\n * in a list of settings.\n * @defaultValue 'top'\n */\n labelPosition?: 'top' | 'end';\n}\n\n/**\n * A toggle switch with a label, over it or beside it. Control it with checked and onCheckedChange, or leave it\n * uncontrolled with defaultChecked.\n */\nexport const Switch = React.forwardRef<HTMLInputElement, SwitchProps>((props, ref) => {\n const {\n id,\n label,\n name,\n disabled,\n checked: checkedProp,\n defaultChecked = false,\n description,\n error,\n className,\n style,\n onChange,\n onCheckedChange,\n labelPosition = 'top',\n ...others\n } = props;\n const beside = labelPosition === 'end';\n const [checked, setChecked] = useControllableState<boolean>({\n value: checkedProp,\n defaultValue: defaultChecked ?? false,\n onChange: onCheckedChange,\n });\n\n const uid = useUid(id);\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n setChecked(event.currentTarget.checked);\n };\n\n return (\n <Field\n controlId={uid}\n label={beside ? undefined : label}\n description={description}\n error={error}\n className={className}\n style={style}\n >\n {/* Its own label too, so a click on the toggle reaches the input; beside it, it holds the text. */}\n <label className=\"roaster-switch\">\n <input\n {...others}\n {...fieldControlProps(uid, { label: beside ? undefined : label, description, error }, others)}\n ref={ref}\n type=\"checkbox\"\n role=\"switch\"\n className=\"roaster-switch__input\"\n name={name}\n checked={checked}\n disabled={disabled}\n onChange={handleChange}\n />\n <span className=\"roaster-switch__track\" />\n {beside && label && <span className=\"roaster-switch__label\">{label}</span>}\n </label>\n </Field>\n );\n});\n\nSwitch.displayName = 'Switch';\n"],"names":[],"mappings":";;;;;;;AAKY,MAAC,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AACvD,EAAE,MAAM;AACR,IAAI,EAAE;AACN,IAAI,KAAK;AACT,IAAI,IAAI;AACR,IAAI,QAAQ;AACZ,IAAI,OAAO,EAAE,WAAW;AACxB,IAAI,cAAc,GAAG,KAAK;AAC1B,IAAI,WAAW;AACf,IAAI,KAAK;AACT,IAAI,SAAS;AACb,IAAI,KAAK;AACT,IAAI,QAAQ;AACZ,IAAI,eAAe;AACnB,IAAI,aAAa,GAAG,KAAK;AACzB,IAAI,GAAG;AACP,GAAG,GAAG,KAAK;AACX,EAAE,MAAM,MAAM,GAAG,aAAa,KAAK,KAAK;AACxC,EAAE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,oBAAoB,CAAC;AACrD,IAAI,KAAK,EAAE,WAAW;AACtB,IAAI,YAAY,EAAE,cAAc,IAAI,KAAK;AACzC,IAAI,QAAQ,EAAE;AACd,GAAG,CAAC;AACJ,EAAE,MAAM,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC;AACxB,EAAE,MAAM,YAAY,GAAG,CAAC,KAAK,KAAK;AAClC,IAAI,QAAQ,GAAG,KAAK,CAAC;AACrB,IAAI,UAAU,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC;AAC3C,EAAE,CAAC;AACH,EAAE,uBAAuB,GAAG;AAC5B,IAAI,KAAK;AACT,IAAI;AACJ,MAAM,SAAS,EAAE,GAAG;AACpB,MAAM,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK;AACpC,MAAM,WAAW;AACjB,MAAM,KAAK;AACX,MAAM,SAAS;AACf,MAAM,KAAK;AACX,MAAM,QAAQ,kBAAkB,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE;AACvF,wBAAwB,GAAG;AAC3B,UAAU,OAAO;AACjB,UAAU;AACV,YAAY,GAAG,MAAM;AACrB,YAAY,GAAG,iBAAiB,CAAC,GAAG,EAAE,EAAkC,WAAW,EAAE,KAAK,EAAE,EAAE,MAAM,CAAC;AACrG,YAAY,GAAG;AACf,YAAY,IAAI,EAAE,UAAU;AAC5B,YAAY,IAAI,EAAE,QAAQ;AAC1B,YAAY,SAAS,EAAE,uBAAuB;AAC9C,YAAY,IAAI;AAChB,YAAY,OAAO;AACnB,YAAY,QAAQ;AACpB,YAAY,QAAQ,EAAE;AACtB;AACA,SAAS;AACT,wBAAwB,GAAG,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;AAC3E,QAAQ,MAAM,IAAI,KAAK,oBAAoB,GAAG,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,uBAAuB,EAAE,QAAQ,EAAE,KAAK,EAAE;AAC9G,OAAO,EAAE;AACT;AACA,GAAG;AACH,CAAC;AACD,MAAM,CAAC,WAAW,GAAG,QAAQ;;"}
1
+ {"version":3,"file":"Switch.js","sources":["../../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useUid, useControllableState } from '@/utils';\nimport { Field, fieldControlProps, type FieldBaseProps } from '../Field';\n\n/**\n * Every native `<input>` prop (`name`, `required`, `aria-*`, ...) is accepted and forwarded to the switch input, with the\n * ref. `className` and `style` go to the field's wrapper.\n */\nexport interface SwitchProps\n extends FieldBaseProps, Omit<React.ComponentPropsWithoutRef<'input'>, 'type' | 'className' | 'style'> {\n /** The HTML ID attribute to be applied to the switch element (optional). */\n id?: string;\n /** The name attribute to be applied to the switch element (optional). */\n name?: string;\n /** Whether the switch toggle should be disabled (optional). */\n disabled?: boolean;\n /** The checked state of the switch toggle, for a controlled switch (optional). */\n checked?: boolean;\n /** The default checked state of the switch toggle, for an uncontrolled switch (optional). */\n defaultChecked?: boolean;\n /** Called with the new state when the user toggles the switch. The native `onChange` gets the event. */\n onCheckedChange?(value: boolean): void;\n /**\n * Where the label goes: over the switch, as a field's label (`top`), or beside it (`end`), as a checkbox's, such as\n * in a list of settings.\n * @defaultValue 'top'\n */\n labelPosition?: 'top' | 'end';\n}\n\n/**\n * A toggle switch with a label, over it or beside it. Control it with checked and onCheckedChange, or leave it\n * uncontrolled with defaultChecked.\n */\nexport const Switch = React.forwardRef<HTMLInputElement, SwitchProps>((props, ref) => {\n const {\n id,\n label,\n name,\n disabled,\n checked: checkedProp,\n defaultChecked = false,\n description,\n keepDescription,\n error,\n className,\n style,\n onChange,\n onCheckedChange,\n labelPosition = 'top',\n ...others\n } = props;\n const beside = labelPosition === 'end';\n const [checked, setChecked] = useControllableState<boolean>({\n value: checkedProp,\n defaultValue: defaultChecked ?? false,\n onChange: onCheckedChange,\n });\n\n const uid = useUid(id);\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n setChecked(event.currentTarget.checked);\n };\n\n return (\n <Field\n controlId={uid}\n label={beside ? undefined : label}\n description={description}\n keepDescription={keepDescription}\n error={error}\n className={className}\n style={style}\n >\n {/* Its own label too, so a click on the toggle reaches the input; beside it, it holds the text. */}\n <label className=\"roaster-switch\">\n <input\n {...others}\n {...fieldControlProps(\n uid,\n { label: beside ? undefined : label, description, error, keepDescription },\n others\n )}\n ref={ref}\n type=\"checkbox\"\n role=\"switch\"\n className=\"roaster-switch__input\"\n name={name}\n checked={checked}\n disabled={disabled}\n onChange={handleChange}\n />\n <span className=\"roaster-switch__track\" />\n {beside && label && <span className=\"roaster-switch__label\">{label}</span>}\n </label>\n </Field>\n );\n});\n\nSwitch.displayName = 'Switch';\n"],"names":[],"mappings":";;;;;;;AAKY,MAAC,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AACvD,EAAE,MAAM;AACR,IAAI,EAAE;AACN,IAAI,KAAK;AACT,IAAI,IAAI;AACR,IAAI,QAAQ;AACZ,IAAI,OAAO,EAAE,WAAW;AACxB,IAAI,cAAc,GAAG,KAAK;AAC1B,IAAI,WAAW;AACf,IAAI,eAAe;AACnB,IAAI,KAAK;AACT,IAAI,SAAS;AACb,IAAI,KAAK;AACT,IAAI,QAAQ;AACZ,IAAI,eAAe;AACnB,IAAI,aAAa,GAAG,KAAK;AACzB,IAAI,GAAG;AACP,GAAG,GAAG,KAAK;AACX,EAAE,MAAM,MAAM,GAAG,aAAa,KAAK,KAAK;AACxC,EAAE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,oBAAoB,CAAC;AACrD,IAAI,KAAK,EAAE,WAAW;AACtB,IAAI,YAAY,EAAE,cAAc,IAAI,KAAK;AACzC,IAAI,QAAQ,EAAE;AACd,GAAG,CAAC;AACJ,EAAE,MAAM,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC;AACxB,EAAE,MAAM,YAAY,GAAG,CAAC,KAAK,KAAK;AAClC,IAAI,QAAQ,GAAG,KAAK,CAAC;AACrB,IAAI,UAAU,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC;AAC3C,EAAE,CAAC;AACH,EAAE,uBAAuB,GAAG;AAC5B,IAAI,KAAK;AACT,IAAI;AACJ,MAAM,SAAS,EAAE,GAAG;AACpB,MAAM,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK;AACpC,MAAM,WAAW;AACjB,MAAM,eAAe;AACrB,MAAM,KAAK;AACX,MAAM,SAAS;AACf,MAAM,KAAK;AACX,MAAM,QAAQ,kBAAkB,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE;AACvF,wBAAwB,GAAG;AAC3B,UAAU,OAAO;AACjB,UAAU;AACV,YAAY,GAAG,MAAM;AACrB,YAAY,GAAG,iBAAiB;AAChC,cAAc,GAAG;AACjB,cAAc,EAAkC,WAAW,EAAE,KAAK,EAAE,eAAe,EAAE;AACrF,cAAc;AACd,aAAa;AACb,YAAY,GAAG;AACf,YAAY,IAAI,EAAE,UAAU;AAC5B,YAAY,IAAI,EAAE,QAAQ;AAC1B,YAAY,SAAS,EAAE,uBAAuB;AAC9C,YAAY,IAAI;AAChB,YAAY,OAAO;AACnB,YAAY,QAAQ;AACpB,YAAY,QAAQ,EAAE;AACtB;AACA,SAAS;AACT,wBAAwB,GAAG,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;AAC3E,QAAQ,MAAM,IAAI,KAAK,oBAAoB,GAAG,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,uBAAuB,EAAE,QAAQ,EAAE,KAAK,EAAE;AAC9G,OAAO,EAAE;AACT;AACA,GAAG;AACH,CAAC;AACD,MAAM,CAAC,WAAW,GAAG,QAAQ;;"}
@@ -88,7 +88,10 @@ const TableBase = React.forwardRef((props, ref) => {
88
88
  ref,
89
89
  className: classNames("roaster-table__table", { "roaster-table__table--browsable": browsable }, className),
90
90
  children: [
91
- columns && /* @__PURE__ */ jsx("colgroup", { children: columns.map((width, index) => /* @__PURE__ */ jsx("col", { style: { width } }, index)) }),
91
+ columns && /* @__PURE__ */ jsx("colgroup", { children: columns.map((column, index) => {
92
+ const { width, priority } = typeof column === "object" ? column : { width: column, priority: void 0 };
93
+ return /* @__PURE__ */ jsx("col", { style: width === void 0 ? void 0 : { width }, "data-priority": priority }, index);
94
+ }) }),
92
95
  children
93
96
  ]
94
97
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Table.js","sources":["../../../../src/components/Table/Table.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Button } from '@/components/Button';\nimport { PaginationProps } from '@/components/Pagination';\n\nimport { Checkbox } from './components/Checkbox';\nimport { TableBody } from './components/TableBody';\nimport { TableGroup } from './components/TableGroup';\nimport { TableCell } from './components/TableCell';\nimport { TableHead } from './components/TableHead';\nimport { TableHeadCell, TableSortButton } from './components/TableHeadCell';\nimport { TablePagination, TablePaginationProps } from './components/TablePagination';\nimport { TableProvider } from './components/TableProvider';\nimport { TableRow } from './components/TableRow';\nimport { TableProviderProps, SELECT_ALL_ITEMS, useTableSelectionChange, useTableValue } from './utils/table';\nimport { defaultTableLabels, TableLabels, TableLabelsContext } from './labels';\n\nexport type { TableLabels } from './labels';\nimport { classNames } from '@/utils';\n\n/**\n * Every native `<table>` prop (`id`, `aria-*`, `className`...) is accepted and forwarded to the `<table>`, but the\n * obsolete `summary`.\n */\nexport interface NativeTableProps extends Omit<React.ComponentPropsWithoutRef<'table'>, 'summary'> {\n /** The table content: Table.Head and Table.Body. */\n children?: React.ReactNode;\n /**\n * Whether rows can be selected, with a checkbox column and a bulk-action bar.\n * @defaultValue false\n */\n selectable?: boolean;\n /**\n * Whether rows lead somewhere: they react to the pointer.\n * @defaultValue false\n */\n browsable?: boolean;\n /** The actions to be displayed when a row in the table is selected (optional). */\n selectActions?: React.ReactNode;\n /** The text of the table, in English by default. */\n labels?: Partial<TableLabels>;\n /**\n * The columns' widths, in order, in pixels or any CSS length: kept exactly, the table scrolling sideways when they\n * add up to more than its width.\n */\n columns?: (number | string)[];\n /** Reaches the edges of a full-width page, its rows from edge to edge. */\n bleed?: boolean;\n /** Shorter rows, such as a short list in a card. */\n compact?: boolean;\n /** Keeps the column titles in view: the rows scroll under them, in a box no taller than the window. */\n sticky?: boolean;\n /** Floats the bulk-action bar low in the window, in the middle of the content; the column titles stay. */\n floatingActions?: boolean;\n /** Draws a row's fill (hovered, pressed, open or checked) inset from the table's sides, with rounded ends. */\n insetRows?: boolean;\n /** More room above and below each row's cells, such as rows of two lines (a name and its description). */\n roomy?: boolean;\n /** Over the table: its filters, sorting and actions. */\n toolbar?: React.ReactNode;\n /** A band over the rows, such as totals (`StatCard.Group variant=\"compact\"`), with an action at its end. */\n summary?: React.ReactNode;\n}\n\n/**\n * This interface defines the props that can be passed to a table component that includes pagination.\n * It extends the `NativeTableProps` interface, and includes additional props related to pagination.\n */\ninterface TableBaseWithPagination extends NativeTableProps, Omit<TablePaginationProps, keyof PaginationProps> {\n /** A boolean indicating whether pagination should be displayed (required). */\n showPagination: true;\n /** A function that is called when the \"Next\" button is clicked (required). */\n onNextPage: () => void;\n /** A function that is called when the \"Previous\" button is clicked (required). */\n onPreviousPage: () => void;\n /** A boolean indicating whether there is a next page (required). */\n hasNextPage: boolean;\n /** A boolean indicating whether there is a previous page (required). */\n hasPreviousPage: boolean;\n /** CSS class names to be applied to the pagination element (optional). */\n paginationClassName?: string;\n /** Before the pagination's buttons, such as the number of rows (\"312 transactions\"). */\n count?: React.ReactNode;\n}\n\n/**\n * This interface defines the props that can be passed to a table component that does not include pagination.\n * It extends the `NativeTableProps` interface, and does not include any additional props.\n */\ninterface TableBaseWithoutPagination extends NativeTableProps {\n /** A boolean indicating whether pagination should be displayed (optional). */\n showPagination?: never;\n /** A function that is called when the \"Next\" button is clicked (optional). */\n onNextPage?: never;\n /** A function that is called when the \"Previous\" button is clicked (optional). */\n onPreviousPage?: never;\n /** A boolean indicating whether there is a next page (optional). */\n hasNextPage?: never;\n /** A boolean indicating whether there is a previous page (optional). */\n hasPreviousPage?: never;\n /** CSS class names to be applied to the pagination element (optional). */\n paginationClassName?: never;\n count?: never;\n}\n\n/**\n * This type defines the props that can be passed to a table component.\n * It includes the `TableBaseWithPagination` and `TableBaseWithoutPagination` interfaces,\n * and ensures that only one set of props is used at a time.\n */\nexport type TableBaseProps = TableBaseWithPagination | TableBaseWithoutPagination;\n\nconst TableBase = React.forwardRef<HTMLTableElement, TableBaseProps>((props, ref) => {\n const {\n children,\n showPagination,\n selectActions,\n browsable = false,\n labels,\n className,\n onNextPage,\n onPreviousPage,\n hasNextPage,\n hasPreviousPage,\n paginationClassName,\n count,\n columns,\n bleed = false,\n compact = false,\n sticky = false,\n floatingActions = false,\n insetRows = false,\n roomy = false,\n toolbar,\n summary,\n ...others\n } = props;\n const text = { ...defaultTableLabels, ...labels };\n const { bulkSelectState, itemCount, selectedItemsCount } = useTableValue();\n const handleSelectionChange = useTableSelectionChange();\n\n const handleSelectAllItems = React.useCallback(() => {\n handleSelectionChange(selectedItemsCount === SELECT_ALL_ITEMS ? 'page' : 'all');\n }, [handleSelectionChange, selectedItemsCount]);\n\n const handleTogglePage = React.useCallback(() => {\n handleSelectionChange('page');\n }, [handleSelectionChange]);\n\n return (\n <TableLabelsContext.Provider value={text}>\n <section\n className={classNames('roaster-table', {\n 'roaster-table--bleed': bleed,\n 'roaster-table--compact': compact,\n 'roaster-table--sticky': sticky,\n 'roaster-table--floating-actions': floatingActions,\n 'roaster-table--inset-rows': insetRows,\n 'roaster-table--roomy': roomy,\n })}\n >\n {toolbar != null && <section className=\"roaster-table-toolbar\">{toolbar}</section>}\n {summary != null && <div className=\"roaster-table__summary\">{summary}</div>}\n {bulkSelectState && (\n // data-state: shown even before the rows' checkboxes are (the CSS shows the bar from them too).\n <div className=\"roaster-table__bulk-actions\" data-state=\"open\">\n <div className=\"roaster-stack roaster-stack--spread\" style={{ alignItems: 'center' }}>\n <div className=\"roaster-stack\">\n <Checkbox\n onChange={() => handleTogglePage()}\n indeterminate={selectedItemsCount !== SELECT_ALL_ITEMS && selectedItemsCount < itemCount}\n checked\n label={\n <span className=\"roaster-table__selected-count\">{text.selectedCount(selectedItemsCount)}</span>\n }\n />\n {selectActions}\n </div>\n\n <div className=\"action\">\n <Button variant=\"plain\" onClick={() => handleSelectAllItems()}>\n {text.selectAll}\n </Button>\n </div>\n </div>\n </div>\n )}\n <div className=\"roaster-table__scroll\">\n <table\n {...others}\n ref={ref}\n className={classNames('roaster-table__table', { 'roaster-table__table--browsable': browsable }, className)}\n >\n {columns && (\n <colgroup>\n {columns.map((width, index) => (\n <col key={index} style={{ width }} />\n ))}\n </colgroup>\n )}\n {children}\n </table>\n </div>\n {showPagination && (\n <TablePagination\n hasNextPage={hasNextPage}\n hasPreviousPage={hasPreviousPage}\n onNextPage={onNextPage}\n onPreviousPage={onPreviousPage}\n className={paginationClassName}\n count={count}\n labels={{ previousPage: text.previousPage, nextPage: text.nextPage }}\n />\n )}\n </section>\n </TableLabelsContext.Provider>\n );\n});\n\nTableBase.displayName = 'TableBase';\n\nexport type TableProps = TableBaseProps & TableProviderProps;\n\n/**\n * A data table with typed columns, optional row selection (a checkbox column, and a bulk-action bar in place of the\n * column titles while rows are selected), and pagination. Compose it with Table.Head, HeadCell, Body, Row and Cell\n * (Table.Group in place of Body for rows in groups, each under a title row); a\n * sortable column's title is a Table.SortButton, such as the trigger of a menu of sort orders. In a currency cell, the\n * cents can go in a `<sup>`; an enum cell can start with an `Icon`.\n */\nexport function Table({\n children,\n selectable = false,\n itemCount,\n selectedItemsCount = 0,\n onSelectionChange,\n ...tableBaseProps\n}: TableProps) {\n return (\n <TableProvider\n selectable={selectable}\n itemCount={itemCount}\n selectedItemsCount={selectedItemsCount}\n onSelectionChange={onSelectionChange}\n >\n <TableBase {...tableBaseProps}>{children}</TableBase>\n </TableProvider>\n );\n}\n\nTable.displayName = 'Table';\n\nTable.Head = TableHead;\nTable.Body = TableBody;\nTable.Group = TableGroup;\nTable.Row = TableRow;\nTable.HeadCell = TableHeadCell;\nTable.Cell = TableCell;\nTable.SortButton = TableSortButton;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAgBA,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AACnD,EAAE,MAAM;AACR,IAAI,QAAQ;A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AAC;AACtB,EAAE,QAAQ;AACV,EAAE,UAAU,GAAG,KAAK;AACpB,EAAE,SAAS;AACX,EAAE,kBAAkB,GAAG,CAAC;AACxB,EAAE,iBAAiB;AACnB,EAAE,GAAG;AACL,CAAC,EAAE;AACH,EAAE,uBAAuB,GAAG;AAC5B,IAAI,aAAa;AACjB,IAAI;AACJ,MAAM,UAAU;AAChB,MAAM,SAAS;AACf,MAAM,kBAAkB;AACxB,MAAM,iBAAiB;AACvB,MAAM,QAAQ,kBAAkB,GAAG,CAAC,SAAS,EAAE,EAAE,GAAG,cAAc,EAAE,QAAQ,EAAE;AAC9E;AACA,GAAG;AACH;AACA,KAAK,CAAC,WAAW,GAAG,OAAO;AAC3B,KAAK,CAAC,IAAI,GAAG,SAAS;AACtB,KAAK,CAAC,IAAI,GAAG,SAAS;AACtB,KAAK,CAAC,KAAK,GAAG,UAAU;AACxB,KAAK,CAAC,GAAG,GAAG,QAAQ;AACpB,KAAK,CAAC,QAAQ,GAAG,aAAa;AAC9B,KAAK,CAAC,IAAI,GAAG,SAAS;AACtB,KAAK,CAAC,UAAU,GAAG,eAAe;;"}
1
+ {"version":3,"file":"Table.js","sources":["../../../../src/components/Table/Table.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Button } from '@/components/Button';\nimport { PaginationProps } from '@/components/Pagination';\n\nimport { Checkbox } from './components/Checkbox';\nimport { TableBody } from './components/TableBody';\nimport { TableGroup } from './components/TableGroup';\nimport { TableCell } from './components/TableCell';\nimport { TableHead } from './components/TableHead';\nimport { TableHeadCell, TableSortButton } from './components/TableHeadCell';\nimport { TablePagination, TablePaginationProps } from './components/TablePagination';\nimport { TableProvider } from './components/TableProvider';\nimport { TableRow } from './components/TableRow';\nimport type { TableColumn } from './Table.types';\nimport { TableProviderProps, SELECT_ALL_ITEMS, useTableSelectionChange, useTableValue } from './utils/table';\nimport { defaultTableLabels, TableLabels, TableLabelsContext } from './labels';\n\nexport type { TableLabels } from './labels';\nimport { classNames } from '@/utils';\n\n/**\n * Every native `<table>` prop (`id`, `aria-*`, `className`...) is accepted and forwarded to the `<table>`, but the\n * obsolete `summary`.\n */\nexport interface NativeTableProps extends Omit<React.ComponentPropsWithoutRef<'table'>, 'summary'> {\n /** The table content: Table.Head and Table.Body. */\n children?: React.ReactNode;\n /**\n * Whether rows can be selected, with a checkbox column and a bulk-action bar.\n * @defaultValue false\n */\n selectable?: boolean;\n /**\n * Whether rows lead somewhere: they react to the pointer.\n * @defaultValue false\n */\n browsable?: boolean;\n /** The actions to be displayed when a row in the table is selected (optional). */\n selectActions?: React.ReactNode;\n /** The text of the table, in English by default. */\n labels?: Partial<TableLabels>;\n /**\n * The columns' widths, in order, in pixels or any CSS length: kept exactly, the table scrolling sideways when they\n * add up to more than its width. With a selection column, the first is its own. A column can be `{ width, priority }`:\n * `priority: 'secondary'` hides it on a phone (its cells take the same `priority`).\n */\n columns?: (number | string | TableColumn)[];\n /** Reaches the edges of a full-width page, its rows from edge to edge. */\n bleed?: boolean;\n /** Shorter rows, such as a short list in a card. */\n compact?: boolean;\n /** Keeps the column titles in view: the rows scroll under them, in a box no taller than the window. */\n sticky?: boolean;\n /** Floats the bulk-action bar low in the window, in the middle of the content; the column titles stay. */\n floatingActions?: boolean;\n /** Draws a row's fill (hovered, pressed, open or checked) inset from the table's sides, with rounded ends. */\n insetRows?: boolean;\n /** More room above and below each row's cells, such as rows of two lines (a name and its description). */\n roomy?: boolean;\n /** Over the table: its filters, sorting and actions. */\n toolbar?: React.ReactNode;\n /** A band over the rows, such as totals (`StatCard.Group variant=\"compact\"`), with an action at its end. */\n summary?: React.ReactNode;\n}\n\n/**\n * This interface defines the props that can be passed to a table component that includes pagination.\n * It extends the `NativeTableProps` interface, and includes additional props related to pagination.\n */\ninterface TableBaseWithPagination extends NativeTableProps, Omit<TablePaginationProps, keyof PaginationProps> {\n /** A boolean indicating whether pagination should be displayed (required). */\n showPagination: true;\n /** A function that is called when the \"Next\" button is clicked (required). */\n onNextPage: () => void;\n /** A function that is called when the \"Previous\" button is clicked (required). */\n onPreviousPage: () => void;\n /** A boolean indicating whether there is a next page (required). */\n hasNextPage: boolean;\n /** A boolean indicating whether there is a previous page (required). */\n hasPreviousPage: boolean;\n /** CSS class names to be applied to the pagination element (optional). */\n paginationClassName?: string;\n /** Before the pagination's buttons, such as the number of rows (\"312 transactions\"). */\n count?: React.ReactNode;\n}\n\n/**\n * This interface defines the props that can be passed to a table component that does not include pagination.\n * It extends the `NativeTableProps` interface, and does not include any additional props.\n */\ninterface TableBaseWithoutPagination extends NativeTableProps {\n /** A boolean indicating whether pagination should be displayed (optional). */\n showPagination?: never;\n /** A function that is called when the \"Next\" button is clicked (optional). */\n onNextPage?: never;\n /** A function that is called when the \"Previous\" button is clicked (optional). */\n onPreviousPage?: never;\n /** A boolean indicating whether there is a next page (optional). */\n hasNextPage?: never;\n /** A boolean indicating whether there is a previous page (optional). */\n hasPreviousPage?: never;\n /** CSS class names to be applied to the pagination element (optional). */\n paginationClassName?: never;\n count?: never;\n}\n\n/**\n * This type defines the props that can be passed to a table component.\n * It includes the `TableBaseWithPagination` and `TableBaseWithoutPagination` interfaces,\n * and ensures that only one set of props is used at a time.\n */\nexport type TableBaseProps = TableBaseWithPagination | TableBaseWithoutPagination;\n\nconst TableBase = React.forwardRef<HTMLTableElement, TableBaseProps>((props, ref) => {\n const {\n children,\n showPagination,\n selectActions,\n browsable = false,\n labels,\n className,\n onNextPage,\n onPreviousPage,\n hasNextPage,\n hasPreviousPage,\n paginationClassName,\n count,\n columns,\n bleed = false,\n compact = false,\n sticky = false,\n floatingActions = false,\n insetRows = false,\n roomy = false,\n toolbar,\n summary,\n ...others\n } = props;\n const text = { ...defaultTableLabels, ...labels };\n const { bulkSelectState, itemCount, selectedItemsCount } = useTableValue();\n const handleSelectionChange = useTableSelectionChange();\n\n const handleSelectAllItems = React.useCallback(() => {\n handleSelectionChange(selectedItemsCount === SELECT_ALL_ITEMS ? 'page' : 'all');\n }, [handleSelectionChange, selectedItemsCount]);\n\n const handleTogglePage = React.useCallback(() => {\n handleSelectionChange('page');\n }, [handleSelectionChange]);\n\n return (\n <TableLabelsContext.Provider value={text}>\n <section\n className={classNames('roaster-table', {\n 'roaster-table--bleed': bleed,\n 'roaster-table--compact': compact,\n 'roaster-table--sticky': sticky,\n 'roaster-table--floating-actions': floatingActions,\n 'roaster-table--inset-rows': insetRows,\n 'roaster-table--roomy': roomy,\n })}\n >\n {toolbar != null && <section className=\"roaster-table-toolbar\">{toolbar}</section>}\n {summary != null && <div className=\"roaster-table__summary\">{summary}</div>}\n {bulkSelectState && (\n // data-state: shown even before the rows' checkboxes are (the CSS shows the bar from them too).\n <div className=\"roaster-table__bulk-actions\" data-state=\"open\">\n <div className=\"roaster-stack roaster-stack--spread\" style={{ alignItems: 'center' }}>\n <div className=\"roaster-stack\">\n <Checkbox\n onChange={() => handleTogglePage()}\n indeterminate={selectedItemsCount !== SELECT_ALL_ITEMS && selectedItemsCount < itemCount}\n checked\n label={\n <span className=\"roaster-table__selected-count\">{text.selectedCount(selectedItemsCount)}</span>\n }\n />\n {selectActions}\n </div>\n\n <div className=\"action\">\n <Button variant=\"plain\" onClick={() => handleSelectAllItems()}>\n {text.selectAll}\n </Button>\n </div>\n </div>\n </div>\n )}\n <div className=\"roaster-table__scroll\">\n <table\n {...others}\n ref={ref}\n className={classNames('roaster-table__table', { 'roaster-table__table--browsable': browsable }, className)}\n >\n {columns && (\n <colgroup>\n {columns.map((column, index) => {\n const { width, priority } =\n typeof column === 'object' ? column : { width: column, priority: undefined };\n return (\n <col key={index} style={width === undefined ? undefined : { width }} data-priority={priority} />\n );\n })}\n </colgroup>\n )}\n {children}\n </table>\n </div>\n {showPagination && (\n <TablePagination\n hasNextPage={hasNextPage}\n hasPreviousPage={hasPreviousPage}\n onNextPage={onNextPage}\n onPreviousPage={onPreviousPage}\n className={paginationClassName}\n count={count}\n labels={{ previousPage: text.previousPage, nextPage: text.nextPage }}\n />\n )}\n </section>\n </TableLabelsContext.Provider>\n );\n});\n\nTableBase.displayName = 'TableBase';\n\nexport type TableProps = TableBaseProps & TableProviderProps;\n\n/**\n * A data table with typed columns, optional row selection (a checkbox column, and a bulk-action bar in place of the\n * column titles while rows are selected), and pagination. Compose it with Table.Head, HeadCell, Body, Row and Cell\n * (Table.Group in place of Body for rows in groups, each under a title row); a\n * sortable column's title is a Table.SortButton, such as the trigger of a menu of sort orders. In a currency cell, the\n * cents can go in a `<sup>`; an enum cell can start with an `Icon`.\n */\nexport function Table({\n children,\n selectable = false,\n itemCount,\n selectedItemsCount = 0,\n onSelectionChange,\n ...tableBaseProps\n}: TableProps) {\n return (\n <TableProvider\n selectable={selectable}\n itemCount={itemCount}\n selectedItemsCount={selectedItemsCount}\n onSelectionChange={onSelectionChange}\n >\n <TableBase {...tableBaseProps}>{children}</TableBase>\n </TableProvider>\n );\n}\n\nTable.displayName = 'Table';\n\nTable.Head = TableHead;\nTable.Body = TableBody;\nTable.Group = TableGroup;\nTable.Row = TableRow;\nTable.HeadCell = TableHeadCell;\nTable.Cell = TableCell;\nTable.SortButton = TableSortButton;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAgBA,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AACnD,EAAE,MAAM;AACR,IAAI,QAAQ;AACZ,IAAI,cAAc;AAClB,IAAI,aAAa;AACjB,IAAI,SAAS,GAAG,KAAK;AACrB,IAAI,MAAM;AACV,IAAI,SAAS;AACb,IAAI,UAAU;AACd,IAAI,cAAc;AAClB,IAAI,WAAW;AACf,IAAI,eAAe;AACnB,IAAI,mBAAmB;AACvB,IAAI,KAAK;AACT,IAAI,OAAO;AACX,IAAI,KAAK,GAAG,KAAK;AACjB,IAAI,OAAO,GAAG,KAAK;AACnB,IAAI,MAAM,GAAG,KAAK;AAClB,IAAI,eAAe,GAAG,KAAK;AAC3B,IAAI,SAAS,GAAG,KAAK;AACrB,IAAI,KAAK,GAAG,KAAK;A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,EAAE;AACH,EAAE,uBAAuB,GAAG;AAC5B,IAAI,aAAa;AACjB,IAAI;AACJ,MAAM,UAAU;AAChB,MAAM,SAAS;AACf,MAAM,kBAAkB;AACxB,MAAM,iBAAiB;AACvB,MAAM,QAAQ,kBAAkB,GAAG,CAAC,SAAS,EAAE,EAAE,GAAG,cAAc,EAAE,QAAQ,EAAE;AAC9E;AACA,GAAG;AACH;AACA,KAAK,CAAC,WAAW,GAAG,OAAO;AAC3B,KAAK,CAAC,IAAI,GAAG,SAAS;AACtB,KAAK,CAAC,IAAI,GAAG,SAAS;AACtB,KAAK,CAAC,KAAK,GAAG,UAAU;AACxB,KAAK,CAAC,GAAG,GAAG,QAAQ;AACpB,KAAK,CAAC,QAAQ,GAAG,aAAa;AAC9B,KAAK,CAAC,IAAI,GAAG,SAAS;AACtB,KAAK,CAAC,UAAU,GAAG,eAAe;;"}
@@ -2,7 +2,9 @@
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
  import * as React from 'react';
4
4
 
5
- const TableCell = React.forwardRef(({ children, type, ...props }, ref) => /* @__PURE__ */ jsx("td", { ...props, ref, "data-type": type, children: type === "paragraph" ? /* @__PURE__ */ jsx("p", { children }) : children }));
5
+ const TableCell = React.forwardRef(
6
+ ({ children, type, priority, ...props }, ref) => /* @__PURE__ */ jsx("td", { ...props, ref, "data-type": type, "data-priority": priority, children: type === "paragraph" ? /* @__PURE__ */ jsx("p", { children }) : children })
7
+ );
6
8
  TableCell.displayName = "TableCell";
7
9
 
8
10
  export { TableCell };
@@ -1 +1 @@
1
- {"version":3,"file":"TableCell.js","sources":["../../../../../src/components/Table/components/TableCell.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { TableDataType } from '../Table.types';\n\n/** Every native `<td>` prop is accepted and forwarded to it. */\nexport interface TableCellProps extends React.ComponentPropsWithoutRef<'td'> {\n /** The column's kind of data, which aligns and wraps the cell (`data-type`). */\n type: TableDataType;\n /** The value. A `paragraph` is clamped to four lines. */\n children?: React.ReactNode;\n}\n\n/** A cell, typed by its column's kind of data. */\nexport const TableCell = React.forwardRef<HTMLTableCellElement, TableCellProps>(({ children, type, ...props }, ref) => (\n <td {...props} ref={ref} data-type={type}>\n {type === 'paragraph' ? <p>{children}</p> : children}\n </td>\n));\nTableCell.displayName = 'TableCell';\n"],"names":[],"mappings":";;;;AAGY,MAAC,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,qBAAqB,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,KAAK,WAAW,mBAAmB,GAAG,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC;AACpO,SAAS,CAAC,WAAW,GAAG,WAAW;;"}
1
+ {"version":3,"file":"TableCell.js","sources":["../../../../../src/components/Table/components/TableCell.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { TableColumnPriority, TableDataType } from '../Table.types';\n\n/** Every native `<td>` prop is accepted and forwarded to it. */\nexport interface TableCellProps extends React.ComponentPropsWithoutRef<'td'> {\n /** The column's kind of data, which aligns and wraps the cell (`data-type`). */\n type: TableDataType;\n /** The value. A `paragraph` is clamped to four lines. */\n children?: React.ReactNode;\n /** `secondary`: hidden on a phone, with its column (give the column the same priority in `Table`'s `columns`). */\n priority?: TableColumnPriority;\n}\n\n/** A cell, typed by its column's kind of data. */\nexport const TableCell = React.forwardRef<HTMLTableCellElement, TableCellProps>(\n ({ children, type, priority, ...props }, ref) => (\n <td {...props} ref={ref} data-type={type} data-priority={priority}>\n {type === 'paragraph' ? <p>{children}</p> : children}\n </td>\n )\n);\nTableCell.displayName = 'TableCell';\n"],"names":[],"mappings":";;;;AAGY,MAAC,SAAS,GAAG,KAAK,CAAC,UAAU;AACzC,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,qBAAqB,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,KAAK,WAAW,mBAAmB,GAAG,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,CAAC,GAAG,QAAQ,EAAE;AAChO;AACA,SAAS,CAAC,WAAW,GAAG,WAAW;;"}
@@ -7,9 +7,9 @@ import { TableLabelsContext } from '../labels.js';
7
7
  import { classNames } from '../../../utils/classNames/index.js';
8
8
 
9
9
  const TableHeadCell = React.forwardRef(
10
- ({ title, type, description, tooltipProps, sort, children, ...props }, ref) => {
10
+ ({ title, type, description, tooltipProps, sort, priority, children, ...props }, ref) => {
11
11
  const text = React.useContext(TableLabelsContext);
12
- return /* @__PURE__ */ jsx("th", { ...props, ref, "data-type": type, "aria-sort": sort, children: /* @__PURE__ */ jsxs(SortContext.Provider, { value: sort, children: [
12
+ return /* @__PURE__ */ jsx("th", { ...props, ref, "data-type": type, "data-priority": priority, "aria-sort": sort, children: /* @__PURE__ */ jsxs(SortContext.Provider, { value: sort, children: [
13
13
  title,
14
14
  children,
15
15
  description && " ",
@@ -1 +1 @@
1
- {"version":3,"file":"TableHeadCell.js","sources":["../../../../../src/components/Table/components/TableHeadCell.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Tooltip, TooltipProps } from '@/components/Tooltip';\nimport { Icon } from '@/components/Icon';\nimport type { TableDataType } from '../Table.types';\nimport { TableLabelsContext } from '../labels';\nimport { classNames } from '@/utils';\n\n/** Every native `<th>` prop is accepted and forwarded to it. */\nexport interface TableHeadCellBaseProps extends Omit<React.ComponentPropsWithoutRef<'th'>, 'title'> {\n /** The column's kind of data, which aligns its cells (`data-type`). */\n type: TableDataType;\n /** What the column means, in a tooltip on an info button after the title. */\n description?: React.ReactNode;\n /** The tooltip's other props, such as `placement`. */\n tooltipProps?: Omit<TooltipProps, 'children' | 'label'>;\n /** How the column sorts the rows (`aria-sort`), with an arrow after its Table.SortButton's title. */\n sort?: 'ascending' | 'descending';\n}\n\nexport interface TableHeadCellPropsWithChildren extends TableHeadCellBaseProps {\n /** The title of the column. */\n children?: React.ReactNode;\n title?: never;\n}\n\nexport interface TableHeadCellPropsWithTitle extends TableHeadCellBaseProps {\n children?: never;\n /** The title of the column. */\n title?: React.ReactNode;\n}\n\nexport type TableHeadCellProps = TableHeadCellPropsWithChildren | TableHeadCellPropsWithTitle;\n\n/** A column title, with an optional info button that shows the column's description. */\nexport const TableHeadCell = React.forwardRef<HTMLTableCellElement, TableHeadCellProps>(\n ({ title, type, description, tooltipProps, sort, children, ...props }, ref) => {\n const text = React.useContext(TableLabelsContext);\n return (\n <th {...props} ref={ref} data-type={type} aria-sort={sort}>\n <SortContext.Provider value={sort}>\n {title}\n {children}\n {description && ' '}\n {description && (\n <Tooltip placement=\"bottom\" {...tooltipProps} label={description}>\n <button className=\"roaster-table__info\" type=\"button\" aria-label={text.columnInfo}>\n <Icon name=\"circle-info\" />\n </button>\n </Tooltip>\n )}\n </SortContext.Provider>\n </th>\n );\n }\n);\n\nTableHeadCell.displayName = 'TableHeadCell';\n\nconst SortContext = React.createContext<TableHeadCellBaseProps['sort']>(undefined);\n\n/** Every native `<button>` prop is accepted and forwarded to it. */\nexport interface TableSortButtonProps extends React.ComponentPropsWithoutRef<'button'> {\n /** The column's title. */\n children: React.ReactNode;\n}\n\n/**\n * A sortable column's title, as a button: it sorts the rows, or opens a menu of sort orders (in ActionList.Trigger).\n * The column's `sort` adds its arrow.\n */\nexport const TableSortButton = React.forwardRef<HTMLButtonElement, TableSortButtonProps>(\n ({ children, className, type = 'button', ...props }, ref) => {\n const sort = React.useContext(SortContext);\n return (\n <button {...props} ref={ref} type={type} className={classNames('roaster-table__sort', className)}>\n {children}\n {sort && <Icon name={sort === 'ascending' ? 'arrow-up' : 'arrow-down'} />}\n </button>\n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AE,EAAE,GAAG,KAAK;AAC/D,IAAI,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC;AAC9C,IAAI,uBAAuB,IAAI,CAAC,QAAQ,EAAE,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,CAAC,qBAAqB,EAAE,SAAS,CAAC,EAAE,QAAQ,EAAE;AACpI,MAAM,QAAQ;AACd,MAAM,IAAI,oBAAoB,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,KAAK,WAAW,GAAG,UAAU,GAAG,YAAY,EAAE;AAClG,KAAK,EAAE,CAAC;AACR,EAAE;AACF;AACA,eAAe,CAAC,WAAW,GAAG,iBAAiB;;"}
1
+ {"version":3,"file":"TableHeadCell.js","sources":["../../../../../src/components/Table/components/TableHeadCell.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Tooltip, TooltipProps } from '@/components/Tooltip';\nimport { Icon } from '@/components/Icon';\nimport type { TableColumnPriority, TableDataType } from '../Table.types';\nimport { TableLabelsContext } from '../labels';\nimport { classNames } from '@/utils';\n\n/** Every native `<th>` prop is accepted and forwarded to it. */\nexport interface TableHeadCellBaseProps extends Omit<React.ComponentPropsWithoutRef<'th'>, 'title'> {\n /** The column's kind of data, which aligns its cells (`data-type`). */\n type: TableDataType;\n /** What the column means, in a tooltip on an info button after the title. */\n description?: React.ReactNode;\n /** The tooltip's other props, such as `placement`. */\n tooltipProps?: Omit<TooltipProps, 'children' | 'label'>;\n /** How the column sorts the rows (`aria-sort`), with an arrow after its Table.SortButton's title. */\n sort?: 'ascending' | 'descending';\n /** `secondary`: hidden on a phone, with its column (give the column the same priority in `Table`'s `columns`). */\n priority?: TableColumnPriority;\n}\n\nexport interface TableHeadCellPropsWithChildren extends TableHeadCellBaseProps {\n /** The title of the column. */\n children?: React.ReactNode;\n title?: never;\n}\n\nexport interface TableHeadCellPropsWithTitle extends TableHeadCellBaseProps {\n children?: never;\n /** The title of the column. */\n title?: React.ReactNode;\n}\n\nexport type TableHeadCellProps = TableHeadCellPropsWithChildren | TableHeadCellPropsWithTitle;\n\n/** A column title, with an optional info button that shows the column's description. */\nexport const TableHeadCell = React.forwardRef<HTMLTableCellElement, TableHeadCellProps>(\n ({ title, type, description, tooltipProps, sort, priority, children, ...props }, ref) => {\n const text = React.useContext(TableLabelsContext);\n return (\n <th {...props} ref={ref} data-type={type} data-priority={priority} aria-sort={sort}>\n <SortContext.Provider value={sort}>\n {title}\n {children}\n {description && ' '}\n {description && (\n <Tooltip placement=\"bottom\" {...tooltipProps} label={description}>\n <button className=\"roaster-table__info\" type=\"button\" aria-label={text.columnInfo}>\n <Icon name=\"circle-info\" />\n </button>\n </Tooltip>\n )}\n </SortContext.Provider>\n </th>\n );\n }\n);\n\nTableHeadCell.displayName = 'TableHeadCell';\n\nconst SortContext = React.createContext<TableHeadCellBaseProps['sort']>(undefined);\n\n/** Every native `<button>` prop is accepted and forwarded to it. */\nexport interface TableSortButtonProps extends React.ComponentPropsWithoutRef<'button'> {\n /** The column's title. */\n children: React.ReactNode;\n}\n\n/**\n * A sortable column's title, as a button: it sorts the rows, or opens a menu of sort orders (in ActionList.Trigger).\n * The column's `sort` adds its arrow.\n */\nexport const TableSortButton = React.forwardRef<HTMLButtonElement, TableSortButtonProps>(\n ({ children, className, type = 'button', ...props }, ref) => {\n const sort = React.useContext(SortContext);\n return (\n <button {...props} ref={ref} type={type} className={classNames('roaster-table__sort', className)}>\n {children}\n {sort && <Icon name={sort === 'ascending' ? 'arrow-up' : 'arrow-down'} />}\n </button>\n );\n }\n);\nTableSortButton.displayName = 'TableSortButton';\n"],"names":[],"mappings":";;;;;;;;AAOY,MAAC,aAAa,GAAG,KAAK,CAAC,UAAU;AAC7C,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,K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qBAAqB,EAAE,SAAS,CAAC,EAAE,QAAQ,EAAE;AACpI,MAAM,QAAQ;AACd,MAAM,IAAI,oBAAoB,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,KAAK,WAAW,GAAG,UAAU,GAAG,YAAY,EAAE;AAClG,KAAK,EAAE,CAAC;AACR,EAAE;AACF;AACA,eAAe,CAAC,WAAW,GAAG,iBAAiB;;"}
@@ -16,6 +16,7 @@ const TextField = React.forwardRef((props, ref) => {
16
16
  onChange,
17
17
  onValueChange,
18
18
  description,
19
+ keepDescription,
19
20
  rightSection,
20
21
  type = "text",
21
22
  variant,
@@ -34,7 +35,7 @@ const TextField = React.forwardRef((props, ref) => {
34
35
  "input",
35
36
  {
36
37
  ...others,
37
- ...fieldControlProps(uid, { description, error }, others),
38
+ ...fieldControlProps(uid, { description, error, keepDescription }, others),
38
39
  ref,
39
40
  type,
40
41
  onChange: handleChange,
@@ -56,6 +57,7 @@ const TextField = React.forwardRef((props, ref) => {
56
57
  controlId: uid,
57
58
  label,
58
59
  description,
60
+ keepDescription,
59
61
  error,
60
62
  inline,
61
63
  className,