@trellixio/roaster-react 2.1.1 → 2.2.0

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 (204) hide show
  1. package/CHANGELOG.md +383 -0
  2. package/LICENSE.md +38 -2
  3. package/README.md +10 -10
  4. package/cjs/components/ActionList/components/ActionListDropdown.js +6 -5
  5. package/cjs/components/ActionList/components/ActionListDropdown.js.map +1 -1
  6. package/cjs/components/ActionList/components/ActionListItem.js +9 -7
  7. package/cjs/components/ActionList/components/ActionListItem.js.map +1 -1
  8. package/cjs/components/ActionList/components/ActionListSearch.js +24 -6
  9. package/cjs/components/ActionList/components/ActionListSearch.js.map +1 -1
  10. package/cjs/components/ActionList/components/ActionListSubmenu.js +7 -5
  11. package/cjs/components/ActionList/components/ActionListSubmenu.js.map +1 -1
  12. package/cjs/components/ActionList/components/ActionListSwitchItem.js +6 -5
  13. package/cjs/components/ActionList/components/ActionListSwitchItem.js.map +1 -1
  14. package/cjs/components/Alert/Alert.js +3 -2
  15. package/cjs/components/Alert/Alert.js.map +1 -1
  16. package/cjs/components/AppFrame/AppFrame.js.map +1 -1
  17. package/cjs/components/Avatar/Avatar.js +1 -1
  18. package/cjs/components/Avatar/Avatar.js.map +1 -1
  19. package/cjs/components/Button/Button.js +3 -2
  20. package/cjs/components/Button/Button.js.map +1 -1
  21. package/cjs/components/ButtonIcon/ButtonIcon.js.map +1 -1
  22. package/cjs/components/Checkbox/Checkbox.js +4 -4
  23. package/cjs/components/Checkbox/Checkbox.js.map +1 -1
  24. package/cjs/components/ColorField/ColorField.js +42 -29
  25. package/cjs/components/ColorField/ColorField.js.map +1 -1
  26. package/cjs/components/DatePicker/DatePicker.js +2 -2
  27. package/cjs/components/DatePicker/DatePicker.js.map +1 -1
  28. package/cjs/components/DatePicker/components/Calendar/Calendar.js +4 -3
  29. package/cjs/components/DatePicker/components/Calendar/Calendar.js.map +1 -1
  30. package/cjs/components/DropdownCard/components/DropdownCardDropdown.js +6 -5
  31. package/cjs/components/DropdownCard/components/DropdownCardDropdown.js.map +1 -1
  32. package/cjs/components/DropdownCard/components/DropdownCardTabs.js +3 -2
  33. package/cjs/components/DropdownCard/components/DropdownCardTabs.js.map +1 -1
  34. package/cjs/components/Field/Field.js +26 -6
  35. package/cjs/components/Field/Field.js.map +1 -1
  36. package/cjs/components/FileField/FileField.js +47 -33
  37. package/cjs/components/FileField/FileField.js.map +1 -1
  38. package/cjs/components/Icon/Icon.js.map +1 -1
  39. package/cjs/components/Icon/RoasterIcon.js +12 -0
  40. package/cjs/components/Icon/RoasterIcon.js.map +1 -0
  41. package/cjs/components/IconBadge/IconBadge.js.map +1 -1
  42. package/cjs/components/Modal/Modal.js +3 -2
  43. package/cjs/components/Modal/Modal.js.map +1 -1
  44. package/cjs/components/Pagination/Pagination.js +4 -3
  45. package/cjs/components/Pagination/Pagination.js.map +1 -1
  46. package/cjs/components/RangeField/RangeField.js +34 -21
  47. package/cjs/components/RangeField/RangeField.js.map +1 -1
  48. package/cjs/components/Select/Select.js +8 -6
  49. package/cjs/components/Select/Select.js.map +1 -1
  50. package/cjs/components/Sidebar/Sidebar.js +4 -3
  51. package/cjs/components/Sidebar/Sidebar.js.map +1 -1
  52. package/cjs/components/Sidebar/components/Back.js +7 -3
  53. package/cjs/components/Sidebar/components/Back.js.map +1 -1
  54. package/cjs/components/StatCard/StatCard.js +3 -2
  55. package/cjs/components/StatCard/StatCard.js.map +1 -1
  56. package/cjs/components/Switch/Switch.js +7 -1
  57. package/cjs/components/Switch/Switch.js.map +1 -1
  58. package/cjs/components/Table/components/TableHeadCell.js +4 -3
  59. package/cjs/components/Table/components/TableHeadCell.js.map +1 -1
  60. package/cjs/components/Tag/Tag.js +3 -2
  61. package/cjs/components/Tag/Tag.js.map +1 -1
  62. package/cjs/components/TextField/TextField.js +3 -1
  63. package/cjs/components/TextField/TextField.js.map +1 -1
  64. package/cjs/components/Textarea/Textarea.js +36 -4
  65. package/cjs/components/Textarea/Textarea.js.map +1 -1
  66. package/cjs/components/Thumbnail/Thumbnail.js +3 -2
  67. package/cjs/components/Thumbnail/Thumbnail.js.map +1 -1
  68. package/cjs/components/Toast/Toast.js +3 -2
  69. package/cjs/components/Toast/Toast.js.map +1 -1
  70. package/cjs/components/Tooltip/Tooltip.js +6 -5
  71. package/cjs/components/Tooltip/Tooltip.js.map +1 -1
  72. package/cjs/components/Tooltip/TooltipCallout.js +3 -2
  73. package/cjs/components/Tooltip/TooltipCallout.js.map +1 -1
  74. package/cjs/components/Visualizer/Visualizer.js +4 -3
  75. package/cjs/components/Visualizer/Visualizer.js.map +1 -1
  76. package/cjs/utils/Slot/index.js +5 -5
  77. package/cjs/utils/Slot/index.js.map +1 -1
  78. package/cjs/utils/useDropdown/DropdownTrigger.js +4 -4
  79. package/cjs/utils/useDropdown/DropdownTrigger.js.map +1 -1
  80. package/cjs/utils/useMergeRefs/index.js +51 -0
  81. package/cjs/utils/useMergeRefs/index.js.map +1 -0
  82. package/esm/components/ActionList/components/ActionListDropdown.js +2 -1
  83. package/esm/components/ActionList/components/ActionListDropdown.js.map +1 -1
  84. package/esm/components/ActionList/components/ActionListItem.js +5 -3
  85. package/esm/components/ActionList/components/ActionListItem.js.map +1 -1
  86. package/esm/components/ActionList/components/ActionListSearch.js +21 -3
  87. package/esm/components/ActionList/components/ActionListSearch.js.map +1 -1
  88. package/esm/components/ActionList/components/ActionListSubmenu.js +5 -3
  89. package/esm/components/ActionList/components/ActionListSubmenu.js.map +1 -1
  90. package/esm/components/ActionList/components/ActionListSwitchItem.js +2 -1
  91. package/esm/components/ActionList/components/ActionListSwitchItem.js.map +1 -1
  92. package/esm/components/Alert/Alert.js +3 -2
  93. package/esm/components/Alert/Alert.js.map +1 -1
  94. package/esm/components/AppFrame/AppFrame.js.map +1 -1
  95. package/esm/components/Avatar/Avatar.js +1 -1
  96. package/esm/components/Avatar/Avatar.js.map +1 -1
  97. package/esm/components/Button/Button.js +3 -2
  98. package/esm/components/Button/Button.js.map +1 -1
  99. package/esm/components/ButtonIcon/ButtonIcon.js.map +1 -1
  100. package/esm/components/Checkbox/Checkbox.js +1 -1
  101. package/esm/components/Checkbox/Checkbox.js.map +1 -1
  102. package/esm/components/ColorField/ColorField.js +42 -29
  103. package/esm/components/ColorField/ColorField.js.map +1 -1
  104. package/esm/components/DatePicker/DatePicker.js +1 -1
  105. package/esm/components/DatePicker/DatePicker.js.map +1 -1
  106. package/esm/components/DatePicker/components/Calendar/Calendar.js +4 -3
  107. package/esm/components/DatePicker/components/Calendar/Calendar.js.map +1 -1
  108. package/esm/components/DropdownCard/components/DropdownCardDropdown.js +2 -1
  109. package/esm/components/DropdownCard/components/DropdownCardDropdown.js.map +1 -1
  110. package/esm/components/DropdownCard/components/DropdownCardTabs.js +3 -2
  111. package/esm/components/DropdownCard/components/DropdownCardTabs.js.map +1 -1
  112. package/esm/components/Field/Field.js +26 -6
  113. package/esm/components/Field/Field.js.map +1 -1
  114. package/esm/components/FileField/FileField.js +47 -33
  115. package/esm/components/FileField/FileField.js.map +1 -1
  116. package/esm/components/Icon/Icon.js.map +1 -1
  117. package/esm/components/Icon/RoasterIcon.js +10 -0
  118. package/esm/components/Icon/RoasterIcon.js.map +1 -0
  119. package/esm/components/IconBadge/IconBadge.js.map +1 -1
  120. package/esm/components/Modal/Modal.js +3 -2
  121. package/esm/components/Modal/Modal.js.map +1 -1
  122. package/esm/components/Pagination/Pagination.js +4 -3
  123. package/esm/components/Pagination/Pagination.js.map +1 -1
  124. package/esm/components/RangeField/RangeField.js +34 -21
  125. package/esm/components/RangeField/RangeField.js.map +1 -1
  126. package/esm/components/Select/Select.js +4 -2
  127. package/esm/components/Select/Select.js.map +1 -1
  128. package/esm/components/Sidebar/Sidebar.js +4 -3
  129. package/esm/components/Sidebar/Sidebar.js.map +1 -1
  130. package/esm/components/Sidebar/components/Back.js +7 -3
  131. package/esm/components/Sidebar/components/Back.js.map +1 -1
  132. package/esm/components/StatCard/StatCard.js +3 -2
  133. package/esm/components/StatCard/StatCard.js.map +1 -1
  134. package/esm/components/Switch/Switch.js +7 -1
  135. package/esm/components/Switch/Switch.js.map +1 -1
  136. package/esm/components/Table/components/TableHeadCell.js +4 -3
  137. package/esm/components/Table/components/TableHeadCell.js.map +1 -1
  138. package/esm/components/Tag/Tag.js +3 -2
  139. package/esm/components/Tag/Tag.js.map +1 -1
  140. package/esm/components/TextField/TextField.js +3 -1
  141. package/esm/components/TextField/TextField.js.map +1 -1
  142. package/esm/components/Textarea/Textarea.js +38 -6
  143. package/esm/components/Textarea/Textarea.js.map +1 -1
  144. package/esm/components/Thumbnail/Thumbnail.js +3 -2
  145. package/esm/components/Thumbnail/Thumbnail.js.map +1 -1
  146. package/esm/components/Toast/Toast.js +3 -2
  147. package/esm/components/Toast/Toast.js.map +1 -1
  148. package/esm/components/Tooltip/Tooltip.js +2 -1
  149. package/esm/components/Tooltip/Tooltip.js.map +1 -1
  150. package/esm/components/Tooltip/TooltipCallout.js +3 -2
  151. package/esm/components/Tooltip/TooltipCallout.js.map +1 -1
  152. package/esm/components/Visualizer/Visualizer.js +4 -3
  153. package/esm/components/Visualizer/Visualizer.js.map +1 -1
  154. package/esm/package.json +4 -1
  155. package/esm/utils/Slot/index.js +1 -1
  156. package/esm/utils/Slot/index.js.map +1 -1
  157. package/esm/utils/useDropdown/DropdownTrigger.js +1 -1
  158. package/esm/utils/useDropdown/DropdownTrigger.js.map +1 -1
  159. package/esm/utils/useMergeRefs/index.js +36 -0
  160. package/esm/utils/useMergeRefs/index.js.map +1 -0
  161. package/lib/components/ActionList/components/ActionListItem.d.ts +4 -1
  162. package/lib/components/ActionList/components/ActionListItem.d.ts.map +1 -1
  163. package/lib/components/ActionList/components/ActionListSearch.d.ts.map +1 -1
  164. package/lib/components/ActionList/components/ActionListSubmenu.d.ts.map +1 -1
  165. package/lib/components/AppFrame/AppFrame.d.ts +5 -1
  166. package/lib/components/AppFrame/AppFrame.d.ts.map +1 -1
  167. package/lib/components/Avatar/Avatar.d.ts +4 -1
  168. package/lib/components/Avatar/Avatar.d.ts.map +1 -1
  169. package/lib/components/ButtonIcon/ButtonIcon.d.ts +1 -1
  170. package/lib/components/ButtonIcon/ButtonIcon.d.ts.map +1 -1
  171. package/lib/components/Checkbox/Checkbox.d.ts.map +1 -1
  172. package/lib/components/ColorField/ColorField.d.ts.map +1 -1
  173. package/lib/components/DatePicker/DatePicker.d.ts.map +1 -1
  174. package/lib/components/DatePicker/utils/index.d.ts +2 -1
  175. package/lib/components/DatePicker/utils/index.d.ts.map +1 -1
  176. package/lib/components/Field/Field.d.ts +13 -7
  177. package/lib/components/Field/Field.d.ts.map +1 -1
  178. package/lib/components/FileField/FileField.d.ts.map +1 -1
  179. package/lib/components/Icon/Icon.d.ts +13 -2
  180. package/lib/components/Icon/Icon.d.ts.map +1 -1
  181. package/lib/components/Icon/RoasterIcon.d.ts +13 -0
  182. package/lib/components/Icon/RoasterIcon.d.ts.map +1 -0
  183. package/lib/components/Icon/index.d.ts +2 -0
  184. package/lib/components/Icon/index.d.ts.map +1 -1
  185. package/lib/components/IconBadge/IconBadge.d.ts +2 -2
  186. package/lib/components/RangeField/RangeField.d.ts.map +1 -1
  187. package/lib/components/Select/Select.d.ts.map +1 -1
  188. package/lib/components/Sidebar/components/Back.d.ts.map +1 -1
  189. package/lib/components/Switch/Switch.d.ts.map +1 -1
  190. package/lib/components/TextField/TextField.d.ts.map +1 -1
  191. package/lib/components/Textarea/Textarea.d.ts +6 -1
  192. package/lib/components/Textarea/Textarea.d.ts.map +1 -1
  193. package/lib/components/Tooltip/Tooltip.d.ts.map +1 -1
  194. package/lib/utils/Slot/index.d.ts.map +1 -1
  195. package/lib/utils/index.d.ts +1 -0
  196. package/lib/utils/index.d.ts.map +1 -1
  197. package/lib/utils/useDropdown/DropdownTrigger.d.ts.map +1 -1
  198. package/lib/utils/useMergeRefs/index.d.ts +11 -0
  199. package/lib/utils/useMergeRefs/index.d.ts.map +1 -0
  200. package/package.json +2 -2
  201. package/roaster.css +2 -1
  202. package/themes/azoth.css +1 -1
  203. package/themes/coffee.css +1 -1
  204. package/themes/scalar.css +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DropdownCardTabs.js","sources":["../../../../../src/components/DropdownCard/components/DropdownCardTabs.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames, useControllableState, useUid } from '@/utils';\nimport { Icon } from '../../Icon';\n\ninterface TabsContextValue {\n value: string;\n setValue(value: string): void;\n baseId: string;\n}\n\nconst TabsContext = React.createContext<TabsContextValue | null>(null);\n\nfunction useTabsContext() {\n const context = React.useContext(TabsContext);\n if (context == null) throw new Error('DropdownCard.TabList, Tab and Panel must be wrapped in <DropdownCard.Tabs />');\n return context;\n}\n\nconst idOf = (baseId: string, part: 'tab' | 'panel', value: string) => `${baseId}-${part}-${value}`;\n\nexport interface DropdownCardTabsProps {\n /** The tab list and the panels. */\n children: React.ReactNode;\n /** The chosen tab's value, for controlled tabs. */\n value?: string;\n /** The tab chosen at first, for uncontrolled tabs. */\n defaultValue?: string;\n /** Called with the tab's value when the user chooses a tab. */\n onValueChange?(value: string): void;\n}\n\n/**\n * Tabs in a dropdown card (`variant=\"tabs\"` on DropdownCard.Dropdown): a list of tabs beside the content, one panel\n * per tab, such as one filter per tab. Compose it with DropdownCard.TabList, DropdownCard.Tab and DropdownCard.Panel.\n */\nexport function DropdownCardTabs({ children, value, defaultValue, onValueChange }: DropdownCardTabsProps) {\n const [current, setCurrent] = useControllableState({\n value,\n defaultValue: defaultValue ?? '',\n onChange: onValueChange,\n });\n const baseId = useUid();\n const context = React.useMemo(\n () => ({ value: current, setValue: setCurrent, baseId }),\n [current, setCurrent, baseId]\n );\n return <TabsContext.Provider value={context}>{children}</TabsContext.Provider>;\n}\n\n/** Every native `<div>` prop (`aria-label`, ...) is accepted and forwarded to the list. Name it with `aria-label`. */\nexport interface DropdownCardTabListProps extends React.ComponentPropsWithoutRef<'div'> {\n /** The tabs. */\n children: React.ReactNode;\n}\n\n/** The list of tabs (`role=\"tablist\"`), on the card's start side. The arrow keys, Home and End choose a tab. */\nexport const DropdownCardTabList = React.forwardRef<HTMLDivElement, DropdownCardTabListProps>(\n ({ className, children, onKeyDown, ...rest }, ref) => {\n const { setValue } = useTabsContext();\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event);\n const tabs = [...event.currentTarget.querySelectorAll<HTMLElement>(':scope > [role=\"tab\"]:not(:disabled)')];\n const index = tabs.indexOf(event.target as HTMLElement);\n if (index === -1) return;\n const step = ({ ArrowDown: 1, ArrowRight: 1, ArrowUp: -1, ArrowLeft: -1 } as Record<string, number>)[event.key];\n let next: HTMLElement | undefined;\n if (step) next = tabs[(index + step + tabs.length) % tabs.length];\n else if (event.key === 'Home') next = tabs[0];\n else if (event.key === 'End') next = tabs[tabs.length - 1];\n if (!next) return;\n event.preventDefault();\n setValue(next.dataset.value ?? '');\n next.focus();\n };\n return (\n // The keys come from its tabs, which take the focus.\n // eslint-disable-next-line jsx-a11y/interactive-supports-focus\n <div\n role=\"tablist\"\n aria-orientation=\"vertical\"\n {...rest}\n ref={ref}\n onKeyDown={handleKeyDown}\n className={classNames('roaster-dropdown-card__tabs', className)}\n >\n {children}\n </div>\n );\n }\n);\nDropdownCardTabList.displayName = 'DropdownCardTabList';\n\n/** Every native `<button>` prop is accepted and forwarded to the tab. */\nexport interface DropdownCardTabProps extends Omit<React.ComponentPropsWithoutRef<'button'>, 'value'> {\n /** The tab's value, which names its panel. */\n value: string;\n /** The tab's name. */\n children: React.ReactNode;\n /** An `Icon` before the name. */\n icon?: React.ReactNode;\n}\n\n/** A tab: choosing it shows its panel. The chosen tab is the list's one tab stop, with a chevron at its end. */\nexport const DropdownCardTab = React.forwardRef<HTMLButtonElement, DropdownCardTabProps>(\n ({ value, icon, children, className, onClick, type = 'button', ...rest }, ref) => {\n const context = useTabsContext();\n const selected = context.value === value;\n return (\n <button\n {...rest}\n ref={ref}\n type={type}\n role=\"tab\"\n id={idOf(context.baseId, 'tab', value)}\n aria-controls={idOf(context.baseId, 'panel', value)}\n aria-selected={selected}\n tabIndex={selected ? 0 : -1}\n data-value={value}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) context.setValue(value);\n }}\n className={classNames('roaster-dropdown-card__tab', className)}\n >\n {icon}\n {children}\n <Icon name=\"angle-right\" />\n </button>\n );\n }\n);\nDropdownCardTab.displayName = 'DropdownCardTab';\n\n/** Every native `<div>` prop is accepted and forwarded to the panel. */\nexport interface DropdownCardPanelProps extends React.ComponentPropsWithoutRef<'div'> {\n /** The value of the tab that shows the panel. */\n value: string;\n /** The panel's fields. It scrolls when it is taller than the card. */\n children: React.ReactNode;\n}\n\n/** The content of one tab (`role=\"tabpanel\"`), hidden while another tab is chosen. */\nexport const DropdownCardPanel = React.forwardRef<HTMLDivElement, DropdownCardPanelProps>(\n ({ value, className, children, ...rest }, ref) => {\n const context = useTabsContext();\n return (\n <div\n {...rest}\n ref={ref}\n role=\"tabpanel\"\n id={idOf(context.baseId, 'panel', value)}\n aria-labelledby={idOf(context.baseId, 'tab', value)}\n hidden={context.value !== value}\n className={classNames('roaster-dropdown-card__content', className)}\n >\n {children}\n </div>\n );\n }\n);\nDropdownCardPanel.displayName = 'DropdownCardPanel';\n"],"names":[],"mappings":";;;;;;;;AAKA,MAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC;AAC7C,SAAS,cAAc,GAAG;AAC1B,EAAE,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC;AAC/C,EAAE,IAAI,OAAO,IAAI,IAAI,EAAE,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC;AACtH,EAAE,OAAO,OAAO;AAChB;AACA,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AAC3D,SAAS,gBAAgB,CAAC,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AAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC;AAChD,QAAQ,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC;AAC7D,QAAQ,MAAM,EAAE,OAAO,CAAC,KAAK,KAAK,KAAK;AACvC,QAAQ,SAAS,EAAE,UAAU,CAAC,gCAAgC,EAAE,SAAS,CAAC;AAC1E,QAAQ;AACR;AACA,KAAK;AACL,EAAE;AACF;AACA,iBAAiB,CAAC,WAAW,GAAG,mBAAmB;;"}
1
+ {"version":3,"file":"DropdownCardTabs.js","sources":["../../../../../src/components/DropdownCard/components/DropdownCardTabs.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames, useControllableState, useUid } from '@/utils';\nimport { RoasterIcon } from '../../Icon';\n\ninterface TabsContextValue {\n value: string;\n setValue(value: string): void;\n baseId: string;\n}\n\nconst TabsContext = React.createContext<TabsContextValue | null>(null);\n\nfunction useTabsContext() {\n const context = React.useContext(TabsContext);\n if (context == null) throw new Error('DropdownCard.TabList, Tab and Panel must be wrapped in <DropdownCard.Tabs />');\n return context;\n}\n\nconst idOf = (baseId: string, part: 'tab' | 'panel', value: string) => `${baseId}-${part}-${value}`;\n\nexport interface DropdownCardTabsProps {\n /** The tab list and the panels. */\n children: React.ReactNode;\n /** The chosen tab's value, for controlled tabs. */\n value?: string;\n /** The tab chosen at first, for uncontrolled tabs. */\n defaultValue?: string;\n /** Called with the tab's value when the user chooses a tab. */\n onValueChange?(value: string): void;\n}\n\n/**\n * Tabs in a dropdown card (`variant=\"tabs\"` on DropdownCard.Dropdown): a list of tabs beside the content, one panel\n * per tab, such as one filter per tab. Compose it with DropdownCard.TabList, DropdownCard.Tab and DropdownCard.Panel.\n */\nexport function DropdownCardTabs({ children, value, defaultValue, onValueChange }: DropdownCardTabsProps) {\n const [current, setCurrent] = useControllableState({\n value,\n defaultValue: defaultValue ?? '',\n onChange: onValueChange,\n });\n const baseId = useUid();\n const context = React.useMemo(\n () => ({ value: current, setValue: setCurrent, baseId }),\n [current, setCurrent, baseId]\n );\n return <TabsContext.Provider value={context}>{children}</TabsContext.Provider>;\n}\n\n/** Every native `<div>` prop (`aria-label`, ...) is accepted and forwarded to the list. Name it with `aria-label`. */\nexport interface DropdownCardTabListProps extends React.ComponentPropsWithoutRef<'div'> {\n /** The tabs. */\n children: React.ReactNode;\n}\n\n/** The list of tabs (`role=\"tablist\"`), on the card's start side. The arrow keys, Home and End choose a tab. */\nexport const DropdownCardTabList = React.forwardRef<HTMLDivElement, DropdownCardTabListProps>(\n ({ className, children, onKeyDown, ...rest }, ref) => {\n const { setValue } = useTabsContext();\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event);\n const tabs = [...event.currentTarget.querySelectorAll<HTMLElement>(':scope > [role=\"tab\"]:not(:disabled)')];\n const index = tabs.indexOf(event.target as HTMLElement);\n if (index === -1) return;\n const step = ({ ArrowDown: 1, ArrowRight: 1, ArrowUp: -1, ArrowLeft: -1 } as Record<string, number>)[event.key];\n let next: HTMLElement | undefined;\n if (step) next = tabs[(index + step + tabs.length) % tabs.length];\n else if (event.key === 'Home') next = tabs[0];\n else if (event.key === 'End') next = tabs[tabs.length - 1];\n if (!next) return;\n event.preventDefault();\n setValue(next.dataset.value ?? '');\n next.focus();\n };\n return (\n // The keys come from its tabs, which take the focus.\n // eslint-disable-next-line jsx-a11y/interactive-supports-focus\n <div\n role=\"tablist\"\n aria-orientation=\"vertical\"\n {...rest}\n ref={ref}\n onKeyDown={handleKeyDown}\n className={classNames('roaster-dropdown-card__tabs', className)}\n >\n {children}\n </div>\n );\n }\n);\nDropdownCardTabList.displayName = 'DropdownCardTabList';\n\n/** Every native `<button>` prop is accepted and forwarded to the tab. */\nexport interface DropdownCardTabProps extends Omit<React.ComponentPropsWithoutRef<'button'>, 'value'> {\n /** The tab's value, which names its panel. */\n value: string;\n /** The tab's name. */\n children: React.ReactNode;\n /** An `Icon` before the name. */\n icon?: React.ReactNode;\n}\n\n/** A tab: choosing it shows its panel. The chosen tab is the list's one tab stop, with a chevron at its end. */\nexport const DropdownCardTab = React.forwardRef<HTMLButtonElement, DropdownCardTabProps>(\n ({ value, icon, children, className, onClick, type = 'button', ...rest }, ref) => {\n const context = useTabsContext();\n const selected = context.value === value;\n return (\n <button\n {...rest}\n ref={ref}\n type={type}\n role=\"tab\"\n id={idOf(context.baseId, 'tab', value)}\n aria-controls={idOf(context.baseId, 'panel', value)}\n aria-selected={selected}\n tabIndex={selected ? 0 : -1}\n data-value={value}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) context.setValue(value);\n }}\n className={classNames('roaster-dropdown-card__tab', className)}\n >\n {icon}\n {children}\n <RoasterIcon name=\"chevron-right\" />\n </button>\n );\n }\n);\nDropdownCardTab.displayName = 'DropdownCardTab';\n\n/** Every native `<div>` prop is accepted and forwarded to the panel. */\nexport interface DropdownCardPanelProps extends React.ComponentPropsWithoutRef<'div'> {\n /** The value of the tab that shows the panel. */\n value: string;\n /** The panel's fields. It scrolls when it is taller than the card. */\n children: React.ReactNode;\n}\n\n/** The content of one tab (`role=\"tabpanel\"`), hidden while another tab is chosen. */\nexport const DropdownCardPanel = React.forwardRef<HTMLDivElement, DropdownCardPanelProps>(\n ({ value, className, children, ...rest }, ref) => {\n const context = useTabsContext();\n return (\n <div\n {...rest}\n ref={ref}\n role=\"tabpanel\"\n id={idOf(context.baseId, 'panel', value)}\n aria-labelledby={idOf(context.baseId, 'tab', value)}\n hidden={context.value !== value}\n className={classNames('roaster-dropdown-card__content', className)}\n >\n {children}\n </div>\n );\n }\n);\nDropdownCardPanel.displayName = 'DropdownCardPanel';\n"],"names":[],"mappings":";;;;;;;;;AAKA,MAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC;AAC7C,SAAS,cAAc,GAAG;AAC1B,EAAE,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,WA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U;AACjD,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,GAAG,KAAK;AACpD,IAAI,MAAM,OAAO,GAAG,cAAc,EAAE;AACpC,IAAI,uBAAuB,GAAG;AAC9B,MAAM,KAAK;AACX,MAAM;AACN,QAAQ,GAAG,IAAI;AACf,QAAQ,GAAG;AACX,QAAQ,IAAI,EAAE,UAAU;AACxB,QAAQ,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC;AAChD,QAAQ,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC;AAC7D,QAAQ,MAAM,EAAE,OAAO,CAAC,KAAK,KAAK,KAAK;AACvC,QAAQ,SAAS,EAAE,UAAU,CAAC,gCAAgC,EAAE,SAAS,CAAC;AAC1E,QAAQ;AACR;AACA,KAAK;AACL,EAAE;AACF;AACA,iBAAiB,CAAC,WAAW,GAAG,mBAAmB;;"}
@@ -4,19 +4,39 @@ import { classNames } from '../../utils/classNames/index.js';
4
4
 
5
5
  const hasContent = (node) => !(node == null || typeof node === "boolean" || node === "");
6
6
  const isInvalid = (error) => error != null && error !== false && error !== "";
7
- function fieldControlProps(controlId, { description, error }, ariaProps = {}) {
8
- const hasMessage = hasContent(error) || hasContent(description);
7
+ function messageIds(controlId, { description, error, keepDescription }) {
8
+ const showsError = hasContent(error);
9
+ const showsDescription = hasContent(description) && (!showsError || !!keepDescription);
10
+ return {
11
+ descriptionId: showsDescription ? `${controlId}-message` : void 0,
12
+ errorId: showsError ? `${controlId}-${showsDescription ? "error" : "message"}` : void 0
13
+ };
14
+ }
15
+ function fieldControlProps(controlId, messages, ariaProps = {}) {
16
+ const { descriptionId, errorId } = messageIds(controlId, messages);
9
17
  return {
10
18
  id: controlId,
11
- "aria-invalid": isInvalid(error) ? true : void 0,
12
- "aria-describedby": [ariaProps["aria-describedby"], hasMessage && `${controlId}-message`].filter(Boolean).join(" ") || void 0
19
+ "aria-invalid": isInvalid(messages.error) ? true : void 0,
20
+ "aria-describedby": [ariaProps["aria-describedby"], descriptionId, errorId].filter(Boolean).join(" ") || void 0
13
21
  };
14
22
  }
15
- function Field({ controlId, label, description, error, inline, className, style, children }) {
23
+ function Field({
24
+ controlId,
25
+ label,
26
+ description,
27
+ error,
28
+ keepDescription,
29
+ inline,
30
+ className,
31
+ style,
32
+ children
33
+ }) {
34
+ const { descriptionId, errorId } = messageIds(controlId, { description, error, keepDescription });
16
35
  return /* @__PURE__ */ jsxs("div", { className: classNames("roaster-field", { "roaster-field--inline": inline }, className), style, children: [
17
36
  hasContent(label) && /* @__PURE__ */ jsx("label", { className: "roaster-field__label", htmlFor: controlId, children: label }),
18
37
  children,
19
- hasContent(error) ? /* @__PURE__ */ jsx("small", { className: "roaster-field__error", id: `${controlId}-message`, children: error }) : hasContent(description) && /* @__PURE__ */ jsx("small", { className: "roaster-field__help", id: `${controlId}-message`, children: description })
38
+ descriptionId && /* @__PURE__ */ jsx("small", { className: "roaster-field__help", id: descriptionId, children: description }),
39
+ errorId && /* @__PURE__ */ jsx("small", { className: "roaster-field__error", id: errorId, children: error })
20
40
  ] });
21
41
  }
22
42
 
@@ -1 +1 @@
1
- {"version":3,"file":"Field.js","sources":["../../../../src/components/Field/Field.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames } from '@/utils';\n\n/** The props every form field shares: its label, help text and error. */\nexport interface FieldBaseProps {\n /** The label shown above the control. */\n label?: React.ReactNode;\n /** Help text shown under the control. */\n description?: React.ReactNode;\n /**\n * An error shown under the control, in place of the help text. It also marks the control as invalid; `true` marks it\n * invalid without a message.\n */\n error?: React.ReactNode;\n /** Classes added to the field's wrapper (the label, the control and the text under it). */\n className?: string;\n /** Styles added to the field's wrapper. */\n style?: React.CSSProperties;\n}\n\n/** A field whose control can sit on its label's row: TextField and Select. */\nexport interface InlineFieldProps {\n /** The label at the start of a row and the control at its end, at its own width, such as a setting in a menu. */\n inline?: boolean;\n}\n\nexport interface FieldProps extends FieldBaseProps, InlineFieldProps {\n /** The id of the control, which the label points at. */\n controlId: string;\n /** The control, with the props that tie it to the label and the text under it (`fieldControlProps`). */\n children: React.ReactNode;\n}\n\n/** Whether there is something to show: not nothing, not a boolean, not an empty string. */\nconst hasContent = (node: React.ReactNode) => !(node == null || typeof node === 'boolean' || node === '');\nconst isInvalid = (error: React.ReactNode) => error != null && error !== false && error !== '';\n\n/** The ARIA props a control may already have, which the field keeps. */\nexport interface ControlAriaProps {\n 'aria-describedby'?: string;\n}\n\n/**\n * The props that tie a control to its field: its id, `aria-invalid` when there is an error, and `aria-describedby`\n * pointing at the help text or error (after any the control already has). The label names it through `for`.\n */\nexport function fieldControlProps(\n controlId: string,\n { description, error }: Pick<FieldBaseProps, 'label' | 'description' | 'error'>,\n ariaProps: ControlAriaProps = {}\n) {\n const hasMessage = hasContent(error) || hasContent(description);\n return {\n id: controlId,\n 'aria-invalid': isInvalid(error) ? true : undefined,\n 'aria-describedby':\n [ariaProps['aria-describedby'], hasMessage && `${controlId}-message`].filter(Boolean).join(' ') || undefined,\n };\n}\n\n/**\n * The frame of a form field: the label, the control, and the help text or error under it. Each field renders one,\n * and passes `fieldControlProps` to its control.\n */\nexport function Field({ controlId, label, description, error, inline, className, style, children }: FieldProps) {\n return (\n <div className={classNames('roaster-field', { 'roaster-field--inline': inline }, className)} style={style}>\n {hasContent(label) && (\n <label className=\"roaster-field__label\" htmlFor={controlId}>\n {label}\n </label>\n )}\n {children}\n {hasContent(error) ? (\n <small className=\"roaster-field__error\" id={`${controlId}-message`}>\n {error}\n </small>\n ) : (\n hasContent(description) && (\n <small className=\"roaster-field__help\" id={`${controlId}-message`}>\n {description}\n </small>\n )\n )}\n </div>\n );\n}\n"],"names":[],"mappings":";;;;AAGA,MAAM,UAAU,GAAG,CAAC,IAAI,KAAK,EAAE,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,SAAS,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AE,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC,oBAAoB,GAAG,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,qBAAqB,EAAE,EAAE,EAAE,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE;AAC1R,GAAG,EAAE,CAAC;AACN;;"}
1
+ {"version":3,"file":"Field.js","sources":["../../../../src/components/Field/Field.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames } from '@/utils';\n\n/** The props every form field shares: its label, help text and error. */\nexport interface FieldBaseProps {\n /** The label shown above the control. */\n label?: React.ReactNode;\n /** Help text shown under the control. */\n description?: React.ReactNode;\n /**\n * An error shown under the control, in place of the help text unless `keepDescription`. It also marks the control as\n * invalid; `true` marks it invalid without a message.\n */\n error?: React.ReactNode;\n /**\n * Keeps the help text when there is an error, which then shows under it: for help that stays useful while the value\n * is wrong, such as the format it needs. A count of the characters goes in a Textarea's `footer`.\n * @defaultValue false\n */\n keepDescription?: boolean;\n /** Classes added to the field's wrapper (the label, the control and the text under it). */\n className?: string;\n /** Styles added to the field's wrapper. */\n style?: React.CSSProperties;\n}\n\n/** A field whose control can sit on its label's row: TextField and Select. */\nexport interface InlineFieldProps {\n /** The label at the start of a row and the control at its end, at its own width, such as a setting in a menu. */\n inline?: boolean;\n}\n\nexport interface FieldProps extends FieldBaseProps, InlineFieldProps {\n /** The id of the control, which the label points at. */\n controlId: string;\n /** The control, with the props that tie it to the label and the text under it (`fieldControlProps`). */\n children: React.ReactNode;\n}\n\n/** Whether there is something to show: not nothing, not a boolean, not an empty string. */\nconst hasContent = (node: React.ReactNode) => !(node == null || typeof node === 'boolean' || node === '');\nconst isInvalid = (error: React.ReactNode) => error != null && error !== false && error !== '';\n\n/**\n * The ids of the texts under the control: the help text or the error, both with `keepDescription`. The one shown alone\n * is `<id>-message`; with both, the error is `<id>-error`.\n */\nfunction messageIds(\n controlId: string,\n { description, error, keepDescription }: Pick<FieldBaseProps, 'description' | 'error' | 'keepDescription'>\n) {\n const showsError = hasContent(error);\n const showsDescription = hasContent(description) && (!showsError || !!keepDescription);\n return {\n descriptionId: showsDescription ? `${controlId}-message` : undefined,\n errorId: showsError ? `${controlId}-${showsDescription ? 'error' : 'message'}` : undefined,\n };\n}\n\n/** The ARIA props a control may already have, which the field keeps. */\nexport interface ControlAriaProps {\n 'aria-describedby'?: string;\n}\n\n/**\n * The props that tie a control to its field: its id, `aria-invalid` when there is an error, and `aria-describedby`\n * pointing at the help text, the error, or both (after any the control already has). The label names it through `for`.\n */\nexport function fieldControlProps(\n controlId: string,\n messages: Pick<FieldBaseProps, 'label' | 'description' | 'error' | 'keepDescription'>,\n ariaProps: ControlAriaProps = {}\n) {\n const { descriptionId, errorId } = messageIds(controlId, messages);\n return {\n id: controlId,\n 'aria-invalid': isInvalid(messages.error) ? true : undefined,\n 'aria-describedby': [ariaProps['aria-describedby'], descriptionId, errorId].filter(Boolean).join(' ') || undefined,\n };\n}\n\n/**\n * The frame of a form field: the label, the control, and the help text or error under it, or both. Each field renders\n * one, and passes `fieldControlProps` to its control.\n */\nexport function Field({\n controlId,\n label,\n description,\n error,\n keepDescription,\n inline,\n className,\n style,\n children,\n}: FieldProps) {\n const { descriptionId, errorId } = messageIds(controlId, { description, error, keepDescription });\n return (\n <div className={classNames('roaster-field', { 'roaster-field--inline': inline }, className)} style={style}>\n {hasContent(label) && (\n <label className=\"roaster-field__label\" htmlFor={controlId}>\n {label}\n </label>\n )}\n {children}\n {descriptionId && (\n <small className=\"roaster-field__help\" id={descriptionId}>\n {description}\n </small>\n )}\n {errorId && (\n <small className=\"roaster-field__error\" id={errorId}>\n {error}\n </small>\n )}\n </div>\n );\n}\n"],"names":[],"mappings":";;;;AAGA,MAAM,UAAU,GAAG,CAAC,IAAI,KAAK,EAAE,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,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AACR,EAAE,SAAS;AACX,EAAE,KAAK;AACP,EAAE;AACF,CAAC,EAAE;AACH,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC;AACnG,EAAE,uBAAuB,IAAI,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,eAAe,EAAE,EAAE,uBAAuB,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE;AAChJ,IAAI,UAAU,CAAC,KAAK,CAAC,oBAAoB,GAAG,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,sBAAsB,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AACjI,IAAI,QAAQ;AACZ,IAAI,aAAa,oBAAoB,GAAG,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,qBAAqB,EAAE,EAAE,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;AACjI,IAAI,OAAO,oBAAoB,GAAG,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,sBAAsB,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE;AAC/G,GAAG,EAAE,CAAC;AACN;;"}
@@ -2,7 +2,8 @@
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import * as React from 'react';
4
4
  import { Field, fieldControlProps } from '../Field/Field.js';
5
- import { Icon } from '../Icon/Icon.js';
5
+ import '../Icon/Icon.js';
6
+ import { RoasterIcon } from '../Icon/RoasterIcon.js';
6
7
  import { useUid } from '../../utils/useUid/index.js';
7
8
  import { classNames } from '../../utils/classNames/index.js';
8
9
 
@@ -14,13 +15,13 @@ function EmptyMarkupPlaceholder({
14
15
  }) {
15
16
  if (type === "file")
16
17
  return /* @__PURE__ */ jsxs(Fragment, { children: [
17
- /* @__PURE__ */ jsx(Icon, { name: "file-csv", className: "roaster-file__icon" }),
18
+ /* @__PURE__ */ jsx(RoasterIcon, { name: "file-spreadsheet", className: "roaster-file__icon" }),
18
19
  /* @__PURE__ */ jsx("span", { className: "roaster-file__name", children: noFileLabel })
19
20
  ] });
20
21
  if (defaultValue) {
21
22
  return /* @__PURE__ */ jsx("img", { src: defaultValue, alt: "" });
22
23
  }
23
- return /* @__PURE__ */ jsx("div", { className: "roaster-file__placeholder", children: /* @__PURE__ */ jsx(Icon, { name: "image" }) });
24
+ return /* @__PURE__ */ jsx("div", { className: "roaster-file__placeholder", children: /* @__PURE__ */ jsx(RoasterIcon, { name: "image" }) });
24
25
  }
25
26
  function Preview({ type, files }) {
26
27
  const file = files[0];
@@ -35,7 +36,7 @@ function Preview({ type, files }) {
35
36
  return imageUrl ? /* @__PURE__ */ jsx("img", { src: imageUrl, alt: file.name }) : null;
36
37
  }
37
38
  return /* @__PURE__ */ jsxs(Fragment, { children: [
38
- /* @__PURE__ */ jsx(Icon, { name: "file-csv", className: "roaster-file__icon" }),
39
+ /* @__PURE__ */ jsx(RoasterIcon, { name: "file-spreadsheet", className: "roaster-file__icon" }),
39
40
  /* @__PURE__ */ jsx("span", { className: "roaster-file__name", children: files.map((chosen) => chosen.name).join(", ") })
40
41
  ] });
41
42
  }
@@ -46,6 +47,7 @@ const FileField = React.forwardRef((props, ref) => {
46
47
  name,
47
48
  disabled,
48
49
  description,
50
+ keepDescription,
49
51
  error,
50
52
  className,
51
53
  style,
@@ -68,37 +70,49 @@ const FileField = React.forwardRef((props, ref) => {
68
70
  onChange?.(event);
69
71
  onValueChange?.(chosen);
70
72
  };
71
- return /* @__PURE__ */ jsx(Field, { controlId: uid, label, description, error, className, style, children: /* @__PURE__ */ jsxs(
72
- "div",
73
+ return /* @__PURE__ */ jsx(
74
+ Field,
73
75
  {
74
- className: classNames("roaster-file", `roaster-file--${size}`),
75
- "data-state": files.length > 0 ? "filled" : void 0,
76
- children: [
77
- /* @__PURE__ */ jsx("div", { className: type === "image" ? "roaster-file__image" : "roaster-file__preview", children: files.length === 0 ? /* @__PURE__ */ jsx(EmptyMarkupPlaceholder, { type, defaultValue, noFileLabel: text.noFile }) : /* @__PURE__ */ jsx(Preview, { type, files }) }),
78
- /* @__PURE__ */ jsxs("div", { className: "roaster-file__button", children: [
79
- /* @__PURE__ */ jsxs("span", { children: [
80
- /* @__PURE__ */ jsx(Icon, { name: "arrow-up-from-bracket" }),
81
- text.upload,
82
- hint && /* @__PURE__ */ jsx("small", { className: "roaster-file__hint", children: hint })
83
- ] }),
84
- /* @__PURE__ */ jsx(
85
- "input",
86
- {
87
- ...others,
88
- ...fieldControlProps(uid, { description, error }, others),
89
- name,
90
- ref,
91
- className: "roaster-file__input",
92
- type: "file",
93
- disabled,
94
- accept,
95
- onChange: handleChange
96
- }
97
- )
98
- ] })
99
- ]
76
+ controlId: uid,
77
+ label,
78
+ description,
79
+ keepDescription,
80
+ error,
81
+ className,
82
+ style,
83
+ children: /* @__PURE__ */ jsxs(
84
+ "div",
85
+ {
86
+ className: classNames("roaster-file", `roaster-file--${size}`),
87
+ "data-state": files.length > 0 ? "filled" : void 0,
88
+ children: [
89
+ /* @__PURE__ */ jsx("div", { className: type === "image" ? "roaster-file__image" : "roaster-file__preview", children: files.length === 0 ? /* @__PURE__ */ jsx(EmptyMarkupPlaceholder, { type, defaultValue, noFileLabel: text.noFile }) : /* @__PURE__ */ jsx(Preview, { type, files }) }),
90
+ /* @__PURE__ */ jsxs("div", { className: "roaster-file__button", children: [
91
+ /* @__PURE__ */ jsxs("span", { children: [
92
+ /* @__PURE__ */ jsx(RoasterIcon, { name: "upload" }),
93
+ text.upload,
94
+ hint && /* @__PURE__ */ jsx("small", { className: "roaster-file__hint", children: hint })
95
+ ] }),
96
+ /* @__PURE__ */ jsx(
97
+ "input",
98
+ {
99
+ ...others,
100
+ ...fieldControlProps(uid, { description, error, keepDescription }, others),
101
+ name,
102
+ ref,
103
+ className: "roaster-file__input",
104
+ type: "file",
105
+ disabled,
106
+ accept,
107
+ onChange: handleChange
108
+ }
109
+ )
110
+ ] })
111
+ ]
112
+ }
113
+ )
100
114
  }
101
- ) });
115
+ );
102
116
  });
103
117
  FileField.displayName = "FileField";
104
118
 
@@ -1 +1 @@
1
- {"version":3,"file":"FileField.js","sources":["../../../../src/components/FileField/FileField.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames, useUid } from '@/utils';\nimport { Field, fieldControlProps, type FieldBaseProps } from '../Field';\nimport { Icon } from '@/components/Icon';\n\n/**\n * Every native `<input>` prop (`name`, `required`, `aria-*`, ...) is accepted and forwarded to the file input, with the\n * ref. `className` and `style` go to the field's wrapper.\n */\nexport interface FileFieldProps\n extends\n FieldBaseProps,\n Omit<React.ComponentPropsWithoutRef<'input'>, 'type' | 'size' | 'defaultValue' | 'value' | 'className' | 'style'> {\n /** The HTML ID attribute to be applied to the file upload field input element (optional). */\n id?: string;\n /** The name attribute to be applied to the file upload field input element (optional). */\n name?: string;\n /**\n * The accept attribute to be applied to the file upload field input element (optional).\n * Specifies the types of accepted files.\n */\n accept?: string;\n /**\n * The size of the file upload field (optional).\n * - 'small': render a smaller file upload field\n * - 'medium': render a larger file upload field\n */\n size?: 'small' | 'medium';\n /** Whether the file upload field should be disabled (optional). */\n disabled?: boolean;\n /** The default value of the file upload field input (used to display a preview image when type is image). */\n defaultValue?: string | null;\n /**\n * Called with the chosen files when the user picks some: one, or several with `multiple`. The native `onChange`\n * gets the event.\n */\n onValueChange?(files: File[]): void;\n /**\n * The type of file to be uploaded (optional).\n * - 'image': upload an image file\n * - 'file': upload any file type\n */\n type?: 'image' | 'file';\n /** The text of the field, in English by default. */\n labels?: Partial<FileFieldLabels>;\n /** A line under the upload label, such as the files it takes. */\n hint?: React.ReactNode;\n}\n\n/** The text of the file field, for other languages. */\nexport interface FileFieldLabels {\n /** The upload button. */\n upload: React.ReactNode;\n /** Shown for a file field (`type=\"file\"`) with no file yet. */\n noFile: React.ReactNode;\n}\n\nconst defaultFileFieldLabels: FileFieldLabels = { upload: 'Upload a file', noFile: 'No file added' };\n\nfunction EmptyMarkupPlaceholder({\n type,\n defaultValue,\n noFileLabel,\n}: {\n type: 'image' | 'file';\n defaultValue?: string | null;\n noFileLabel: React.ReactNode;\n}) {\n if (type === 'file')\n return (\n <>\n <Icon name=\"file-csv\" className=\"roaster-file__icon\" />\n <span className=\"roaster-file__name\">{noFileLabel}</span>\n </>\n );\n\n if (defaultValue) {\n return <img src={defaultValue} alt=\"\" />;\n }\n\n return (\n <div className=\"roaster-file__placeholder\">\n <Icon name=\"image\" />\n </div>\n );\n}\n\nfunction Preview({ type, files }: { type: string; files: File[] }) {\n const file = files[0];\n const [imageUrl, setImageUrl] = React.useState<string>();\n\n // One object URL per file, released when the file changes or the preview goes away, so it doesn't leak memory.\n React.useEffect(() => {\n if (type !== 'image' || !file) return undefined;\n const url = URL.createObjectURL(file);\n setImageUrl(url);\n return () => URL.revokeObjectURL(url);\n }, [type, file]);\n\n if (type === 'image' && file) {\n return imageUrl ? <img src={imageUrl} alt={file.name} /> : null;\n }\n\n return (\n <>\n <Icon name=\"file-csv\" className=\"roaster-file__icon\" />\n <span className=\"roaster-file__name\">{files.map((chosen) => chosen.name).join(', ')}</span>\n </>\n );\n}\n\n/** A file upload field with a preview for images and the file name for other files. */\nexport const FileField = React.forwardRef<HTMLInputElement, FileFieldProps>((props, ref) => {\n const {\n id,\n label,\n name,\n disabled,\n description,\n error,\n className,\n style,\n onChange,\n onValueChange,\n type = 'image',\n accept = type === 'image' ? 'image/*' : '.csv, .xls',\n size = 'small',\n defaultValue,\n labels,\n hint,\n ...others\n } = props;\n const text = { ...defaultFileFieldLabels, ...labels };\n const uid = useUid(id);\n // Every chosen file: several with `multiple`.\n const [files, setFiles] = React.useState<File[]>([]);\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const chosen = [...(event.currentTarget.files ?? [])];\n setFiles(chosen);\n onChange?.(event);\n onValueChange?.(chosen);\n };\n\n return (\n <Field controlId={uid} label={label} description={description} error={error} className={className} style={style}>\n <div\n className={classNames('roaster-file', `roaster-file--${size}`)}\n data-state={files.length > 0 ? 'filled' : undefined}\n >\n <div className={type === 'image' ? 'roaster-file__image' : 'roaster-file__preview'}>\n {files.length === 0 ? (\n <EmptyMarkupPlaceholder type={type} defaultValue={defaultValue} noFileLabel={text.noFile} />\n ) : (\n <Preview type={type} files={files} />\n )}\n </div>\n <div className=\"roaster-file__button\">\n <span>\n <Icon name=\"arrow-up-from-bracket\" />\n {text.upload}\n {hint && <small className=\"roaster-file__hint\">{hint}</small>}\n </span>\n <input\n {...others}\n {...fieldControlProps(uid, { label, description, error }, others)}\n name={name}\n ref={ref}\n className=\"roaster-file__input\"\n type=\"file\"\n disabled={disabled}\n accept={accept}\n onChange={handleChange}\n />\n </div>\n </div>\n </Field>\n );\n});\n\nFileField.displayName = 'FileField';\n"],"names":[],"mappings":";;;;;;;;AAMA,MAAM,sBAAsB,GAAG,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,EAAE;AACnF,SAAS,sBAAsB,CAAC;AAChC,EAAE,IAAI;AACN,EAAE,YAAY;AACd,EAAE;AACF,CAAC,EAAE;AACH,EAAE,IAAI,IAAI,KAAK,MAAM;AACrB,IAAI,uBAAuB,IAAI,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE;AACtD,sBAAsB,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,oBAAoB,EAAE,CAAC;AACtF,sBAAsB,GAAG,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,oBAAoB,EAAE,QAAQ,EAAE,WAAW,EAAE;AAC5F,KAAK,EAAE,CAAC;AACR,EAAE,IAAI,YAAY,EAAE;AACpB,IAAI,uBAAuB,GAAG,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;AACrE,EAAE;AACF,EAAE,uBAAu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;AACA,SAAS,EAAE;AACX;AACA;AACA,GAAG,EAAE,CAAC;AACN,CAAC;AACD,SAAS,CAAC,WAAW,GAAG,WAAW;;"}
1
+ {"version":3,"file":"FileField.js","sources":["../../../../src/components/FileField/FileField.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames, useUid } from '@/utils';\nimport { Field, fieldControlProps, type FieldBaseProps } from '../Field';\nimport { RoasterIcon } from '@/components/Icon';\n\n/**\n * Every native `<input>` prop (`name`, `required`, `aria-*`, ...) is accepted and forwarded to the file input, with the\n * ref. `className` and `style` go to the field's wrapper.\n */\nexport interface FileFieldProps\n extends\n FieldBaseProps,\n Omit<React.ComponentPropsWithoutRef<'input'>, 'type' | 'size' | 'defaultValue' | 'value' | 'className' | 'style'> {\n /** The HTML ID attribute to be applied to the file upload field input element (optional). */\n id?: string;\n /** The name attribute to be applied to the file upload field input element (optional). */\n name?: string;\n /**\n * The accept attribute to be applied to the file upload field input element (optional).\n * Specifies the types of accepted files.\n */\n accept?: string;\n /**\n * The size of the file upload field (optional).\n * - 'small': render a smaller file upload field\n * - 'medium': render a larger file upload field\n */\n size?: 'small' | 'medium';\n /** Whether the file upload field should be disabled (optional). */\n disabled?: boolean;\n /** The default value of the file upload field input (used to display a preview image when type is image). */\n defaultValue?: string | null;\n /**\n * Called with the chosen files when the user picks some: one, or several with `multiple`. The native `onChange`\n * gets the event.\n */\n onValueChange?(files: File[]): void;\n /**\n * The type of file to be uploaded (optional).\n * - 'image': upload an image file\n * - 'file': upload any file type\n */\n type?: 'image' | 'file';\n /** The text of the field, in English by default. */\n labels?: Partial<FileFieldLabels>;\n /** A line under the upload label, such as the files it takes. */\n hint?: React.ReactNode;\n}\n\n/** The text of the file field, for other languages. */\nexport interface FileFieldLabels {\n /** The upload button. */\n upload: React.ReactNode;\n /** Shown for a file field (`type=\"file\"`) with no file yet. */\n noFile: React.ReactNode;\n}\n\nconst defaultFileFieldLabels: FileFieldLabels = { upload: 'Upload a file', noFile: 'No file added' };\n\nfunction EmptyMarkupPlaceholder({\n type,\n defaultValue,\n noFileLabel,\n}: {\n type: 'image' | 'file';\n defaultValue?: string | null;\n noFileLabel: React.ReactNode;\n}) {\n if (type === 'file')\n return (\n <>\n <RoasterIcon name=\"file-spreadsheet\" className=\"roaster-file__icon\" />\n <span className=\"roaster-file__name\">{noFileLabel}</span>\n </>\n );\n\n if (defaultValue) {\n return <img src={defaultValue} alt=\"\" />;\n }\n\n return (\n <div className=\"roaster-file__placeholder\">\n <RoasterIcon name=\"image\" />\n </div>\n );\n}\n\nfunction Preview({ type, files }: { type: string; files: File[] }) {\n const file = files[0];\n const [imageUrl, setImageUrl] = React.useState<string>();\n\n // One object URL per file, released when the file changes or the preview goes away, so it doesn't leak memory.\n React.useEffect(() => {\n if (type !== 'image' || !file) return undefined;\n const url = URL.createObjectURL(file);\n setImageUrl(url);\n return () => URL.revokeObjectURL(url);\n }, [type, file]);\n\n if (type === 'image' && file) {\n return imageUrl ? <img src={imageUrl} alt={file.name} /> : null;\n }\n\n return (\n <>\n <RoasterIcon name=\"file-spreadsheet\" className=\"roaster-file__icon\" />\n <span className=\"roaster-file__name\">{files.map((chosen) => chosen.name).join(', ')}</span>\n </>\n );\n}\n\n/** A file upload field with a preview for images and the file name for other files. */\nexport const FileField = React.forwardRef<HTMLInputElement, FileFieldProps>((props, ref) => {\n const {\n id,\n label,\n name,\n disabled,\n description,\n keepDescription,\n error,\n className,\n style,\n onChange,\n onValueChange,\n type = 'image',\n accept = type === 'image' ? 'image/*' : '.csv, .xls',\n size = 'small',\n defaultValue,\n labels,\n hint,\n ...others\n } = props;\n const text = { ...defaultFileFieldLabels, ...labels };\n const uid = useUid(id);\n // Every chosen file: several with `multiple`.\n const [files, setFiles] = React.useState<File[]>([]);\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const chosen = [...(event.currentTarget.files ?? [])];\n setFiles(chosen);\n onChange?.(event);\n onValueChange?.(chosen);\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\n className={classNames('roaster-file', `roaster-file--${size}`)}\n data-state={files.length > 0 ? 'filled' : undefined}\n >\n <div className={type === 'image' ? 'roaster-file__image' : 'roaster-file__preview'}>\n {files.length === 0 ? (\n <EmptyMarkupPlaceholder type={type} defaultValue={defaultValue} noFileLabel={text.noFile} />\n ) : (\n <Preview type={type} files={files} />\n )}\n </div>\n <div className=\"roaster-file__button\">\n <span>\n <RoasterIcon name=\"upload\" />\n {text.upload}\n {hint && <small className=\"roaster-file__hint\">{hint}</small>}\n </span>\n <input\n {...others}\n {...fieldControlProps(uid, { label, description, error, keepDescription }, others)}\n name={name}\n ref={ref}\n className=\"roaster-file__input\"\n type=\"file\"\n disabled={disabled}\n accept={accept}\n onChange={handleChange}\n />\n </div>\n </div>\n </Field>\n );\n});\n\nFileField.displayName = 'FileField';\n"],"names":[],"mappings":";;;;;;;;;AAMA,MAAM,sBAAsB,GAAG,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,EAAE;AACnF,SAAS,sBAAsB,CAAC;AAChC,EAAE,IAAI;AACN,EAAE,YAAY;AACd,EAAE;AACF,CAAC,EAAE;AACH,EAAE,IAAI,IAAI,KAAK,MAAM;AACrB,IAAI,uBAAuB,IAAI,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE;AACtD,sBAAsB,GAAG,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,SAAS,EAAE,oBAAoB,EAAE,CAAC;AACrG,sBAAsB,GAAG,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,oBAAoB,EAAE,QAAQ,EAAE,WAAW,EAAE;AAC5F,KAAK,EAAE,CAAC;AACR,EAAE,IAAI,YAAY,EAAE;AACpB,IAAI,uBAAuB,GAAG,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;AACrE,EAAE;AACF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ACrB,kBAAkB,SAAS,EAAE,qBAAqB;AAClD,kBAAkB,IAAI,EAAE,MAAM;AAC9B,kBAAkB,QAAQ;AAC1B,kBAAkB,MAAM;AACxB,kBAAkB,QAAQ,EAAE;AAC5B;AACA;AACA,aAAa,EAAE;AACf;AACA;AACA;AACA;AACA,GAAG;AACH,CAAC;AACD,SAAS,CAAC,WAAW,GAAG,WAAW;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Icon.js","sources":["../../../../src/components/Icon/Icon.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames } from '@/utils';\n\n/** Every native `<i>` prop (`id`, `data-*`, ...) is accepted and forwarded to it. */\nexport interface IconProps extends Omit<React.ComponentPropsWithoutRef<'i'>, 'children'> {\n /** The Font Awesome icon's name, without its `fa-` prefix: `xmark`, `circle-info`. */\n name: string;\n /**\n * What the icon means, for an icon that stands alone, such as a status. Leave it out for an icon next to text that\n * says the same, or inside a button with its own name: the icon is then hidden from screen readers.\n */\n label?: string;\n}\n\n/**\n * A Font Awesome icon, in the regular style: `<Icon name=\"xmark\" />`. It needs `fontawesome.css` from the CDN. Use\n * `IconBadge` for an icon on a colored, rounded background.\n */\nexport const Icon = React.forwardRef<HTMLElement, IconProps>(({ name, label, className, ...others }, ref) => (\n <i\n {...(label ? { role: 'img', 'aria-label': label } : { 'aria-hidden': true })}\n {...others}\n ref={ref}\n className={classNames('fa-regular', `fa-${name}`, className)}\n />\n));\n\nIcon.displayName = 'Icon';\n"],"names":[],"mappings":";;;;;AAIY,MAAC,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,qBAAqB,GAAG;AACxG,EAAE,GAAG;AACL,EAAE;AACF,IAAI,GAAG,KAAK,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE;AAC7E,IAAI,GAAG,MAAM;AACb,IAAI,GAAG;AACP,IAAI,SAAS,EAAE,UAAU,CAAC,YAAY,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,EAAE,SAAS;AAC/D;AACA,CAAC;AACD,IAAI,CAAC,WAAW,GAAG,MAAM;;"}
1
+ {"version":3,"file":"Icon.js","sources":["../../../../src/components/Icon/Icon.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames } from '@/utils';\n\n/**\n * Every native `<i>` prop (`id`, `data-*`, ...) is accepted and forwarded to it.\n *\n * @deprecated `Icon` is deprecated: pass your icon set's own element.\n */\nexport interface IconProps extends Omit<React.ComponentPropsWithoutRef<'i'>, 'children'> {\n /** The Font Awesome icon's name, without its `fa-` prefix: `xmark`, `circle-info`. */\n name: string;\n /**\n * What the icon means, for an icon that stands alone, such as a status. Leave it out for an icon next to text that\n * says the same, or inside a button with its own name: the icon is then hidden from screen readers.\n */\n label?: string;\n}\n\n/**\n * Deprecated: pass your icon set's own element instead, such as Font Awesome's\n * `<i className=\"fa-regular fa-house\" aria-hidden=\"true\" />`. Roaster's components draw their own icons, and an app's\n * icons are the app's, from the icon set it loads.\n *\n * A Font Awesome icon, in the regular style: `<Icon name=\"house\" />`. It needs Font Awesome, which the app loads. Use\n * `IconBadge` for an icon on a colored, rounded background.\n *\n * @deprecated Pass your icon set's own element instead, such as Font Awesome's\n * `<i className=\"fa-regular fa-house\" aria-hidden=\"true\" />`.\n */\nexport const Icon = React.forwardRef<HTMLElement, IconProps>(({ name, label, className, ...others }, ref) => (\n <i\n {...(label ? { role: 'img', 'aria-label': label } : { 'aria-hidden': true })}\n {...others}\n ref={ref}\n className={classNames('fa-regular', `fa-${name}`, className)}\n />\n));\n\nIcon.displayName = 'Icon';\n"],"names":[],"mappings":";;;;;AAIY,MAAC,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,qBAAqB,GAAG;AACxG,EAAE,GAAG;AACL,EAAE;AACF,IAAI,GAAG,KAAK,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE;AAC7E,IAAI,GAAG,MAAM;AACb,IAAI,GAAG;AACP,IAAI,SAAS,EAAE,UAAU,CAAC,YAAY,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,EAAE,SAAS;AAC/D;AACA,CAAC;AACD,IAAI,CAAC,WAAW,GAAG,MAAM;;"}
@@ -0,0 +1,10 @@
1
+ 'use client';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { classNames } from '../../utils/classNames/index.js';
4
+
5
+ function RoasterIcon({ name, className }) {
6
+ return /* @__PURE__ */ jsx("i", { className: classNames("roaster-icon", `roaster-icon--${name}`, className), "aria-hidden": "true" });
7
+ }
8
+
9
+ export { RoasterIcon };
10
+ //# sourceMappingURL=RoasterIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RoasterIcon.js","sources":["../../../../src/components/Icon/RoasterIcon.tsx"],"sourcesContent":["import { classNames } from '@/utils';\n\n/** The icons Roaster draws, each a `roaster-icon--<name>` class of roaster.css: Lucide's, by their Lucide names. */\nexport type RoasterIconName =\n | 'x'\n | 'check'\n | 'chevron-up'\n | 'chevron-down'\n | 'chevron-left'\n | 'chevron-right'\n | 'arrow-up'\n | 'arrow-down'\n | 'arrow-left'\n | 'arrow-right'\n | 'info'\n | 'menu'\n | 'image'\n | 'file-spreadsheet'\n | 'upload'\n | 'bold'\n | 'italic'\n | 'underline'\n | 'strikethrough'\n | 'link'\n | 'list'\n | 'list-ordered'\n | 'heading-1'\n | 'heading-2'\n | 'heading-3'\n | 'square-pen'\n | 'save'\n | 'trash';\n\nexport interface RoasterIconProps {\n name: RoasterIconName;\n className?: string;\n}\n\n/**\n * One of the icons Roaster's components draw, such as a close button's cross: `<RoasterIcon name=\"x\" />`. It needs no\n * icon font, and is hidden from screen readers, as the control around it is named. Internal: an app's own icons go\n * through `Icon`.\n */\nexport function RoasterIcon({ name, className }: RoasterIconProps) {\n return <i className={classNames('roaster-icon', `roaster-icon--${name}`, className)} aria-hidden=\"true\" />;\n}\n"],"names":[],"mappings":";;;;AAGO,SAAS,WAAW,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;AACjD,EAAE,uBAAuB,GAAG,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,cAAc,EAAE,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC;AACvI;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"IconBadge.js","sources":["../../../../src/components/IconBadge/IconBadge.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames } from '@/utils';\n\n/** The tones of the badge's background. Without one, it has none. */\nexport type IconBadgeTone = 'neutral' | 'primary' | 'info' | 'success' | 'danger';\n\n/**\n * Every native `<span>` prop (`id`, `aria-*`, `data-*`, ...) is accepted and forwarded to it, except the obsolete\n * `color`, left out so that v1's `color` prop is an error rather than ignored: use `tone`.\n */\nexport interface IconBadgeProps extends Omit<React.ComponentPropsWithoutRef<'span'>, 'color'> {\n /** The icon or image. */\n children: React.ReactNode;\n /** The background's tone. */\n tone?: IconBadgeTone;\n /**\n * 36px (`medium`) or 20px (`small`). In a Timeline.Item, it takes the timeline marker's size.\n * @defaultValue 'medium'\n */\n size?: 'small' | 'medium';\n}\n\n/**\n * A round badge around an icon or an image, in a tone. For the icon alone, use `Icon`; for a description on hover and\n * focus, put a focusable element in a `Tooltip`.\n */\nexport const IconBadge = React.forwardRef<HTMLSpanElement, IconBadgeProps>((props, ref) => {\n const { tone, children, size = 'medium', className, ...otherProps } = props;\n\n return (\n <span\n {...otherProps}\n ref={ref}\n className={classNames(\n 'roaster-icon-badge',\n { 'roaster-icon-badge--small': size === 'small', [`roaster-icon-badge--${tone}`]: tone },\n className\n )}\n >\n {children}\n </span>\n );\n});\n\nIconBadge.displayName = 'IconBadge';\n"],"names":[],"mappings":";;;;;AAIY,MAAC,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AAC1D,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,GAAG,QAAQ,EAAE,SAAS,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK;AAC7E,EAAE,uBAAuB,GAAG;AAC5B,IAAI,MAAM;AACV,IAAI;AACJ,MAAM,GAAG,UAAU;AACnB,MAAM,GAAG;AACT,MAAM,SAAS,EAAE,UAAU;AAC3B,QAAQ,oBAAoB;AAC5B,QAAQ,EAAE,2BAA2B,EAAE,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE;AAChG,QAAQ;AACR,OAAO;AACP,MAAM;AACN;AACA,GAAG;AACH,CAAC;AACD,SAAS,CAAC,WAAW,GAAG,WAAW;;"}
1
+ {"version":3,"file":"IconBadge.js","sources":["../../../../src/components/IconBadge/IconBadge.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames } from '@/utils';\n\n/** The tones of the badge's background. Without one, it has none. */\nexport type IconBadgeTone = 'neutral' | 'primary' | 'info' | 'success' | 'danger';\n\n/**\n * Every native `<span>` prop (`id`, `aria-*`, `data-*`, ...) is accepted and forwarded to it, except the obsolete\n * `color`, left out so that v1's `color` prop is an error rather than ignored: use `tone`.\n */\nexport interface IconBadgeProps extends Omit<React.ComponentPropsWithoutRef<'span'>, 'color'> {\n /** The icon or image. */\n children: React.ReactNode;\n /** The background's tone. */\n tone?: IconBadgeTone;\n /**\n * 36px (`medium`) or 20px (`small`). In a Timeline.Item, it takes the timeline marker's size.\n * @defaultValue 'medium'\n */\n size?: 'small' | 'medium';\n}\n\n/**\n * A round badge around an icon or an image, in a tone. For a description on hover and focus, put a focusable element\n * in a `Tooltip`.\n */\nexport const IconBadge = React.forwardRef<HTMLSpanElement, IconBadgeProps>((props, ref) => {\n const { tone, children, size = 'medium', className, ...otherProps } = props;\n\n return (\n <span\n {...otherProps}\n ref={ref}\n className={classNames(\n 'roaster-icon-badge',\n { 'roaster-icon-badge--small': size === 'small', [`roaster-icon-badge--${tone}`]: tone },\n className\n )}\n >\n {children}\n </span>\n );\n});\n\nIconBadge.displayName = 'IconBadge';\n"],"names":[],"mappings":";;;;;AAIY,MAAC,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AAC1D,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,GAAG,QAAQ,EAAE,SAAS,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK;AAC7E,EAAE,uBAAuB,GAAG;AAC5B,IAAI,MAAM;AACV,IAAI;AACJ,MAAM,GAAG,UAAU;AACnB,MAAM,GAAG;AACT,MAAM,SAAS,EAAE,UAAU;AAC3B,QAAQ,oBAAoB;AAC5B,QAAQ,EAAE,2BAA2B,EAAE,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE;AAChG,QAAQ;AACR,OAAO;AACP,MAAM;AACN;AACA,GAAG;AACH,CAAC;AACD,SAAS,CAAC,WAAW,GAAG,WAAW;;"}
@@ -2,7 +2,8 @@
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import * as React from 'react';
4
4
  import { ButtonIcon } from '../ButtonIcon/ButtonIcon.js';
5
- import { Icon } from '../Icon/Icon.js';
5
+ import '../Icon/Icon.js';
6
+ import { RoasterIcon } from '../Icon/RoasterIcon.js';
6
7
  import { useControllableState } from '../../utils/useControllableState/index.js';
7
8
  import { useUid } from '../../utils/useUid/index.js';
8
9
  import { classNames } from '../../utils/classNames/index.js';
@@ -90,7 +91,7 @@ const Modal = React.forwardRef((props, ref) => {
90
91
  children: [
91
92
  /* @__PURE__ */ jsxs("div", { className: "roaster-modal__header", children: [
92
93
  title && /* @__PURE__ */ jsx("h2", { className: "roaster-modal__title", id: titleId, children: title }),
93
- /* @__PURE__ */ jsx(ButtonIcon, { size: "medium", "aria-label": text.close, onClick: () => setOpen(false), children: /* @__PURE__ */ jsx(Icon, { name: "xmark" }) }),
94
+ /* @__PURE__ */ jsx(ButtonIcon, { size: "medium", "aria-label": text.close, onClick: () => setOpen(false), children: /* @__PURE__ */ jsx(RoasterIcon, { name: "x" }) }),
94
95
  description && /* @__PURE__ */ jsx("p", { className: "roaster-modal__description", id: descriptionId, children: description })
95
96
  ] }),
96
97
  /* @__PURE__ */ jsx("div", { className: "roaster-modal__body", children }),
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.js","sources":["../../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames, useControllableState, useUid } from '@/utils';\nimport { ModalLabels, ModalProps } from './types';\nimport { ButtonIcon } from '../ButtonIcon';\nimport { Icon } from '@/components/Icon';\n\nconst defaultModalLabels: ModalLabels = { close: 'Close' };\n\n// A layout effect in the browser (the modal opens before it paints), and nothing on the server, which warns about one.\nconst useClientLayoutEffect = typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect;\n\n/** Whether the pointer event happened outside the dialog's box, on its backdrop. */\nfunction onBackdrop(dialog: HTMLDialogElement, event: React.MouseEvent) {\n const box = dialog.getBoundingClientRect();\n return event.clientX < box.left || event.clientX > box.right || event.clientY < box.top || event.clientY > box.bottom;\n}\n\n/**\n * A dialog over the page (`<dialog>` opened with `showModal()`), with a title, content and an optional footer. The page\n * behind is inert and doesn't scroll; the close button, Escape and a click outside ask to close it; the focus goes\n * back where it was. Open it with `open`, or with `useModal().openModal()` inside a ModalProvider.\n */\nexport const Modal = React.forwardRef<HTMLDialogElement, ModalProps>((props, ref) => {\n const {\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n title,\n description,\n size = 'small',\n sheet = false,\n footer,\n labels,\n children,\n className,\n onCancel,\n onMouseDown,\n onClick,\n ...others\n } = props;\n const [open, setOpen] = useControllableState({ value: openProp, defaultValue: defaultOpen, onChange: onOpenChange });\n const text = { ...defaultModalLabels, ...labels };\n const titleId = useUid();\n const descriptionId = useUid();\n const dialogRef = React.useRef<HTMLDialogElement | null>(null);\n const setRefs = React.useCallback(\n (dialog: HTMLDialogElement | null) => {\n dialogRef.current = dialog;\n if (typeof ref === 'function') ref(dialog);\n else if (ref) ref.current = dialog;\n },\n [ref]\n );\n // Set on mousedown, so that a selection dragged from inside the dialog to outside doesn't close it.\n const pressedOutside = React.useRef(false);\n\n // Shown as a modal once mounted. Unmounting removes it without close(), so the focus goes back by hand.\n useClientLayoutEffect(() => {\n if (!open) return undefined;\n const dialog = dialogRef.current;\n const previous = document.activeElement;\n if (dialog && !dialog.open) dialog.showModal();\n return () => {\n if (dialog?.open) dialog.close();\n if (previous instanceof HTMLElement && previous.isConnected) previous.focus({ preventScroll: true });\n };\n }, [open]);\n\n if (!open) return null;\n\n return (\n // The mouse handlers only add a click outside to close it; the keyboard has Escape, through the cancel event.\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions\n <dialog\n aria-labelledby={title ? titleId : undefined}\n aria-describedby={description ? descriptionId : undefined}\n {...others}\n ref={setRefs}\n className={classNames(\n 'roaster-modal',\n size !== 'small' && `roaster-modal--${size}`,\n sheet && 'roaster-modal--sheet',\n className\n )}\n onCancel={(event) => {\n onCancel?.(event);\n // Escape: the state closes the dialog, so a parent that keeps it open is obeyed.\n event.preventDefault();\n setOpen(false);\n }}\n onMouseDown={(event) => {\n onMouseDown?.(event);\n pressedOutside.current = event.target === event.currentTarget && onBackdrop(event.currentTarget, event);\n }}\n onClick={(event) => {\n onClick?.(event);\n const outside = event.target === event.currentTarget && onBackdrop(event.currentTarget, event);\n if (pressedOutside.current && outside) setOpen(false);\n pressedOutside.current = false;\n }}\n >\n <div className=\"roaster-modal__header\">\n {title && (\n <h2 className=\"roaster-modal__title\" id={titleId}>\n {title}\n </h2>\n )}\n <ButtonIcon size=\"medium\" aria-label={text.close} onClick={() => setOpen(false)}>\n <Icon name=\"xmark\" />\n </ButtonIcon>\n {description && (\n <p className=\"roaster-modal__description\" id={descriptionId}>\n {description}\n </p>\n )}\n </div>\n <div className=\"roaster-modal__body\">{children}</div>\n {footer && <div className=\"roaster-modal__footer\">{footer}</div>}\n </dialog>\n );\n});\n\nModal.displayName = 'Modal';\n"],"names":[],"mappings":";;;;;;;;;AAMA,MAAM,kBAAkB,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE;AAC7C,MAAM,qBAAqB,GAAG,OAAO,MAAM,KAAK,WAAW,GAAG,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,eAAe;AACrG,SAAS,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE;AACnC,EAAE,MAAM,GAAG,GAAG,MAAM,CAAC,qBAAqB,EAAE;AAC5C,EAAE,OAAO,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC,MAAM;AACvH;AACY,MAAC,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AACtD,EAAE,MAAM;AACR,IAAI,IAAI,EAAE,QAAQ;AAClB,IAAI,WAAW,GAAG,KAAK;AACvB,IAAI,YAAY;AAChB,IAAI,KAAK;AACT,IAAI,WAAW;AACf,IAAI,IAAI,GAAG,OAAO;AAClB,IAAI,KAAK,GAAG,KAAK;AACjB,IAAI,MAAM;AACV,IAAI,MAAM;AACV,IAAI,QAAQ;AACZ,IAAI,SAAS;AACb,IAAI,QAAQ;AACZ,IAAI,WAAW;AACf,IAAI,OAAO;AACX,IAAI,GAAG;AACP,GAAG,GAAG,KAAK;AAC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/D,UAAU,cAAc,CAAC,OAAO,GAAG,KAAK;AACxC,QAAQ,CAAC;AACT,QAAQ,QAAQ,EAAE;AAClB,0BAA0B,IAAI,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,uBAAuB,EAAE,QAAQ,EAAE;AACtF,YAAY,KAAK,oBAAoB,GAAG,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,sBAAsB,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AACnH,4BAA4B,GAAG,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,QAAQ,kBAAkB,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AAChL,YAAY,WAAW,oBAAoB,GAAG,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,4BAA4B,EAAE,EAAE,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE;AACzI,WAAW,EAAE,CAAC;AACd,0BAA0B,GAAG,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,qBAAqB,EAAE,QAAQ,EAAE,CAAC;AACpF,UAAU,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,EAAE;AACvG;AACA;AACA;AACA;AACA,CAAC;AACD,KAAK,CAAC,WAAW,GAAG,OAAO;;"}
1
+ {"version":3,"file":"Modal.js","sources":["../../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames, useControllableState, useUid } from '@/utils';\nimport { ModalLabels, ModalProps } from './types';\nimport { ButtonIcon } from '../ButtonIcon';\nimport { RoasterIcon } from '@/components/Icon';\n\nconst defaultModalLabels: ModalLabels = { close: 'Close' };\n\n// A layout effect in the browser (the modal opens before it paints), and nothing on the server, which warns about one.\nconst useClientLayoutEffect = typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect;\n\n/** Whether the pointer event happened outside the dialog's box, on its backdrop. */\nfunction onBackdrop(dialog: HTMLDialogElement, event: React.MouseEvent) {\n const box = dialog.getBoundingClientRect();\n return event.clientX < box.left || event.clientX > box.right || event.clientY < box.top || event.clientY > box.bottom;\n}\n\n/**\n * A dialog over the page (`<dialog>` opened with `showModal()`), with a title, content and an optional footer. The page\n * behind is inert and doesn't scroll; the close button, Escape and a click outside ask to close it; the focus goes\n * back where it was. Open it with `open`, or with `useModal().openModal()` inside a ModalProvider.\n */\nexport const Modal = React.forwardRef<HTMLDialogElement, ModalProps>((props, ref) => {\n const {\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n title,\n description,\n size = 'small',\n sheet = false,\n footer,\n labels,\n children,\n className,\n onCancel,\n onMouseDown,\n onClick,\n ...others\n } = props;\n const [open, setOpen] = useControllableState({ value: openProp, defaultValue: defaultOpen, onChange: onOpenChange });\n const text = { ...defaultModalLabels, ...labels };\n const titleId = useUid();\n const descriptionId = useUid();\n const dialogRef = React.useRef<HTMLDialogElement | null>(null);\n const setRefs = React.useCallback(\n (dialog: HTMLDialogElement | null) => {\n dialogRef.current = dialog;\n if (typeof ref === 'function') ref(dialog);\n else if (ref) ref.current = dialog;\n },\n [ref]\n );\n // Set on mousedown, so that a selection dragged from inside the dialog to outside doesn't close it.\n const pressedOutside = React.useRef(false);\n\n // Shown as a modal once mounted. Unmounting removes it without close(), so the focus goes back by hand.\n useClientLayoutEffect(() => {\n if (!open) return undefined;\n const dialog = dialogRef.current;\n const previous = document.activeElement;\n if (dialog && !dialog.open) dialog.showModal();\n return () => {\n if (dialog?.open) dialog.close();\n if (previous instanceof HTMLElement && previous.isConnected) previous.focus({ preventScroll: true });\n };\n }, [open]);\n\n if (!open) return null;\n\n return (\n // The mouse handlers only add a click outside to close it; the keyboard has Escape, through the cancel event.\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions\n <dialog\n aria-labelledby={title ? titleId : undefined}\n aria-describedby={description ? descriptionId : undefined}\n {...others}\n ref={setRefs}\n className={classNames(\n 'roaster-modal',\n size !== 'small' && `roaster-modal--${size}`,\n sheet && 'roaster-modal--sheet',\n className\n )}\n onCancel={(event) => {\n onCancel?.(event);\n // Escape: the state closes the dialog, so a parent that keeps it open is obeyed.\n event.preventDefault();\n setOpen(false);\n }}\n onMouseDown={(event) => {\n onMouseDown?.(event);\n pressedOutside.current = event.target === event.currentTarget && onBackdrop(event.currentTarget, event);\n }}\n onClick={(event) => {\n onClick?.(event);\n const outside = event.target === event.currentTarget && onBackdrop(event.currentTarget, event);\n if (pressedOutside.current && outside) setOpen(false);\n pressedOutside.current = false;\n }}\n >\n <div className=\"roaster-modal__header\">\n {title && (\n <h2 className=\"roaster-modal__title\" id={titleId}>\n {title}\n </h2>\n )}\n <ButtonIcon size=\"medium\" aria-label={text.close} onClick={() => setOpen(false)}>\n <RoasterIcon name=\"x\" />\n </ButtonIcon>\n {description && (\n <p className=\"roaster-modal__description\" id={descriptionId}>\n {description}\n </p>\n )}\n </div>\n <div className=\"roaster-modal__body\">{children}</div>\n {footer && <div className=\"roaster-modal__footer\">{footer}</div>}\n </dialog>\n );\n});\n\nModal.displayName = 'Modal';\n"],"names":[],"mappings":";;;;;;;;;;AAMA,MAAM,kBAAkB,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE;AAC7C,MAAM,qBAAqB,GAAG,OAAO,MAAM,KAAK,WAAW,GAAG,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,eAAe;AACrG,SAAS,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE;AACnC,EAAE,MAAM,GAAG,GAAG,MAAM,CAAC,qBAAqB,EAAE;AAC5C,EAAE,OAAO,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC,KAAK,IAAI,KAA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ACd,0BAA0B,GAAG,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,qBAAqB,EAAE,QAAQ,EAAE,CAAC;AACpF,UAAU,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,EAAE;AACvG;AACA;AACA;AACA;AACA,CAAC;AACD,KAAK,CAAC,WAAW,GAAG,OAAO;;"}
@@ -2,7 +2,8 @@
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import * as React from 'react';
4
4
  import { Button } from '../Button/Button.js';
5
- import { Icon } from '../Icon/Icon.js';
5
+ import '../Icon/Icon.js';
6
+ import { RoasterIcon } from '../Icon/RoasterIcon.js';
6
7
  import { classNames } from '../../utils/classNames/index.js';
7
8
 
8
9
  const defaultPaginationLabels = {
@@ -20,10 +21,10 @@ const Pagination = React.forwardRef(function Pagination2({ onNextPage, onPreviou
20
21
  disabled: !hasPreviousPage,
21
22
  onClick: () => onPreviousPage?.(),
22
23
  "aria-label": text.previousPage,
23
- children: /* @__PURE__ */ jsx(Icon, { name: "chevron-left" })
24
+ children: /* @__PURE__ */ jsx(RoasterIcon, { name: "chevron-left" })
24
25
  }
25
26
  ),
26
- /* @__PURE__ */ jsx(Button, { variant: "secondary", disabled: !hasNextPage, onClick: () => onNextPage?.(), "aria-label": text.nextPage, children: /* @__PURE__ */ jsx(Icon, { name: "chevron-right" }) })
27
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", disabled: !hasNextPage, onClick: () => onNextPage?.(), "aria-label": text.nextPage, children: /* @__PURE__ */ jsx(RoasterIcon, { name: "chevron-right" }) })
27
28
  ] });
28
29
  });
29
30
 
@@ -1 +1 @@
1
- {"version":3,"file":"Pagination.js","sources":["../../../../src/components/Pagination/Pagination.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Button } from '../Button';\nimport { classNames } from '@/utils';\nimport { Icon } from '@/components/Icon';\n\n/** The text of the pagination, for other languages. */\nexport interface PaginationLabels {\n /** The name of the navigation, read by screen readers. */\n navigation: string;\n /** The name of the previous page button, read by screen readers. */\n previousPage: string;\n /** The name of the next page button, read by screen readers. */\n nextPage: string;\n}\n\nconst defaultPaginationLabels: PaginationLabels = {\n navigation: 'Pagination',\n previousPage: 'Previous page',\n nextPage: 'Next page',\n};\n\n/** Every native `<nav>` prop (`id`, `data-*`, ...) is accepted and forwarded to it. */\nexport interface PaginationProps extends React.ComponentPropsWithoutRef<'nav'> {\n /** Called when the next page button is clicked. */\n onNextPage?: () => void;\n /** Called when the previous page button is clicked. */\n onPreviousPage?: () => void;\n /** Whether there is a next page: the button is disabled otherwise. */\n hasNextPage?: boolean;\n /** Whether there is a previous page: the button is disabled otherwise. */\n hasPreviousPage?: boolean;\n /** The text of the pagination, in English by default. */\n labels?: Partial<PaginationLabels>;\n}\n\n/** Previous and next buttons to move through pages of results, in a named `nav`. */\nexport const Pagination = React.forwardRef<HTMLElement, PaginationProps>(function Pagination(\n { onNextPage, onPreviousPage, hasNextPage, hasPreviousPage, className, labels, ...others },\n ref\n) {\n const text = { ...defaultPaginationLabels, ...labels };\n return (\n <nav aria-label={text.navigation} {...others} ref={ref} className={classNames('roaster-pagination', className)}>\n <Button\n variant=\"secondary\"\n disabled={!hasPreviousPage}\n onClick={() => onPreviousPage?.()}\n aria-label={text.previousPage}\n >\n <Icon name=\"chevron-left\" />\n </Button>\n <Button variant=\"secondary\" disabled={!hasNextPage} onClick={() => onNextPage?.()} aria-label={text.nextPage}>\n <Icon name=\"chevron-right\" />\n </Button>\n </nav>\n );\n});\n"],"names":[],"mappings":";;;;;;;AAMA,MAAM,uBAAuB,GAAG;AAChC,EAAE,UAAU,EAAE,YAAY;AAC1B,EAAE,YAAY,EAAE,eAAe;AAC/B,EAAE,QAAQ,EAAE;AACZ,CAAC;AACW,MAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,SAAS,WAAW,CAAC,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,EAAE;AACjK,EAAE,MAAM,IAAI,GAAG,EAAE,GAAG,uBAAuB,EAAE,GAAG,MAAM,EAAE;AACxD,EAAE,uBAAuB,IAAI,CAAC,KAAK,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,UAAU,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,CAAC,oBAAoB,EAAE,SAAS,CAAC,EAAE,QAAQ,EAAE;AACxJ,oBAAoB,GAAG;AACvB,MAAM,MAAM;AACZ,MAAM;AACN,QAAQ,OAAO,EAAE,WAAW;AAC5B,QAAQ,QAAQ,EAAE,CAAC,eAAe;AAClC,QAAQ,OAAO,EAAE,MAAM,cAAc,IAAI;AACzC,QAAQ,YAAY,EAAE,IAAI,CAAC,YAAY;AACvC,QAAQ,QAAQ,kBAAkB,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE;AACpE;AACA,KAAK;AACL,oBAAoB,GAAG,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,MAAM,UAAU,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,kBAAkB,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,EAAE;AAC5M,GAAG,EAAE,CAAC;AACN,CAAC;;"}
1
+ {"version":3,"file":"Pagination.js","sources":["../../../../src/components/Pagination/Pagination.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Button } from '../Button';\nimport { classNames } from '@/utils';\nimport { RoasterIcon } from '@/components/Icon';\n\n/** The text of the pagination, for other languages. */\nexport interface PaginationLabels {\n /** The name of the navigation, read by screen readers. */\n navigation: string;\n /** The name of the previous page button, read by screen readers. */\n previousPage: string;\n /** The name of the next page button, read by screen readers. */\n nextPage: string;\n}\n\nconst defaultPaginationLabels: PaginationLabels = {\n navigation: 'Pagination',\n previousPage: 'Previous page',\n nextPage: 'Next page',\n};\n\n/** Every native `<nav>` prop (`id`, `data-*`, ...) is accepted and forwarded to it. */\nexport interface PaginationProps extends React.ComponentPropsWithoutRef<'nav'> {\n /** Called when the next page button is clicked. */\n onNextPage?: () => void;\n /** Called when the previous page button is clicked. */\n onPreviousPage?: () => void;\n /** Whether there is a next page: the button is disabled otherwise. */\n hasNextPage?: boolean;\n /** Whether there is a previous page: the button is disabled otherwise. */\n hasPreviousPage?: boolean;\n /** The text of the pagination, in English by default. */\n labels?: Partial<PaginationLabels>;\n}\n\n/** Previous and next buttons to move through pages of results, in a named `nav`. */\nexport const Pagination = React.forwardRef<HTMLElement, PaginationProps>(function Pagination(\n { onNextPage, onPreviousPage, hasNextPage, hasPreviousPage, className, labels, ...others },\n ref\n) {\n const text = { ...defaultPaginationLabels, ...labels };\n return (\n <nav aria-label={text.navigation} {...others} ref={ref} className={classNames('roaster-pagination', className)}>\n <Button\n variant=\"secondary\"\n disabled={!hasPreviousPage}\n onClick={() => onPreviousPage?.()}\n aria-label={text.previousPage}\n >\n <RoasterIcon name=\"chevron-left\" />\n </Button>\n <Button variant=\"secondary\" disabled={!hasNextPage} onClick={() => onNextPage?.()} aria-label={text.nextPage}>\n <RoasterIcon name=\"chevron-right\" />\n </Button>\n </nav>\n );\n});\n"],"names":[],"mappings":";;;;;;;;AAMA,MAAM,uBAAuB,GAAG;AAChC,EAAE,UAAU,EAAE,YAAY;AAC1B,EAAE,YAAY,EAAE,eAAe;AAC/B,EAAE,QAAQ,EAAE;AACZ,CAAC;AACW,MAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,SAAS,WAAW,CAAC,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,EAAE;AACjK,EAAE,MAAM,IAAI,GAAG,EAAE,GAAG,uBAAuB,EAAE,GAAG,MAAM,EAAE;AACxD,EAAE,uBAAuB,IAAI,CAAC,KAAK,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,UAAU,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,CAAC,oBAAoB,EAAE,SAAS,CAAC,EAAE,QAAQ,EAAE;AACxJ,oBAAoB,GAAG;AACvB,MAAM,MAAM;AACZ,MAAM;AACN,QAAQ,OAAO,EAAE,WAAW;AAC5B,QAAQ,QAAQ,EAAE,CAAC,eAAe;AAClC,QAAQ,OAAO,EAAE,MAAM,cAAc,IAAI;AACzC,QAAQ,YAAY,EAAE,IAAI,CAAC,YAAY;AACvC,QAAQ,QAAQ,kBAAkB,GAAG,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE;AAC3E;AACA,KAAK;AACL,oBAAoB,GAAG,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,MAAM,UAAU,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,kBAAkB,GAAG,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,EAAE;AACnN,GAAG,EAAE,CAAC;AACN,CAAC;;"}
@@ -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,K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MAAM;AACN,QAAQ,GAAG,MAAM;AACjB,QAAQ,GAAG,iBAAiB,CAAC,GAAG,EAAE,EAAS,WAAW,EAAE,KAAK,EAAE,EAAE,MAAM,CAAC;AACxE,QAAQ,GAAG;AACX,QAAQ,SAAS,EAAE,sBAAsB;AACzC,QAAQ,GAAG;AACX,QAAQ,GAAG;AACX,QAAQ,IAAI;AACZ,QAAQ,IAAI;AACZ,QAAQ,IAAI,EAAE,OAAO;AACrB,QAAQ,QAAQ;AAChB,QAAQ,KAAK,EAAE,OAAO;AACtB,QAAQ,QAAQ,EAAE,YAAY;AAC9B,QAAQ,KAAK,EAAE,EAAE,yBAAyB,EAAE,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC;AAChE;AACA,KAAK;AACL,oBAAoB,GAAG,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,sBAAsB,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE;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,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,QAAQ,EAAE;AACpF,wBAAwB,GAAG;AAC3B,UAAU,OAAO;AACjB,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;AACf,YAAY,SAAS,EAAE,sBAAsB;AAC7C,YAAY,GAAG;AACf,YAAY,GAAG;AACf,YAAY,IAAI;AAChB,YAAY,IAAI;AAChB,YAAY,IAAI,EAAE,OAAO;AACzB,YAAY,QAAQ;AACpB,YAAY,KAAK,EAAE,OAAO;AAC1B,YAAY,QAAQ,EAAE,YAAY;AAClC,YAAY,KAAK,EAAE,EAAE,yBAAyB,EAAE,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC;AACpE;AACA,SAAS;AACT,wBAAwB,GAAG,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,sBAAsB,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 },