@atom-learning/components 9.0.0-beta.5 → 10.0.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 (220) hide show
  1. package/dist/components/alert-dialog/AlertDialog.context.js +9 -6
  2. package/dist/components/alert-dialog/AlertDialog.context.js.map +1 -1
  3. package/dist/components/alert-dialog/alert-context/reducer.js +1 -5
  4. package/dist/components/alert-dialog/alert-context/reducer.js.map +1 -1
  5. package/dist/components/alert-dialog/alert-context/types.d.ts +1 -2
  6. package/dist/components/avatar/Avatar.js +5 -6
  7. package/dist/components/avatar/Avatar.js.map +1 -1
  8. package/dist/components/avatar/AvatarIcon.js +2 -2
  9. package/dist/components/avatar/AvatarIcon.js.map +1 -1
  10. package/dist/components/avatar/AvatarInitial.js +2 -2
  11. package/dist/components/avatar/AvatarInitial.js.map +1 -1
  12. package/dist/components/badge/Badge.context.js +12 -13
  13. package/dist/components/badge/Badge.context.js.map +1 -1
  14. package/dist/components/badge/Badge.js +4 -3
  15. package/dist/components/badge/Badge.js.map +1 -1
  16. package/dist/components/badge/BadgeText.js +3 -3
  17. package/dist/components/badge/BadgeText.js.map +1 -1
  18. package/dist/components/banner/Banner.context.js +13 -14
  19. package/dist/components/banner/Banner.context.js.map +1 -1
  20. package/dist/components/banner/banner-regular/BannerRegularActions.js +2 -8
  21. package/dist/components/banner/banner-regular/BannerRegularActions.js.map +1 -1
  22. package/dist/components/banner/banner-regular/BannerRegularButton.js +2 -2
  23. package/dist/components/banner/banner-regular/BannerRegularButton.js.map +1 -1
  24. package/dist/components/banner/banner-regular/BannerRegularDismiss.js +1 -1
  25. package/dist/components/banner/banner-regular/BannerRegularDismiss.js.map +1 -1
  26. package/dist/components/banner/banner-slim/BannerSlimButton.js +2 -2
  27. package/dist/components/banner/banner-slim/BannerSlimButton.js.map +1 -1
  28. package/dist/components/banner/banner-slim/BannerSlimContainer.js +4 -13
  29. package/dist/components/banner/banner-slim/BannerSlimContainer.js.map +1 -1
  30. package/dist/components/button/Button.js +5 -1
  31. package/dist/components/button/Button.js.map +1 -1
  32. package/dist/components/calendar/Calendar.d.ts +1 -1
  33. package/dist/components/calendar/Calendar.js +4 -2
  34. package/dist/components/calendar/Calendar.js.map +1 -1
  35. package/dist/components/carousel/Carousel.js +2 -2
  36. package/dist/components/carousel/Carousel.js.map +1 -1
  37. package/dist/components/carousel/CarouselSlide.js +1 -1
  38. package/dist/components/carousel/CarouselSlide.js.map +1 -1
  39. package/dist/components/carousel/CarouselSlider.js +1 -1
  40. package/dist/components/carousel/CarouselSlider.js.map +1 -1
  41. package/dist/components/checkbox/Checkbox.js +2 -2
  42. package/dist/components/checkbox/Checkbox.js.map +1 -1
  43. package/dist/components/checkbox-field/CheckboxField.js +7 -3
  44. package/dist/components/checkbox-field/CheckboxField.js.map +1 -1
  45. package/dist/components/checkbox-group/CheckboxGroupAllItem.js +2 -2
  46. package/dist/components/checkbox-group/CheckboxGroupAllItem.js.map +1 -1
  47. package/dist/components/checkbox-group/CheckboxGroupChecked.context.js +13 -14
  48. package/dist/components/checkbox-group/CheckboxGroupChecked.context.js.map +1 -1
  49. package/dist/components/checkbox-group/CheckboxGroupItem.js +2 -2
  50. package/dist/components/checkbox-group/CheckboxGroupItem.js.map +1 -1
  51. package/dist/components/checkbox-group/CheckboxGroupMounted.context.js +6 -7
  52. package/dist/components/checkbox-group/CheckboxGroupMounted.context.js.map +1 -1
  53. package/dist/components/chip/Chip.js +4 -5
  54. package/dist/components/chip/Chip.js.map +1 -1
  55. package/dist/components/create-password-field/CreatePasswordField.js +1 -1
  56. package/dist/components/create-password-field/CreatePasswordField.js.map +1 -1
  57. package/dist/components/data-table/DataTable.context.js +43 -26
  58. package/dist/components/data-table/DataTable.context.js.map +1 -1
  59. package/dist/components/data-table/DataTable.types.d.ts +1 -0
  60. package/dist/components/data-table/DataTable.types.js.map +1 -1
  61. package/dist/components/data-table/DataTableBulkActionsFloating.js +2 -6
  62. package/dist/components/data-table/DataTableBulkActionsFloating.js.map +1 -1
  63. package/dist/components/data-table/DataTableGlobalFilter.js +16 -8
  64. package/dist/components/data-table/DataTableGlobalFilter.js.map +1 -1
  65. package/dist/components/data-table/DataTableHead.js +5 -14
  66. package/dist/components/data-table/DataTableHead.js.map +1 -1
  67. package/dist/components/data-table/DataTableRowSelectionCheckbox.js +1 -0
  68. package/dist/components/data-table/DataTableRowSelectionCheckbox.js.map +1 -1
  69. package/dist/components/data-table/DataTableSelectAllRowsCheckbox.js +2 -1
  70. package/dist/components/data-table/DataTableSelectAllRowsCheckbox.js.map +1 -1
  71. package/dist/components/data-table/DataTableTable.js +8 -6
  72. package/dist/components/data-table/DataTableTable.js.map +1 -1
  73. package/dist/components/data-table/drag-and-drop/DragAndDropTable.js +1 -1
  74. package/dist/components/data-table/drag-and-drop/DragAndDropTable.js.map +1 -1
  75. package/dist/components/data-table/pagination/Pagination.js +3 -2
  76. package/dist/components/data-table/pagination/Pagination.js.map +1 -1
  77. package/dist/components/data-table/usePagination.d.ts +1 -0
  78. package/dist/components/data-table/usePagination.js +7 -2
  79. package/dist/components/data-table/usePagination.js.map +1 -1
  80. package/dist/components/date-input/DateInput.js +4 -3
  81. package/dist/components/date-input/DateInput.js.map +1 -1
  82. package/dist/components/dialog/DialogContent.js +19 -6
  83. package/dist/components/dialog/DialogContent.js.map +1 -1
  84. package/dist/components/dismissible/DismissibleRoot.js +15 -16
  85. package/dist/components/dismissible/DismissibleRoot.js.map +1 -1
  86. package/dist/components/dismissible/DismissibleTrigger.js +1 -1
  87. package/dist/components/dismissible/DismissibleTrigger.js.map +1 -1
  88. package/dist/components/dismissible-group/DismissibleGroupItem.js +1 -1
  89. package/dist/components/dismissible-group/DismissibleGroupItem.js.map +1 -1
  90. package/dist/components/dismissible-group/DismissibleGroupRoot.js +5 -6
  91. package/dist/components/dismissible-group/DismissibleGroupRoot.js.map +1 -1
  92. package/dist/components/drawer/Drawer.context.js +2 -3
  93. package/dist/components/drawer/Drawer.context.js.map +1 -1
  94. package/dist/components/drawer/DrawerContent.js +1 -1
  95. package/dist/components/drawer/DrawerContent.js.map +1 -1
  96. package/dist/components/empty-state/EmptyState.context.js +2 -3
  97. package/dist/components/empty-state/EmptyState.context.js.map +1 -1
  98. package/dist/components/empty-state/EmptyStateBody.js +1 -1
  99. package/dist/components/empty-state/EmptyStateBody.js.map +1 -1
  100. package/dist/components/empty-state/EmptyStateImage.js +1 -1
  101. package/dist/components/empty-state/EmptyStateImage.js.map +1 -1
  102. package/dist/components/empty-state/EmptyStateTitle.js +1 -1
  103. package/dist/components/empty-state/EmptyStateTitle.js.map +1 -1
  104. package/dist/components/file-drop/FileDrop.js +3 -3
  105. package/dist/components/file-drop/FileDrop.js.map +1 -1
  106. package/dist/components/file-drop/useFileDrop.js +1 -1
  107. package/dist/components/file-drop/useFileDrop.js.map +1 -1
  108. package/dist/components/form/Form.js +7 -6
  109. package/dist/components/form/Form.js.map +1 -1
  110. package/dist/components/form/useFormCustomContext.js +1 -1
  111. package/dist/components/form/useFormCustomContext.js.map +1 -1
  112. package/dist/components/index.d.ts +0 -3
  113. package/dist/components/index.js +1 -4
  114. package/dist/components/index.js.map +1 -1
  115. package/dist/components/input/Input.js +2 -2
  116. package/dist/components/input/Input.js.map +1 -1
  117. package/dist/components/keyboard-shortcut/KeyboardShortcut.js +10 -7
  118. package/dist/components/keyboard-shortcut/KeyboardShortcut.js.map +1 -1
  119. package/dist/components/markdown-content/MarkdownContent.d.ts +1 -1
  120. package/dist/components/markdown-content/MarkdownContent.js +4 -4
  121. package/dist/components/markdown-content/MarkdownContent.js.map +1 -1
  122. package/dist/components/navigation/NavigationMenu.context.js +1 -1
  123. package/dist/components/navigation/NavigationMenu.context.js.map +1 -1
  124. package/dist/components/navigation/NavigationMenu.js +7 -6
  125. package/dist/components/navigation/NavigationMenu.js.map +1 -1
  126. package/dist/components/navigation-menu-vertical/NavigationMenuVerticalAccordion.d.ts +2 -2
  127. package/dist/components/navigation-menu-vertical/NavigationMenuVerticalAccordion.js +3 -3
  128. package/dist/components/navigation-menu-vertical/NavigationMenuVerticalAccordion.js.map +1 -1
  129. package/dist/components/navigation-menu-vertical/NavigationMenuVerticalAccordionContent.js +1 -1
  130. package/dist/components/navigation-menu-vertical/NavigationMenuVerticalAccordionContent.js.map +1 -1
  131. package/dist/components/navigation-menu-vertical/NavigationMenuVerticalAccordionTrigger.js +1 -1
  132. package/dist/components/navigation-menu-vertical/NavigationMenuVerticalAccordionTrigger.js.map +1 -1
  133. package/dist/components/number-input/NumberInput.js +15 -16
  134. package/dist/components/number-input/NumberInput.js.map +1 -1
  135. package/dist/components/number-input-field/NumberInputField.js +7 -3
  136. package/dist/components/number-input-field/NumberInputField.js.map +1 -1
  137. package/dist/components/pagination/Pagination.context.js +29 -22
  138. package/dist/components/pagination/Pagination.context.js.map +1 -1
  139. package/dist/components/pagination/usePagination.js +1 -1
  140. package/dist/components/pagination/usePagination.js.map +1 -1
  141. package/dist/components/password-input/PasswordInput.js +1 -2
  142. package/dist/components/password-input/PasswordInput.js.map +1 -1
  143. package/dist/components/radio-button-field/RadioButtonField.js +7 -3
  144. package/dist/components/radio-button-field/RadioButtonField.js.map +1 -1
  145. package/dist/components/search-input/SearchInput.js +7 -11
  146. package/dist/components/search-input/SearchInput.js.map +1 -1
  147. package/dist/components/section-message/SectionMessage.context.js +15 -16
  148. package/dist/components/section-message/SectionMessage.context.js.map +1 -1
  149. package/dist/components/segmented-control/SegmentedControlBadge.js +1 -1
  150. package/dist/components/segmented-control/SegmentedControlBadge.js.map +1 -1
  151. package/dist/components/segmented-control/SegmentedControlDescription.js +1 -1
  152. package/dist/components/segmented-control/SegmentedControlDescription.js.map +1 -1
  153. package/dist/components/segmented-control/SegmentedControlHeading.js +1 -1
  154. package/dist/components/segmented-control/SegmentedControlHeading.js.map +1 -1
  155. package/dist/components/segmented-control/SegmentedControlIcon.js +1 -1
  156. package/dist/components/segmented-control/SegmentedControlIcon.js.map +1 -1
  157. package/dist/components/segmented-control/SegmentedControlItem.js +1 -1
  158. package/dist/components/segmented-control/SegmentedControlItem.js.map +1 -1
  159. package/dist/components/segmented-control/SegmentedControlItemList.js +20 -14
  160. package/dist/components/segmented-control/SegmentedControlItemList.js.map +1 -1
  161. package/dist/components/segmented-control/SegmentedControlRoot.js +18 -19
  162. package/dist/components/segmented-control/SegmentedControlRoot.js.map +1 -1
  163. package/dist/components/select-menu/SelectMenu.context.js +1 -1
  164. package/dist/components/select-menu/SelectMenu.context.js.map +1 -1
  165. package/dist/components/select-menu/SelectMenu.js +18 -12
  166. package/dist/components/select-menu/SelectMenu.js.map +1 -1
  167. package/dist/components/side-bar/SideBar.context.js +1 -1
  168. package/dist/components/side-bar/SideBar.context.js.map +1 -1
  169. package/dist/components/side-bar/SideBar.js +2 -2
  170. package/dist/components/side-bar/SideBar.js.map +1 -1
  171. package/dist/components/skeleton-loader/SkeletonCard.js.map +1 -1
  172. package/dist/components/slider-field/SliderField.js +8 -3
  173. package/dist/components/slider-field/SliderField.js.map +1 -1
  174. package/dist/components/sortable/SortableRoot.js +5 -3
  175. package/dist/components/sortable/SortableRoot.js.map +1 -1
  176. package/dist/components/stepper/Stepper.context.js +38 -30
  177. package/dist/components/stepper/Stepper.context.js.map +1 -1
  178. package/dist/components/toast/Toast.context.js +1 -1
  179. package/dist/components/toast/Toast.context.js.map +1 -1
  180. package/dist/components/toast/ToastProvider.js +3 -3
  181. package/dist/components/toast/ToastProvider.js.map +1 -1
  182. package/dist/components/top-bar/TopBar.js +4 -4
  183. package/dist/components/top-bar/TopBar.js.map +1 -1
  184. package/dist/components/tree/TreeCollapsible.d.ts +2 -2
  185. package/dist/components/tree/TreeCollapsible.js +3 -3
  186. package/dist/components/tree/TreeCollapsible.js.map +1 -1
  187. package/dist/components/tree/TreeCollapsibleContent.js +1 -1
  188. package/dist/components/tree/TreeCollapsibleContent.js.map +1 -1
  189. package/dist/components/tree/TreeCollapsibleTrigger.js +1 -1
  190. package/dist/components/tree/TreeCollapsibleTrigger.js.map +1 -1
  191. package/dist/docgen.json +1 -1
  192. package/dist/index.cjs.js +553 -595
  193. package/dist/index.cjs.js.map +1 -1
  194. package/dist/index.js +1 -4
  195. package/dist/styled.js +5 -1
  196. package/dist/styled.js.map +1 -1
  197. package/dist/utilities/hooks/useCallbackRef.d.ts +3 -3
  198. package/dist/utilities/hooks/useCallbackRef.js +4 -1
  199. package/dist/utilities/hooks/useCallbackRef.js.map +1 -1
  200. package/dist/utilities/hooks/useResizeObserver.js +13 -3
  201. package/dist/utilities/hooks/useResizeObserver.js.map +1 -1
  202. package/dist/utilities/hooks/useScrollPosition.js +22 -17
  203. package/dist/utilities/hooks/useScrollPosition.js.map +1 -1
  204. package/dist/utilities/hooks/useWindowScrollPosition.js +19 -15
  205. package/dist/utilities/hooks/useWindowScrollPosition.js.map +1 -1
  206. package/dist/utilities/uri/index.js +1 -6
  207. package/dist/utilities/uri/index.js.map +1 -1
  208. package/package.json +31 -31
  209. package/src/index.css +2 -0
  210. package/src/responsive-variant-classes.css +1 -1
  211. package/src/utilities.css +6 -0
  212. package/dist/components/box/Box.d.ts +0 -1
  213. package/dist/components/box/Box.js +0 -8
  214. package/dist/components/box/Box.js.map +0 -1
  215. package/dist/components/flex/Flex.d.ts +0 -7
  216. package/dist/components/flex/Flex.js +0 -88
  217. package/dist/components/flex/Flex.js.map +0 -1
  218. package/dist/components/grid/Grid.d.ts +0 -13
  219. package/dist/components/grid/Grid.js +0 -35
  220. package/dist/components/grid/Grid.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"NumberInput.js","names":[],"sources":["../../../src/components/number-input/NumberInput.tsx"],"sourcesContent":["import { Minus, Plus } from '@atom-learning/icons'\nimport * as React from 'react'\n\nimport { styled, cn } from '../../styled'\nimport { getFieldIconSize } from '../../utilities/style/get-icon-size'\nimport { Input } from '../input/Input'\nimport { NumberInputStepper } from './NumberInputStepper'\n\nexport interface NumberInputProps {\n name: string\n min?: number\n max?: number\n step?: number\n value?: number\n defaultValue?: number\n disabled?: boolean\n readonly?: boolean\n size?: 'sm' | 'md' | 'lg'\n appearance?: 'standard' | 'modern'\n theme?: 'white' | 'grey'\n emphasis?: 'bold'\n onValueChange?: (value: number) => void\n stepperButtonLabels?: { increment?: string; decrement?: string }\n disabledTooltipContent?: { increment?: string; decrement?: string }\n className?: string\n}\n\nconst NumberInputContainer = styled('div', {\n base: ['flex'],\n variants: {\n appearance: {\n standard: [],\n modern: ['gap-px']\n },\n emphasis: {\n bold: ['gap-0']\n }\n }\n})\n\nexport const NumberInput = ({\n ref,\n value,\n defaultValue = 0,\n onValueChange,\n min = 0,\n max = Number.MAX_SAFE_INTEGER,\n step = 1,\n disabled: isDisabled = false,\n readonly: isReadOnly = false,\n size = 'md',\n stepperButtonLabels: stepperButtonLabelsProp,\n disabledTooltipContent: disabledTooltipContentProp,\n className,\n appearance = 'standard',\n theme,\n emphasis,\n ...rest\n}: NumberInputProps & {\n ref?: React.Ref<HTMLInputElement>\n}) => {\n const [internalValue, setInternalValue] = React.useState<number>(\n value || defaultValue\n )\n React.useEffect(() => {\n // Update the internal value to match what is passed in.\n if (typeof value !== 'undefined') setInternalValue(value)\n }, [value])\n\n const inputRef = React.useRef<HTMLInputElement | null>(null)\n\n React.useImperativeHandle(ref, () => inputRef.current as HTMLInputElement)\n\n const iconSize = React.useMemo(() => getFieldIconSize(size), [size])\n\n const stepperButtonLabels = {\n increment: 'increment',\n decrement: 'decrement',\n ...stepperButtonLabelsProp\n }\n\n const disabledTooltipContent = {\n decrement: `Cannot enter values below ${min}`,\n increment: `Cannot enter values above ${max}`,\n ...disabledTooltipContentProp\n }\n\n const isAtMax = internalValue >= max\n const isAtMin = internalValue <= min\n\n const clamp = React.useCallback(\n (internalValue: number) => Math.min(Math.max(internalValue, min), max),\n [max, min]\n )\n\n const updateValue = React.useCallback(\n (newValue: number) => {\n onValueChange?.(newValue)\n setInternalValue(newValue)\n },\n [onValueChange]\n )\n\n const onInputChange = React.useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const parsedValue = Number(event.target.value.replace(/\\D/g, ''))\n updateValue(parsedValue)\n },\n [updateValue]\n )\n\n const increment = React.useCallback(() => {\n if (isAtMax || isReadOnly) return\n inputRef?.current?.focus()\n const newValue = Number(internalValue) + step\n updateValue(clamp(newValue))\n }, [clamp, isAtMax, isReadOnly, step, updateValue, internalValue])\n\n const decrement = React.useCallback(() => {\n if (isAtMin || isReadOnly) return\n inputRef?.current?.focus()\n const newValue = Number(internalValue) - step\n updateValue(clamp(newValue))\n }, [clamp, isAtMin, isReadOnly, min, step, updateValue, internalValue])\n\n const onKeyDown = React.useCallback(\n (event: React.KeyboardEvent) => {\n if (event.nativeEvent.isComposing) return\n\n /**\n * Keyboard Accessibility\n *\n * We want to increase or decrease the input's value\n * based on if the user the arrow keys.\n *\n * @see https://www.w3.org/TR/wai-aria-practices-1.1/#keyboard-interaction-17\n */\n const eventKey = event.key\n\n const keyMap: Record<string, React.KeyboardEventHandler> = {\n ArrowUp: increment,\n ArrowRight: increment,\n ArrowDown: decrement,\n ArrowLeft: decrement,\n Home: () => updateValue(min),\n End: () => updateValue(max)\n }\n\n const action = keyMap[eventKey]\n\n if (action) {\n event.preventDefault()\n action(event)\n }\n },\n [increment, decrement, updateValue, min, max]\n )\n\n const hasError = internalValue < min || internalValue > max\n const {\n state: externalState,\n 'aria-invalid': externalAriaInvalid,\n ...restProps\n } = rest as { state?: 'error'; 'aria-invalid'?: boolean } & typeof rest\n\n const inputProps: React.ComponentProps<typeof Input> = {\n type: 'number',\n value: internalValue,\n ...restProps,\n onChange: onInputChange,\n onKeyDown,\n size,\n appearance,\n theme,\n state: externalState || (hasError ? 'error' : undefined),\n 'aria-invalid': externalAriaInvalid || hasError || undefined,\n className: cn(\n 'rounded-none',\n 'w-16',\n '[&_>_input]:text-center',\n 'disabled:opacity-30',\n 'disabled:pointer-events-none',\n emphasis === 'bold' && [\n 'rounded-1',\n '[&_>_input[aria-invalid=true]]:text-danger',\n 'focus-within:[&_>_input]:text-grey-1000'\n ],\n emphasis === 'bold' &&\n appearance === 'standard' && [\n 'border-none',\n '[&:has([aria-invalid=true])]:border-2',\n '[&:has([aria-invalid=true])]:border-danger',\n 'focus-within:border-2',\n 'focus-within:border-blue-800'\n ]\n ),\n ref: inputRef,\n readOnly: isReadOnly,\n disabled: isDisabled,\n 'aria-valuemin': min,\n 'aria-valuemax': max,\n 'aria-valuenow': internalValue,\n role: 'spinbutton'\n }\n\n return (\n <NumberInputContainer\n appearance={appearance}\n emphasis={emphasis}\n className={className}\n >\n <NumberInputStepper\n onClick={decrement}\n icon={Minus}\n className={cn(\n emphasis !== 'bold' && ['border-r-none', 'rounded-r-none']\n )}\n size={iconSize}\n fieldAppearance={appearance}\n fieldTheme={theme}\n emphasis={emphasis}\n disabled={isAtMin || isDisabled}\n showTooltip={isAtMin && !isDisabled}\n disabledTooltipContent={disabledTooltipContent.decrement}\n label={stepperButtonLabels.decrement}\n />\n <Input {...inputProps} />\n <NumberInputStepper\n onClick={increment}\n icon={Plus}\n className={cn(\n emphasis !== 'bold' && ['border-l-none', 'rounded-l-none']\n )}\n size={iconSize}\n fieldAppearance={appearance}\n fieldTheme={theme}\n emphasis={emphasis}\n disabled={isAtMax || isDisabled}\n showTooltip={isAtMax && !isDisabled}\n disabledTooltipContent={disabledTooltipContent.increment}\n label={stepperButtonLabels.increment}\n />\n </NumberInputContainer>\n )\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"NumberInput.js","names":[],"sources":["../../../src/components/number-input/NumberInput.tsx"],"sourcesContent":["import { Minus, Plus } from '@atom-learning/icons'\nimport { useComposedRefs } from '@radix-ui/react-compose-refs'\nimport * as React from 'react'\n\nimport { styled, cn } from '../../styled'\nimport { getFieldIconSize } from '../../utilities/style/get-icon-size'\nimport { Input } from '../input/Input'\nimport { NumberInputStepper } from './NumberInputStepper'\n\nexport interface NumberInputProps {\n name: string\n min?: number\n max?: number\n step?: number\n value?: number\n defaultValue?: number\n disabled?: boolean\n readonly?: boolean\n size?: 'sm' | 'md' | 'lg'\n appearance?: 'standard' | 'modern'\n theme?: 'white' | 'grey'\n emphasis?: 'bold'\n onValueChange?: (value: number) => void\n stepperButtonLabels?: { increment?: string; decrement?: string }\n disabledTooltipContent?: { increment?: string; decrement?: string }\n className?: string\n}\n\nconst NumberInputContainer = styled('div', {\n base: ['flex'],\n variants: {\n appearance: {\n standard: [],\n modern: ['gap-px']\n },\n emphasis: {\n bold: ['gap-0']\n }\n }\n})\n\nexport const NumberInput = ({\n ref,\n value,\n defaultValue = 0,\n onValueChange,\n min = 0,\n max = Number.MAX_SAFE_INTEGER,\n step = 1,\n disabled: isDisabled = false,\n readonly: isReadOnly = false,\n size = 'md',\n stepperButtonLabels: stepperButtonLabelsProp,\n disabledTooltipContent: disabledTooltipContentProp,\n className,\n appearance = 'standard',\n theme,\n emphasis,\n ...rest\n}: NumberInputProps & {\n ref?: React.Ref<HTMLInputElement>\n}) => {\n // `?? defaultValue` (not `||`): a controlled `value={0}` is a value, not\n // an absence. `currentValue` is derived during render — mirroring the prop\n // into state via an effect would paint one stale frame per update.\n const [internalValue, setInternalValue] = React.useState<number>(\n value ?? defaultValue\n )\n const currentValue = value ?? internalValue\n\n const inputRef = React.useRef<HTMLInputElement | null>(null)\n const composedInputRef = useComposedRefs(ref, inputRef)\n\n const iconSize = getFieldIconSize(size)\n\n const stepperButtonLabels = {\n increment: 'increment',\n decrement: 'decrement',\n ...stepperButtonLabelsProp\n }\n\n const disabledTooltipContent = {\n decrement: `Cannot enter values below ${min}`,\n increment: `Cannot enter values above ${max}`,\n ...disabledTooltipContentProp\n }\n\n const isAtMax = currentValue >= max\n const isAtMin = currentValue <= min\n\n const clamp = React.useCallback(\n (internalValue: number) => Math.min(Math.max(internalValue, min), max),\n [max, min]\n )\n\n const updateValue = React.useCallback(\n (newValue: number) => {\n onValueChange?.(newValue)\n setInternalValue(newValue)\n },\n [onValueChange]\n )\n\n const onInputChange = React.useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const parsedValue = Number(event.target.value.replace(/\\D/g, ''))\n updateValue(parsedValue)\n },\n [updateValue]\n )\n\n const increment = React.useCallback(() => {\n if (isAtMax || isReadOnly) return\n inputRef?.current?.focus()\n const newValue = Number(currentValue) + step\n updateValue(clamp(newValue))\n }, [clamp, isAtMax, isReadOnly, step, updateValue, currentValue])\n\n const decrement = React.useCallback(() => {\n if (isAtMin || isReadOnly) return\n inputRef?.current?.focus()\n const newValue = Number(currentValue) - step\n updateValue(clamp(newValue))\n }, [clamp, isAtMin, isReadOnly, min, step, updateValue, currentValue])\n\n const onKeyDown = React.useCallback(\n (event: React.KeyboardEvent) => {\n if (event.nativeEvent.isComposing) return\n\n /**\n * Keyboard Accessibility\n *\n * We want to increase or decrease the input's value\n * based on if the user the arrow keys.\n *\n * @see https://www.w3.org/TR/wai-aria-practices-1.1/#keyboard-interaction-17\n */\n const eventKey = event.key\n\n const keyMap: Record<string, React.KeyboardEventHandler> = {\n ArrowUp: increment,\n ArrowRight: increment,\n ArrowDown: decrement,\n ArrowLeft: decrement,\n Home: () => updateValue(min),\n End: () => updateValue(max)\n }\n\n const action = keyMap[eventKey]\n\n if (action) {\n event.preventDefault()\n action(event)\n }\n },\n [increment, decrement, updateValue, min, max]\n )\n\n const hasError = currentValue < min || currentValue > max\n const {\n state: externalState,\n 'aria-invalid': externalAriaInvalid,\n ...restProps\n } = rest as { state?: 'error'; 'aria-invalid'?: boolean } & typeof rest\n\n const inputProps: React.ComponentProps<typeof Input> = {\n type: 'number',\n value: currentValue,\n ...restProps,\n onChange: onInputChange,\n onKeyDown,\n size,\n appearance,\n theme,\n state: externalState || (hasError ? 'error' : undefined),\n 'aria-invalid': externalAriaInvalid || hasError || undefined,\n className: cn(\n 'rounded-none',\n 'w-16',\n '[&_>_input]:text-center',\n 'disabled:opacity-30',\n 'disabled:pointer-events-none',\n emphasis === 'bold' && [\n 'rounded-1',\n '[&_>_input[aria-invalid=true]]:text-danger',\n 'focus-within:[&_>_input]:text-grey-1000'\n ],\n emphasis === 'bold' &&\n appearance === 'standard' && [\n 'border-none',\n '[&:has([aria-invalid=true])]:border-2',\n '[&:has([aria-invalid=true])]:border-danger',\n 'focus-within:border-2',\n 'focus-within:border-blue-800'\n ]\n ),\n ref: composedInputRef,\n readOnly: isReadOnly,\n disabled: isDisabled,\n 'aria-valuemin': min,\n 'aria-valuemax': max,\n 'aria-valuenow': currentValue,\n role: 'spinbutton'\n }\n\n return (\n <NumberInputContainer\n appearance={appearance}\n emphasis={emphasis}\n className={className}\n >\n <NumberInputStepper\n onClick={decrement}\n icon={Minus}\n className={cn(\n emphasis !== 'bold' && ['border-r-none', 'rounded-r-none']\n )}\n size={iconSize}\n fieldAppearance={appearance}\n fieldTheme={theme}\n emphasis={emphasis}\n disabled={isAtMin || isDisabled}\n showTooltip={isAtMin && !isDisabled}\n disabledTooltipContent={disabledTooltipContent.decrement}\n label={stepperButtonLabels.decrement}\n />\n <Input {...inputProps} />\n <NumberInputStepper\n onClick={increment}\n icon={Plus}\n className={cn(\n emphasis !== 'bold' && ['border-l-none', 'rounded-l-none']\n )}\n size={iconSize}\n fieldAppearance={appearance}\n fieldTheme={theme}\n emphasis={emphasis}\n disabled={isAtMax || isDisabled}\n showTooltip={isAtMax && !isDisabled}\n disabledTooltipContent={disabledTooltipContent.increment}\n label={stepperButtonLabels.increment}\n />\n </NumberInputContainer>\n )\n}\n"],"mappings":"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"}
@@ -7,7 +7,7 @@ import { jsx } from "react/jsx-runtime";
7
7
  import { useController, useFormContext } from "react-hook-form";
8
8
  //#region src/components/number-input-field/NumberInputField.tsx
9
9
  var NumberInputField = ({ className, defaultValue = 0, hideLabel, value, prompt, description, label, name, validation, onValueChange, appearance, theme, ...rest }) => {
10
- const { control } = useFormContext();
10
+ const { control, setValue } = useFormContext();
11
11
  const context = useFormCustomContext();
12
12
  const { field: { ref, onChange, value: innerValue, name: innerName } } = useController({
13
13
  name,
@@ -19,8 +19,12 @@ var NumberInputField = ({ className, defaultValue = 0, hideLabel, value, prompt,
19
19
  const formAppearance = context?.appearance || appearance;
20
20
  const formTheme = context?.theme ?? theme;
21
21
  React$1.useEffect(() => {
22
- if (typeof value !== "undefined") onChange(value);
23
- }, [value]);
22
+ if (typeof value !== "undefined") setValue(name, value, { shouldDirty: false });
23
+ }, [
24
+ value,
25
+ name,
26
+ setValue
27
+ ]);
24
28
  return /* @__PURE__ */ jsx(FieldWrapper, {
25
29
  className,
26
30
  description,
@@ -1 +1 @@
1
- {"version":3,"file":"NumberInputField.js","names":[],"sources":["../../../src/components/number-input-field/NumberInputField.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useController, useFormContext } from 'react-hook-form'\n\nimport { FieldWrapper } from '../field-wrapper/FieldWrapper'\nimport { useFieldError } from '../form/useFieldError'\nimport { useFormCustomContext } from '../form/useFormCustomContext'\nimport type { ValidationOptions } from '../form/validation'\nimport type { NumberInputProps } from '../number-input/NumberInput'\nimport { NumberInput } from '../number-input/NumberInput'\n\nexport interface NumberInputFieldProps extends NumberInputProps {\n className?: string\n hideLabel?: boolean\n description?: string\n label: string\n name: string\n prompt?: { link: string; label: string }\n validation?: ValidationOptions\n}\n\nexport const NumberInputField = ({\n className,\n defaultValue = 0,\n hideLabel,\n value,\n prompt,\n description,\n label,\n name,\n validation,\n onValueChange,\n appearance,\n theme,\n ...rest\n}: NumberInputFieldProps) => {\n const { control } = useFormContext()\n const context = useFormCustomContext()\n const {\n field: { ref, onChange, value: innerValue, name: innerName }\n } = useController({\n name,\n control,\n rules: validation,\n defaultValue\n })\n const { error } = useFieldError(name)\n\n const formAppearance = context?.appearance || appearance\n const formTheme = context?.theme ?? theme\n\n React.useEffect(() => {\n // Update the react-hook-form inner value to match what is passed in.\n if (typeof value !== 'undefined') onChange(value)\n }, [value])\n\n return (\n <FieldWrapper\n className={className}\n description={description}\n error={error}\n fieldId={name}\n hideLabel={hideLabel}\n label={label}\n prompt={prompt}\n required={Boolean(validation?.required)}\n appearance={formAppearance}\n >\n <NumberInput\n id={name}\n name={innerName}\n ref={ref}\n {...(error && { state: 'error', 'aria-invalid': true })}\n defaultValue={defaultValue}\n onValueChange={(newValue) => {\n onChange(newValue)\n onValueChange?.(newValue)\n }}\n value={innerValue}\n appearance={formAppearance}\n theme={formTheme}\n {...rest}\n />\n </FieldWrapper>\n )\n}\n\nNumberInputField.displayName = 'NumberInputField'\n"],"mappings":";;;;;;;;AAoBA,IAAa,oBAAoB,EAC/B,WACA,eAAe,GACf,WACA,OACA,QACA,aACA,OACA,MACA,YACA,eACA,YACA,OACA,GAAG,WACwB;CAC3B,MAAM,EAAE,YAAY,eAAe;CACnC,MAAM,UAAU,qBAAqB;CACrC,MAAM,EACJ,OAAO,EAAE,KAAK,UAAU,OAAO,YAAY,MAAM,gBAC/C,cAAc;EAChB;EACA;EACA,OAAO;EACP;CACF,CAAC;CACD,MAAM,EAAE,UAAU,cAAc,IAAI;CAEpC,MAAM,iBAAiB,SAAS,cAAc;CAC9C,MAAM,YAAY,SAAS,SAAS;CAEpC,QAAM,gBAAgB;EAEpB,IAAI,OAAO,UAAU,aAAa,SAAS,KAAK;CAClD,GAAG,CAAC,KAAK,CAAC;CAEV,OACE,oBAAC,cAAD;EACa;EACE;EACN;EACP,SAAS;EACE;EACJ;EACC;EACR,UAAU,QAAQ,YAAY,QAAQ;EACtC,YAAY;YAEZ,oBAAC,aAAD;GACE,IAAI;GACJ,MAAM;GACD;GACL,GAAK,SAAS;IAAE,OAAO;IAAS,gBAAgB;GAAK;GACvC;GACd,gBAAgB,aAAa;IAC3B,SAAS,QAAQ;IACjB,gBAAgB,QAAQ;GAC1B;GACA,OAAO;GACP,YAAY;GACZ,OAAO;GACP,GAAI;EACL,CAAA;CACW,CAAA;AAElB;AAEA,iBAAiB,cAAc"}
1
+ {"version":3,"file":"NumberInputField.js","names":[],"sources":["../../../src/components/number-input-field/NumberInputField.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useController, useFormContext } from 'react-hook-form'\n\nimport { FieldWrapper } from '../field-wrapper/FieldWrapper'\nimport { useFieldError } from '../form/useFieldError'\nimport { useFormCustomContext } from '../form/useFormCustomContext'\nimport type { ValidationOptions } from '../form/validation'\nimport type { NumberInputProps } from '../number-input/NumberInput'\nimport { NumberInput } from '../number-input/NumberInput'\n\nexport interface NumberInputFieldProps extends NumberInputProps {\n className?: string\n hideLabel?: boolean\n description?: string\n label: string\n name: string\n prompt?: { link: string; label: string }\n validation?: ValidationOptions\n}\n\nexport const NumberInputField = ({\n className,\n defaultValue = 0,\n hideLabel,\n value,\n prompt,\n description,\n label,\n name,\n validation,\n onValueChange,\n appearance,\n theme,\n ...rest\n}: NumberInputFieldProps) => {\n const { control, setValue } = useFormContext()\n const context = useFormCustomContext()\n const {\n field: { ref, onChange, value: innerValue, name: innerName }\n } = useController({\n name,\n control,\n rules: validation,\n defaultValue\n })\n const { error } = useFieldError(name)\n\n const formAppearance = context?.appearance || appearance\n const formTheme = context?.theme ?? theme\n\n React.useEffect(() => {\n // Sync an externally-controlled `value` into react-hook-form without\n // marking the field dirty/touched this isn't user input.\n if (typeof value !== 'undefined')\n setValue(name, value, { shouldDirty: false })\n }, [value, name, setValue])\n\n return (\n <FieldWrapper\n className={className}\n description={description}\n error={error}\n fieldId={name}\n hideLabel={hideLabel}\n label={label}\n prompt={prompt}\n required={Boolean(validation?.required)}\n appearance={formAppearance}\n >\n <NumberInput\n id={name}\n name={innerName}\n ref={ref}\n {...(error && { state: 'error', 'aria-invalid': true })}\n defaultValue={defaultValue}\n onValueChange={(newValue) => {\n onChange(newValue)\n onValueChange?.(newValue)\n }}\n value={innerValue}\n appearance={formAppearance}\n theme={formTheme}\n {...rest}\n />\n </FieldWrapper>\n )\n}\n\nNumberInputField.displayName = 'NumberInputField'\n"],"mappings":";;;;;;;;AAoBA,IAAa,oBAAoB,EAC/B,WACA,eAAe,GACf,WACA,OACA,QACA,aACA,OACA,MACA,YACA,eACA,YACA,OACA,GAAG,WACwB;CAC3B,MAAM,EAAE,SAAS,aAAa,eAAe;CAC7C,MAAM,UAAU,qBAAqB;CACrC,MAAM,EACJ,OAAO,EAAE,KAAK,UAAU,OAAO,YAAY,MAAM,gBAC/C,cAAc;EAChB;EACA;EACA,OAAO;EACP;CACF,CAAC;CACD,MAAM,EAAE,UAAU,cAAc,IAAI;CAEpC,MAAM,iBAAiB,SAAS,cAAc;CAC9C,MAAM,YAAY,SAAS,SAAS;CAEpC,QAAM,gBAAgB;EAGpB,IAAI,OAAO,UAAU,aACnB,SAAS,MAAM,OAAO,EAAE,aAAa,MAAM,CAAC;CAChD,GAAG;EAAC;EAAO;EAAM;CAAQ,CAAC;CAE1B,OACE,oBAAC,cAAD;EACa;EACE;EACN;EACP,SAAS;EACE;EACJ;EACC;EACR,UAAU,QAAQ,YAAY,QAAQ;EACtC,YAAY;YAEZ,oBAAC,aAAD;GACE,IAAI;GACJ,MAAM;GACD;GACL,GAAK,SAAS;IAAE,OAAO;IAAS,gBAAgB;GAAK;GACvC;GACd,gBAAgB,aAAa;IAC3B,SAAS,QAAQ;IACjB,gBAAgB,QAAQ;GAC1B;GACA,OAAO;GACP,YAAY;GACZ,OAAO;GACP,GAAI;EACL,CAAA;CACW,CAAA;AAElB;AAEA,iBAAiB,cAAc"}
@@ -15,7 +15,11 @@ var PaginationContext = React$1.createContext({
15
15
  indicatedPages: [],
16
16
  disabledPages: []
17
17
  });
18
- var PaginationProvider = ({ onSelectedPageChange, selectedPage, visibleElementsCount = VisibleElementsAmount.LESS, pagesCount, indicatedPages = [], disabledPages = [], onItemHover = () => null, labels = {}, children }) => {
18
+ var DEFAULT_LABELS = {};
19
+ var DEFAULT_ON_ITEM_HOVER = () => null;
20
+ var DEFAULT_INDICATED_PAGES = [];
21
+ var DEFAULT_DISABLED_PAGES = [];
22
+ var PaginationProvider = ({ onSelectedPageChange, selectedPage, visibleElementsCount = VisibleElementsAmount.LESS, pagesCount, indicatedPages = DEFAULT_INDICATED_PAGES, disabledPages = DEFAULT_DISABLED_PAGES, onItemHover = DEFAULT_ON_ITEM_HOVER, labels = DEFAULT_LABELS, children }) => {
19
23
  const [internalCurrentPage, setInternalCurrentPage] = React$1.useState(1);
20
24
  const currentPage = selectedPage || internalCurrentPage;
21
25
  const goToPage = React$1.useCallback((pageNumber) => {
@@ -30,38 +34,41 @@ var PaginationProvider = ({ onSelectedPageChange, selectedPage, visibleElementsC
30
34
  const goToNextPage = React$1.useCallback(() => {
31
35
  if (nextAvailablePage) goToPage(nextAvailablePage);
32
36
  }, [goToPage, nextAvailablePage]);
33
- const paginationItems = getPaginationElementsToRender(currentPage, pagesCount, visibleElementsCount);
34
- const value = React$1.useMemo(() => {
35
- return {
37
+ const paginationItems = React$1.useMemo(() => getPaginationElementsToRender(currentPage, pagesCount, visibleElementsCount), [
38
+ currentPage,
39
+ pagesCount,
40
+ visibleElementsCount
41
+ ]);
42
+ return /* @__PURE__ */ jsx(PaginationContext, {
43
+ value: React$1.useMemo(() => {
44
+ return {
45
+ goToNextPage,
46
+ goToPreviousPage,
47
+ goToPage,
48
+ currentPage,
49
+ paginationItems,
50
+ indicatedPages,
51
+ disabledPages,
52
+ pagesCount,
53
+ onItemHover,
54
+ previousAvailablePage,
55
+ nextAvailablePage,
56
+ labels
57
+ };
58
+ }, [
36
59
  goToNextPage,
37
60
  goToPreviousPage,
38
61
  goToPage,
39
62
  currentPage,
40
- paginationItems,
41
63
  indicatedPages,
64
+ paginationItems,
42
65
  disabledPages,
43
66
  pagesCount,
44
67
  onItemHover,
45
68
  previousAvailablePage,
46
69
  nextAvailablePage,
47
70
  labels
48
- };
49
- }, [
50
- goToNextPage,
51
- goToPreviousPage,
52
- goToPage,
53
- currentPage,
54
- indicatedPages,
55
- paginationItems,
56
- disabledPages,
57
- pagesCount,
58
- onItemHover,
59
- previousAvailablePage,
60
- nextAvailablePage,
61
- labels
62
- ]);
63
- return /* @__PURE__ */ jsx(PaginationContext.Provider, {
64
- value,
71
+ ]),
65
72
  children
66
73
  });
67
74
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Pagination.context.js","names":[],"sources":["../../../src/components/pagination/Pagination.context.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { VisibleElementsAmount } from './pagination.constants'\nimport {\n findNextAvailablePage,\n findPreviousAvailablePage,\n getPaginationElementsToRender\n} from './pagination.helper'\nimport type { PaginationContextValue, PaginationProviderProps } from './types'\n\nexport const PaginationContext = React.createContext<PaginationContextValue>({\n goToPage: () => null,\n goToPreviousPage: () => null,\n goToNextPage: () => null,\n currentPage: 1,\n pagesCount: 0,\n onItemHover: () => null,\n paginationItems: [],\n labels: {},\n indicatedPages: [],\n disabledPages: []\n})\n\nexport const PaginationProvider = ({\n onSelectedPageChange,\n selectedPage,\n visibleElementsCount = VisibleElementsAmount.LESS,\n pagesCount,\n indicatedPages = [],\n disabledPages = [],\n onItemHover = () => null,\n labels = {},\n children\n}: React.PropsWithChildren<PaginationProviderProps>) => {\n const [internalCurrentPage, setInternalCurrentPage] = React.useState(1)\n\n const currentPage = selectedPage || internalCurrentPage\n\n const goToPage = React.useCallback(\n (pageNumber: number) => {\n setInternalCurrentPage(pageNumber)\n onSelectedPageChange?.(pageNumber)\n },\n [onSelectedPageChange]\n )\n\n const previousPage = currentPage - 1\n const previousAvailablePage = findPreviousAvailablePage(\n previousPage,\n disabledPages\n )\n\n const goToPreviousPage = React.useCallback(() => {\n if (previousAvailablePage) goToPage(previousAvailablePage)\n }, [goToPage, previousAvailablePage])\n\n const nextPage = currentPage + 1\n const nextAvailablePage = findNextAvailablePage(\n nextPage,\n disabledPages,\n pagesCount\n )\n const goToNextPage = React.useCallback(() => {\n if (nextAvailablePage) goToPage(nextAvailablePage)\n }, [goToPage, nextAvailablePage])\n\n const paginationItems = getPaginationElementsToRender(\n currentPage,\n pagesCount,\n visibleElementsCount\n )\n\n const value = React.useMemo(() => {\n return {\n goToNextPage,\n goToPreviousPage,\n goToPage,\n currentPage,\n paginationItems,\n indicatedPages,\n disabledPages,\n pagesCount,\n onItemHover,\n previousAvailablePage,\n nextAvailablePage,\n labels\n }\n }, [\n goToNextPage,\n goToPreviousPage,\n goToPage,\n currentPage,\n indicatedPages,\n paginationItems,\n disabledPages,\n pagesCount,\n onItemHover,\n previousAvailablePage,\n nextAvailablePage,\n labels\n ])\n\n return (\n <PaginationContext.Provider value={value}>\n {children}\n </PaginationContext.Provider>\n )\n}\n"],"mappings":";;;;;AAUA,IAAa,oBAAoB,QAAM,cAAsC;CAC3E,gBAAgB;CAChB,wBAAwB;CACxB,oBAAoB;CACpB,aAAa;CACb,YAAY;CACZ,mBAAmB;CACnB,iBAAiB,CAAC;CAClB,QAAQ,CAAC;CACT,gBAAgB,CAAC;CACjB,eAAe,CAAC;AAClB,CAAC;AAED,IAAa,sBAAsB,EACjC,sBACA,cACA,uBAAuB,sBAAsB,MAC7C,YACA,iBAAiB,CAAC,GAClB,gBAAgB,CAAC,GACjB,oBAAoB,MACpB,SAAS,CAAC,GACV,eACsD;CACtD,MAAM,CAAC,qBAAqB,0BAA0B,QAAM,SAAS,CAAC;CAEtE,MAAM,cAAc,gBAAgB;CAEpC,MAAM,WAAW,QAAM,aACpB,eAAuB;EACtB,uBAAuB,UAAU;EACjC,uBAAuB,UAAU;CACnC,GACA,CAAC,oBAAoB,CACvB;CAGA,MAAM,wBAAwB,0BADT,cAAc,GAGjC,aACF;CAEA,MAAM,mBAAmB,QAAM,kBAAkB;EAC/C,IAAI,uBAAuB,SAAS,qBAAqB;CAC3D,GAAG,CAAC,UAAU,qBAAqB,CAAC;CAGpC,MAAM,oBAAoB,sBADT,cAAc,GAG7B,eACA,UACF;CACA,MAAM,eAAe,QAAM,kBAAkB;EAC3C,IAAI,mBAAmB,SAAS,iBAAiB;CACnD,GAAG,CAAC,UAAU,iBAAiB,CAAC;CAEhC,MAAM,kBAAkB,8BACtB,aACA,YACA,oBACF;CAEA,MAAM,QAAQ,QAAM,cAAc;EAChC,OAAO;GACL;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF;CACF,GAAG;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,OACE,oBAAC,kBAAkB,UAAnB;EAAmC;EAChC;CACyB,CAAA;AAEhC"}
1
+ {"version":3,"file":"Pagination.context.js","names":[],"sources":["../../../src/components/pagination/Pagination.context.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { VisibleElementsAmount } from './pagination.constants'\nimport {\n findNextAvailablePage,\n findPreviousAvailablePage,\n getPaginationElementsToRender\n} from './pagination.helper'\nimport type { PaginationContextValue, PaginationProviderProps } from './types'\n\nexport const PaginationContext = React.createContext<PaginationContextValue>({\n goToPage: () => null,\n goToPreviousPage: () => null,\n goToNextPage: () => null,\n currentPage: 1,\n pagesCount: 0,\n onItemHover: () => null,\n paginationItems: [],\n labels: {},\n indicatedPages: [],\n disabledPages: []\n})\n\n// Module-level defaults: inline `= {}` / `= () => null` defaults would mint\n// a new identity every render and the value useMemo below could never hit.\nconst DEFAULT_LABELS = {}\nconst DEFAULT_ON_ITEM_HOVER = () => null\nconst DEFAULT_INDICATED_PAGES: number[] = []\nconst DEFAULT_DISABLED_PAGES: number[] = []\n\nexport const PaginationProvider = ({\n onSelectedPageChange,\n selectedPage,\n visibleElementsCount = VisibleElementsAmount.LESS,\n pagesCount,\n indicatedPages = DEFAULT_INDICATED_PAGES,\n disabledPages = DEFAULT_DISABLED_PAGES,\n onItemHover = DEFAULT_ON_ITEM_HOVER,\n labels = DEFAULT_LABELS,\n children\n}: React.PropsWithChildren<PaginationProviderProps>) => {\n const [internalCurrentPage, setInternalCurrentPage] = React.useState(1)\n\n const currentPage = selectedPage || internalCurrentPage\n\n const goToPage = React.useCallback(\n (pageNumber: number) => {\n setInternalCurrentPage(pageNumber)\n onSelectedPageChange?.(pageNumber)\n },\n [onSelectedPageChange]\n )\n\n const previousPage = currentPage - 1\n const previousAvailablePage = findPreviousAvailablePage(\n previousPage,\n disabledPages\n )\n\n const goToPreviousPage = React.useCallback(() => {\n if (previousAvailablePage) goToPage(previousAvailablePage)\n }, [goToPage, previousAvailablePage])\n\n const nextPage = currentPage + 1\n const nextAvailablePage = findNextAvailablePage(\n nextPage,\n disabledPages,\n pagesCount\n )\n const goToNextPage = React.useCallback(() => {\n if (nextAvailablePage) goToPage(nextAvailablePage)\n }, [goToPage, nextAvailablePage])\n\n const paginationItems = React.useMemo(\n () =>\n getPaginationElementsToRender(\n currentPage,\n pagesCount,\n visibleElementsCount\n ),\n [currentPage, pagesCount, visibleElementsCount]\n )\n\n const value = React.useMemo(() => {\n return {\n goToNextPage,\n goToPreviousPage,\n goToPage,\n currentPage,\n paginationItems,\n indicatedPages,\n disabledPages,\n pagesCount,\n onItemHover,\n previousAvailablePage,\n nextAvailablePage,\n labels\n }\n }, [\n goToNextPage,\n goToPreviousPage,\n goToPage,\n currentPage,\n indicatedPages,\n paginationItems,\n disabledPages,\n pagesCount,\n onItemHover,\n previousAvailablePage,\n nextAvailablePage,\n labels\n ])\n\n return <PaginationContext value={value}>{children}</PaginationContext>\n}\n"],"mappings":";;;;;AAUA,IAAa,oBAAoB,QAAM,cAAsC;CAC3E,gBAAgB;CAChB,wBAAwB;CACxB,oBAAoB;CACpB,aAAa;CACb,YAAY;CACZ,mBAAmB;CACnB,iBAAiB,CAAC;CAClB,QAAQ,CAAC;CACT,gBAAgB,CAAC;CACjB,eAAe,CAAC;AAClB,CAAC;AAID,IAAM,iBAAiB,CAAC;AACxB,IAAM,8BAA8B;AACpC,IAAM,0BAAoC,CAAC;AAC3C,IAAM,yBAAmC,CAAC;AAE1C,IAAa,sBAAsB,EACjC,sBACA,cACA,uBAAuB,sBAAsB,MAC7C,YACA,iBAAiB,yBACjB,gBAAgB,wBAChB,cAAc,uBACd,SAAS,gBACT,eACsD;CACtD,MAAM,CAAC,qBAAqB,0BAA0B,QAAM,SAAS,CAAC;CAEtE,MAAM,cAAc,gBAAgB;CAEpC,MAAM,WAAW,QAAM,aACpB,eAAuB;EACtB,uBAAuB,UAAU;EACjC,uBAAuB,UAAU;CACnC,GACA,CAAC,oBAAoB,CACvB;CAGA,MAAM,wBAAwB,0BADT,cAAc,GAGjC,aACF;CAEA,MAAM,mBAAmB,QAAM,kBAAkB;EAC/C,IAAI,uBAAuB,SAAS,qBAAqB;CAC3D,GAAG,CAAC,UAAU,qBAAqB,CAAC;CAGpC,MAAM,oBAAoB,sBADT,cAAc,GAG7B,eACA,UACF;CACA,MAAM,eAAe,QAAM,kBAAkB;EAC3C,IAAI,mBAAmB,SAAS,iBAAiB;CACnD,GAAG,CAAC,UAAU,iBAAiB,CAAC;CAEhC,MAAM,kBAAkB,QAAM,cAE1B,8BACE,aACA,YACA,oBACF,GACF;EAAC;EAAa;EAAY;CAAoB,CAChD;CAgCA,OAAO,oBAAC,mBAAD;EAA0B,OA9BnB,QAAM,cAAc;GAChC,OAAO;IACL;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;EACF,GAAG;GACD;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAEiC;EAAQ;CAA4B,CAAA;AACvE"}
@@ -2,7 +2,7 @@ import { PaginationContext } from "./Pagination.context.js";
2
2
  import * as React$1 from "react";
3
3
  //#region src/components/pagination/usePagination.tsx
4
4
  var usePagination = () => {
5
- const context = React$1.useContext(PaginationContext);
5
+ const context = React$1.use(PaginationContext);
6
6
  if (!context) throw new Error("Ensure that you wrap any components with the PaginationProvider component");
7
7
  return context;
8
8
  };
@@ -1 +1 @@
1
- {"version":3,"file":"usePagination.js","names":[],"sources":["../../../src/components/pagination/usePagination.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { PaginationContext } from './Pagination.context'\nimport type { PaginationContextValue } from './types'\n\nexport const usePagination = (): PaginationContextValue => {\n const context = React.useContext(PaginationContext)\n\n if (!context) {\n throw new Error(\n 'Ensure that you wrap any components with the PaginationProvider component'\n )\n }\n\n return context\n}\n"],"mappings":";;;AAKA,IAAa,sBAA8C;CACzD,MAAM,UAAU,QAAM,WAAW,iBAAiB;CAElD,IAAI,CAAC,SACH,MAAM,IAAI,MACR,2EACF;CAGF,OAAO;AACT"}
1
+ {"version":3,"file":"usePagination.js","names":[],"sources":["../../../src/components/pagination/usePagination.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { PaginationContext } from './Pagination.context'\nimport type { PaginationContextValue } from './types'\n\nexport const usePagination = (): PaginationContextValue => {\n const context = React.use(PaginationContext)\n\n if (!context) {\n throw new Error(\n 'Ensure that you wrap any components with the PaginationProvider component'\n )\n }\n\n return context\n}\n"],"mappings":";;;AAKA,IAAa,sBAA8C;CACzD,MAAM,UAAU,QAAM,IAAI,iBAAiB;CAE3C,IAAI,CAAC,SACH,MAAM,IAAI,MACR,2EACF;CAGF,OAAO;AACT"}
@@ -3,7 +3,6 @@ import { Icon } from "../icon/Icon.js";
3
3
  import { ActionIcon } from "../action-icon/ActionIcon.js";
4
4
  import { getFieldIconSize } from "../../utilities/style/get-icon-size.js";
5
5
  import { Input } from "../input/Input.js";
6
- import * as React$1 from "react";
7
6
  import { useState } from "react";
8
7
  import { jsx, jsxs } from "react/jsx-runtime";
9
8
  import { Eye, EyeCrossed } from "@atom-learning/icons";
@@ -11,7 +10,7 @@ import { Eye, EyeCrossed } from "@atom-learning/icons";
11
10
  var PasswordInput = ({ ref, className, hidePasswordText = "Hide password", showPasswordText = "Show password", size = "md", ...restProps }) => {
12
11
  const [isPasswordVisible, setIsPasswordVisible] = useState(false);
13
12
  const togglePasswordVisibility = () => setIsPasswordVisible((currentState) => !currentState);
14
- const iconSize = React$1.useMemo(() => getFieldIconSize(size), [size]);
13
+ const iconSize = getFieldIconSize(size);
15
14
  return /* @__PURE__ */ jsxs("div", {
16
15
  className: cn("relative", className),
17
16
  children: [/* @__PURE__ */ jsx(Input, {
@@ -1 +1 @@
1
- {"version":3,"file":"PasswordInput.js","names":[],"sources":["../../../src/components/password-input/PasswordInput.tsx"],"sourcesContent":["import { Eye, EyeCrossed } from '@atom-learning/icons'\nimport * as React from 'react'\nimport { useState } from 'react'\n\nimport { cn } from '../../styled'\nimport { getFieldIconSize } from '../../utilities/style/get-icon-size'\nimport { ActionIcon } from '../action-icon/ActionIcon'\nimport { Icon } from '../icon/Icon'\nimport type { InputProps } from '../input/Input'\nimport { Input } from '../input/Input'\n\ntype PasswordInputProps = Omit<InputProps, 'type'> & {\n hidePasswordText?: string\n showPasswordText?: string\n}\n\nexport const PasswordInput = ({\n ref,\n className,\n hidePasswordText = 'Hide password',\n showPasswordText = 'Show password',\n size = 'md',\n ...restProps\n}: PasswordInputProps) => {\n const [isPasswordVisible, setIsPasswordVisible] = useState<boolean>(false)\n const togglePasswordVisibility = () =>\n setIsPasswordVisible((currentState) => !currentState)\n\n const iconSize = React.useMemo(() => getFieldIconSize(size), [size])\n\n return (\n <div className={cn('relative', className)}>\n <Input\n {...restProps}\n size={size}\n type={isPasswordVisible ? 'text' : 'password'}\n ref={ref}\n className=\"pr-6\"\n />\n <ActionIcon\n appearance=\"simple\"\n theme=\"neutral\"\n label={isPasswordVisible ? hidePasswordText : showPasswordText}\n onClick={togglePasswordVisibility}\n onMouseDown={(e) => e.preventDefault()} // prevent focus being lost from password input\n size={iconSize}\n className={cn(\n size === 'lg' ? 'bottom-1' : 'bottom-0',\n 'absolute',\n 'right-0'\n )}\n >\n <Icon is={isPasswordVisible ? Eye : EyeCrossed} />\n </ActionIcon>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;AAgBA,IAAa,iBAAiB,EAC5B,KACA,WACA,mBAAmB,iBACnB,mBAAmB,iBACnB,OAAO,MACP,GAAG,gBACqB;CACxB,MAAM,CAAC,mBAAmB,wBAAwB,SAAkB,KAAK;CACzE,MAAM,iCACJ,sBAAsB,iBAAiB,CAAC,YAAY;CAEtD,MAAM,WAAW,QAAM,cAAc,iBAAiB,IAAI,GAAG,CAAC,IAAI,CAAC;CAEnE,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,YAAY,SAAS;YAAxC,CACE,oBAAC,OAAD;GACE,GAAI;GACE;GACN,MAAM,oBAAoB,SAAS;GAC9B;GACL,WAAU;EACX,CAAA,GACD,oBAAC,YAAD;GACE,YAAW;GACX,OAAM;GACN,OAAO,oBAAoB,mBAAmB;GAC9C,SAAS;GACT,cAAc,MAAM,EAAE,eAAe;GACrC,MAAM;GACN,WAAW,GACT,SAAS,OAAO,aAAa,YAC7B,YACA,SACF;aAEA,oBAAC,MAAD,EAAM,IAAI,oBAAoB,MAAM,WAAa,CAAA;EACvC,CAAA,CACT;;AAET"}
1
+ {"version":3,"file":"PasswordInput.js","names":[],"sources":["../../../src/components/password-input/PasswordInput.tsx"],"sourcesContent":["import { Eye, EyeCrossed } from '@atom-learning/icons'\nimport * as React from 'react'\nimport { useState } from 'react'\n\nimport { cn } from '../../styled'\nimport { getFieldIconSize } from '../../utilities/style/get-icon-size'\nimport { ActionIcon } from '../action-icon/ActionIcon'\nimport { Icon } from '../icon/Icon'\nimport type { InputProps } from '../input/Input'\nimport { Input } from '../input/Input'\n\ntype PasswordInputProps = Omit<InputProps, 'type'> & {\n hidePasswordText?: string\n showPasswordText?: string\n}\n\nexport const PasswordInput = ({\n ref,\n className,\n hidePasswordText = 'Hide password',\n showPasswordText = 'Show password',\n size = 'md',\n ...restProps\n}: PasswordInputProps) => {\n const [isPasswordVisible, setIsPasswordVisible] = useState<boolean>(false)\n const togglePasswordVisibility = () =>\n setIsPasswordVisible((currentState) => !currentState)\n\n const iconSize = getFieldIconSize(size)\n\n return (\n <div className={cn('relative', className)}>\n <Input\n {...restProps}\n size={size}\n type={isPasswordVisible ? 'text' : 'password'}\n ref={ref}\n className=\"pr-6\"\n />\n <ActionIcon\n appearance=\"simple\"\n theme=\"neutral\"\n label={isPasswordVisible ? hidePasswordText : showPasswordText}\n onClick={togglePasswordVisibility}\n onMouseDown={(e) => e.preventDefault()} // prevent focus being lost from password input\n size={iconSize}\n className={cn(\n size === 'lg' ? 'bottom-1' : 'bottom-0',\n 'absolute',\n 'right-0'\n )}\n >\n <Icon is={isPasswordVisible ? Eye : EyeCrossed} />\n </ActionIcon>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;AAgBA,IAAa,iBAAiB,EAC5B,KACA,WACA,mBAAmB,iBACnB,mBAAmB,iBACnB,OAAO,MACP,GAAG,gBACqB;CACxB,MAAM,CAAC,mBAAmB,wBAAwB,SAAkB,KAAK;CACzE,MAAM,iCACJ,sBAAsB,iBAAiB,CAAC,YAAY;CAEtD,MAAM,WAAW,iBAAiB,IAAI;CAEtC,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,YAAY,SAAS;YAAxC,CACE,oBAAC,OAAD;GACE,GAAI;GACE;GACN,MAAM,oBAAoB,SAAS;GAC9B;GACL,WAAU;EACX,CAAA,GACD,oBAAC,YAAD;GACE,YAAW;GACX,OAAM;GACN,OAAO,oBAAoB,mBAAmB;GAC9C,SAAS;GACT,cAAc,MAAM,EAAE,eAAe;GACrC,MAAM;GACN,WAAW,GACT,SAAS,OAAO,aAAa,YAC7B,YACA,SACF;aAEA,oBAAC,MAAD,EAAM,IAAI,oBAAoB,MAAM,WAAa,CAAA;EACvC,CAAA,CACT;;AAET"}
@@ -16,7 +16,7 @@ var Fieldset = styled("fieldset", { base: [
16
16
  "min-w-0"
17
17
  ] });
18
18
  var RadioButtonFieldComponent = ({ children, className, direction = "column", defaultValue, value, description, label, name, validation, onValueChange, ...rest }) => {
19
- const { control } = useFormContext();
19
+ const { control, setValue } = useFormContext();
20
20
  const { field: { ref, onChange, value: innerValue } } = useController({
21
21
  name,
22
22
  control,
@@ -25,8 +25,12 @@ var RadioButtonFieldComponent = ({ children, className, direction = "column", de
25
25
  });
26
26
  const { error } = useFieldError(name);
27
27
  React$1.useEffect(() => {
28
- if (typeof value !== "undefined") onChange(value);
29
- }, [value]);
28
+ if (typeof value !== "undefined") setValue(name, value, { shouldDirty: false });
29
+ }, [
30
+ value,
31
+ name,
32
+ setValue
33
+ ]);
30
34
  return /* @__PURE__ */ jsxs(Fieldset, {
31
35
  className,
32
36
  children: [
@@ -1 +1 @@
1
- {"version":3,"file":"RadioButtonField.js","names":[],"sources":["../../../src/components/radio-button-field/RadioButtonField.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useController, useFormContext } from 'react-hook-form'\n\nimport { styled } from '../../styled'\nimport { Description as FieldDescription } from '../field-wrapper/FieldDescription'\nimport type { FieldElementWrapperProps } from '../field-wrapper/FieldWrapper'\nimport { useFieldError } from '../form/useFieldError'\nimport { InlineMessage } from '../inline-message/InlineMessage'\nimport { Label } from '../label/Label'\nimport { RadioButtonGroup } from '../radio-button/RadioButtonGroup'\nimport { RadioField } from './RadioField'\n\nconst Fieldset = styled('fieldset', {\n base: ['border-0', 'p-0', 'm-0', 'min-w-0']\n})\n\ntype RadioButtonFieldProps = React.ComponentProps<typeof RadioButtonGroup> &\n FieldElementWrapperProps\n\nconst RadioButtonFieldComponent = ({\n children,\n className,\n direction = 'column',\n defaultValue,\n value,\n description,\n label,\n name,\n validation,\n onValueChange,\n ...rest\n}: RadioButtonFieldProps) => {\n const { control } = useFormContext()\n const {\n field: { ref, onChange, value: innerValue }\n } = useController({\n name,\n control,\n rules: validation,\n defaultValue\n })\n const { error } = useFieldError(name)\n\n React.useEffect(() => {\n // Update the react-hook-form inner value to match what is passed in.\n if (typeof value !== 'undefined') onChange(value)\n }, [value])\n\n return (\n <Fieldset className={className}>\n <Label\n as=\"legend\"\n required={Boolean(validation?.required)}\n className=\"mb-3 p-0\"\n >\n {label}\n </Label>\n {description && (\n <FieldDescription className=\"mb-3\">{description}</FieldDescription>\n )}\n\n <RadioButtonGroup\n ref={ref}\n direction={direction}\n defaultValue={defaultValue}\n onValueChange={(newValue) => {\n onChange(newValue)\n onValueChange?.(newValue)\n }}\n value={innerValue}\n {...rest}\n >\n {children}\n </RadioButtonGroup>\n\n {error && <InlineMessage className=\"mt-2\">{error}</InlineMessage>}\n </Fieldset>\n )\n}\n\nexport const RadioButtonField = /* @__PURE__ */ Object.assign(\n RadioButtonFieldComponent,\n {\n Item: RadioField\n }\n)\n\nRadioButtonFieldComponent.displayName = 'RadioButtonField'\n"],"mappings":";;;;;;;;;;;AAYA,IAAM,WAAW,OAAO,YAAY,EAClC,MAAM;CAAC;CAAY;CAAO;CAAO;AAAS,EAC5C,CAAC;AAKD,IAAM,6BAA6B,EACjC,UACA,WACA,YAAY,UACZ,cACA,OACA,aACA,OACA,MACA,YACA,eACA,GAAG,WACwB;CAC3B,MAAM,EAAE,YAAY,eAAe;CACnC,MAAM,EACJ,OAAO,EAAE,KAAK,UAAU,OAAO,iBAC7B,cAAc;EAChB;EACA;EACA,OAAO;EACP;CACF,CAAC;CACD,MAAM,EAAE,UAAU,cAAc,IAAI;CAEpC,QAAM,gBAAgB;EAEpB,IAAI,OAAO,UAAU,aAAa,SAAS,KAAK;CAClD,GAAG,CAAC,KAAK,CAAC;CAEV,OACE,qBAAC,UAAD;EAAqB;YAArB;GACE,oBAAC,OAAD;IACE,IAAG;IACH,UAAU,QAAQ,YAAY,QAAQ;IACtC,WAAU;cAET;GACI,CAAA;GACN,eACC,oBAAC,aAAD;IAAkB,WAAU;cAAQ;GAA8B,CAAA;GAGpE,oBAAC,kBAAD;IACO;IACM;IACG;IACd,gBAAgB,aAAa;KAC3B,SAAS,QAAQ;KACjB,gBAAgB,QAAQ;IAC1B;IACA,OAAO;IACP,GAAI;IAEH;GACe,CAAA;GAEjB,SAAS,oBAAC,eAAD;IAAe,WAAU;cAAQ;GAAqB,CAAA;EACxD;;AAEd;AAEA,IAAa,mBAAmC,uBAAO,OACrD,2BACA,EACE,MAAM,WACR,CACF;AAEA,0BAA0B,cAAc"}
1
+ {"version":3,"file":"RadioButtonField.js","names":[],"sources":["../../../src/components/radio-button-field/RadioButtonField.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useController, useFormContext } from 'react-hook-form'\n\nimport { styled } from '../../styled'\nimport { Description as FieldDescription } from '../field-wrapper/FieldDescription'\nimport type { FieldElementWrapperProps } from '../field-wrapper/FieldWrapper'\nimport { useFieldError } from '../form/useFieldError'\nimport { InlineMessage } from '../inline-message/InlineMessage'\nimport { Label } from '../label/Label'\nimport { RadioButtonGroup } from '../radio-button/RadioButtonGroup'\nimport { RadioField } from './RadioField'\n\nconst Fieldset = styled('fieldset', {\n base: ['border-0', 'p-0', 'm-0', 'min-w-0']\n})\n\ntype RadioButtonFieldProps = React.ComponentProps<typeof RadioButtonGroup> &\n FieldElementWrapperProps\n\nconst RadioButtonFieldComponent = ({\n children,\n className,\n direction = 'column',\n defaultValue,\n value,\n description,\n label,\n name,\n validation,\n onValueChange,\n ...rest\n}: RadioButtonFieldProps) => {\n const { control, setValue } = useFormContext()\n const {\n field: { ref, onChange, value: innerValue }\n } = useController({\n name,\n control,\n rules: validation,\n defaultValue\n })\n const { error } = useFieldError(name)\n\n React.useEffect(() => {\n // Sync an externally-controlled `value` into react-hook-form without\n // marking the field dirty/touched this isn't user input.\n if (typeof value !== 'undefined')\n setValue(name, value, { shouldDirty: false })\n }, [value, name, setValue])\n\n return (\n <Fieldset className={className}>\n <Label\n as=\"legend\"\n required={Boolean(validation?.required)}\n className=\"mb-3 p-0\"\n >\n {label}\n </Label>\n {description && (\n <FieldDescription className=\"mb-3\">{description}</FieldDescription>\n )}\n\n <RadioButtonGroup\n ref={ref}\n direction={direction}\n defaultValue={defaultValue}\n onValueChange={(newValue) => {\n onChange(newValue)\n onValueChange?.(newValue)\n }}\n value={innerValue}\n {...rest}\n >\n {children}\n </RadioButtonGroup>\n\n {error && <InlineMessage className=\"mt-2\">{error}</InlineMessage>}\n </Fieldset>\n )\n}\n\nexport const RadioButtonField = /* @__PURE__ */ Object.assign(\n RadioButtonFieldComponent,\n {\n Item: RadioField\n }\n)\n\nRadioButtonFieldComponent.displayName = 'RadioButtonField'\n"],"mappings":";;;;;;;;;;;AAYA,IAAM,WAAW,OAAO,YAAY,EAClC,MAAM;CAAC;CAAY;CAAO;CAAO;AAAS,EAC5C,CAAC;AAKD,IAAM,6BAA6B,EACjC,UACA,WACA,YAAY,UACZ,cACA,OACA,aACA,OACA,MACA,YACA,eACA,GAAG,WACwB;CAC3B,MAAM,EAAE,SAAS,aAAa,eAAe;CAC7C,MAAM,EACJ,OAAO,EAAE,KAAK,UAAU,OAAO,iBAC7B,cAAc;EAChB;EACA;EACA,OAAO;EACP;CACF,CAAC;CACD,MAAM,EAAE,UAAU,cAAc,IAAI;CAEpC,QAAM,gBAAgB;EAGpB,IAAI,OAAO,UAAU,aACnB,SAAS,MAAM,OAAO,EAAE,aAAa,MAAM,CAAC;CAChD,GAAG;EAAC;EAAO;EAAM;CAAQ,CAAC;CAE1B,OACE,qBAAC,UAAD;EAAqB;YAArB;GACE,oBAAC,OAAD;IACE,IAAG;IACH,UAAU,QAAQ,YAAY,QAAQ;IACtC,WAAU;cAET;GACI,CAAA;GACN,eACC,oBAAC,aAAD;IAAkB,WAAU;cAAQ;GAA8B,CAAA;GAGpE,oBAAC,kBAAD;IACO;IACM;IACG;IACd,gBAAgB,aAAa;KAC3B,SAAS,QAAQ;KACjB,gBAAgB,QAAQ;IAC1B;IACA,OAAO;IACP,GAAI;IAEH;GACe,CAAA;GAEjB,SAAS,oBAAC,eAAD;IAAe,WAAU;cAAQ;GAAqB,CAAA;EACxD;;AAEd;AAEA,IAAa,mBAAmC,uBAAO,OACrD,2BACA,EACE,MAAM,WACR,CACF;AAEA,0BAA0B,cAAc"}
@@ -5,6 +5,7 @@ import { useCallbackRef } from "../../utilities/hooks/useCallbackRef.js";
5
5
  import { getFieldIconSize } from "../../utilities/style/get-icon-size.js";
6
6
  import { InputBackground, InputText } from "../input/Input.js";
7
7
  import * as React$1 from "react";
8
+ import { useComposedRefs } from "@radix-ui/react-compose-refs";
8
9
  import { jsx, jsxs } from "react/jsx-runtime";
9
10
  import { Close, Search } from "@atom-learning/icons";
10
11
  //#region src/components/search-input/SearchInput.tsx
@@ -23,14 +24,10 @@ var StyledIcon = styled(Icon, {
23
24
  var SearchInput = ({ ref, size = "md", appearance = "standard", theme, className, value, defaultValue = "", onValueChange, clearText = "Clear", onChange, ...rest }) => {
24
25
  const [inputElRef, setInputElRef] = useCallbackRef();
25
26
  const [innerValue, setInnerValue] = React$1.useState(defaultValue);
26
- const [activeIcon, setActiveIcon] = React$1.useState(defaultValue ? "CLEAR" : "SEARCH");
27
- React$1.useEffect(() => {
28
- if (typeof value === "undefined") return;
29
- setInnerValue(value);
30
- setActiveIcon(value ? "CLEAR" : "SEARCH");
31
- }, [value]);
32
- const iconSize = React$1.useMemo(() => getFieldIconSize(size), [size]);
33
- React$1.useImperativeHandle(ref, () => inputElRef.current);
27
+ const currentValue = value ?? innerValue;
28
+ const activeIcon = currentValue ? "CLEAR" : "SEARCH";
29
+ const iconSize = getFieldIconSize(size);
30
+ const composedInputRef = useComposedRefs(ref, setInputElRef);
34
31
  const handleClear = () => {
35
32
  const inputEl = inputElRef.current;
36
33
  if (!inputEl) return;
@@ -45,7 +42,6 @@ var SearchInput = ({ ref, size = "md", appearance = "standard", theme, className
45
42
  const newValue = event.target.value;
46
43
  setInnerValue(newValue);
47
44
  onValueChange?.(newValue);
48
- setActiveIcon(newValue ? "CLEAR" : "SEARCH");
49
45
  };
50
46
  const getIcon = () => {
51
47
  if (activeIcon === "SEARCH") return /* @__PURE__ */ jsx(StyledIcon, {
@@ -68,11 +64,11 @@ var SearchInput = ({ ref, size = "md", appearance = "standard", theme, className
68
64
  theme,
69
65
  className: cn("relative", "w-auto", className),
70
66
  children: [/* @__PURE__ */ jsx(InputText, {
71
- ref: setInputElRef,
67
+ ref: composedInputRef,
72
68
  size,
73
69
  type: "search",
74
70
  ...rest,
75
- value: innerValue,
71
+ value: currentValue,
76
72
  onChange: handleOnChange,
77
73
  className: cn(size === "sm" ? "pr-8" : "pr-10", "[&::-webkit-search-decoration]:appearance-none", "[&::-webkit-search-cancel-button]:appearance-none", "[&::-webkit-search-results-button]:appearance-none")
78
74
  }), getIcon()]
@@ -1 +1 @@
1
- {"version":3,"file":"SearchInput.js","names":[],"sources":["../../../src/components/search-input/SearchInput.tsx"],"sourcesContent":["import { Close, Search } from '@atom-learning/icons'\nimport * as React from 'react'\n\nimport { styled, cn } from '../../styled'\nimport { useCallbackRef } from '../../utilities/hooks/useCallbackRef'\nimport { getFieldIconSize } from '../../utilities/style/get-icon-size'\nimport { ActionIcon } from '../action-icon/ActionIcon'\nimport { Icon } from '../icon/Icon'\nimport { Input, InputBackground, InputText } from '../input/Input'\n\nexport type SearchInputProps = React.ComponentProps<typeof Input> & {\n size?: 'sm' | 'md' | 'lg'\n className?: string\n value?: string\n defaultValue?: string\n onValueChange?: (newValue: string) => void\n clearText?: string\n onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void\n}\n\nenum INPUT_ICON {\n SEARCH = 'SEARCH',\n CLEAR = 'CLEAR'\n}\n\nconst StyledIcon = styled(Icon, {\n base: ['text-grey-700', 'absolute', 'pointer-events-none'],\n variants: {\n size: {\n sm: ['right-2', 'size-4'],\n md: ['right-2.5', 'size-5'],\n lg: ['right-2.5', 'size-5']\n }\n }\n})\n\nexport const SearchInput = ({\n ref,\n size = 'md',\n appearance = 'standard',\n theme,\n className,\n value,\n defaultValue = '',\n onValueChange,\n clearText = 'Clear',\n onChange,\n ...rest\n}: SearchInputProps) => {\n const [inputElRef, setInputElRef] = useCallbackRef()\n const [innerValue, setInnerValue] = React.useState(defaultValue)\n const [activeIcon, setActiveIcon] = React.useState<INPUT_ICON>(\n defaultValue ? INPUT_ICON.CLEAR : INPUT_ICON.SEARCH\n )\n React.useEffect(() => {\n if (typeof value === 'undefined') return\n setInnerValue(value)\n setActiveIcon(value ? INPUT_ICON.CLEAR : INPUT_ICON.SEARCH)\n }, [value])\n\n const iconSize = React.useMemo(() => getFieldIconSize(size), [size])\n\n React.useImperativeHandle(ref, () => inputElRef.current as HTMLInputElement)\n\n const handleClear = () => {\n const inputEl = inputElRef.current\n if (!inputEl) return\n\n // https://stackoverflow.com/a/46012210\n const nativeInputValueSetter = Object.getOwnPropertyDescriptor(\n window.HTMLInputElement.prototype,\n 'value'\n )?.set\n nativeInputValueSetter?.call?.(inputEl, '')\n const ev2 = new Event('input', {\n bubbles: true\n })\n inputEl.dispatchEvent(ev2)\n inputEl.focus()\n onValueChange?.('')\n }\n\n const handleOnChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(event)\n\n const newValue = event.target.value\n setInnerValue(newValue)\n onValueChange?.(newValue)\n setActiveIcon(newValue ? INPUT_ICON.CLEAR : INPUT_ICON.SEARCH)\n }\n\n const getIcon = () => {\n if (activeIcon === INPUT_ICON.SEARCH)\n return (\n <StyledIcon\n is={Search}\n size={size}\n className={cn(\n size == 'sm' ? 'size-4' : 'size-5',\n 'top-1/2',\n '-translate-y-1/2'\n )}\n />\n )\n\n return (\n <ActionIcon\n label={clearText}\n theme=\"neutral\"\n size={iconSize}\n onClick={handleClear}\n className=\"absolute top-1/2 right-1 -translate-y-1/2\"\n >\n <Icon is={Close} />\n </ActionIcon>\n )\n }\n\n return (\n <InputBackground\n size={size}\n appearance={appearance}\n theme={theme}\n className={cn('relative', 'w-auto', className)}\n >\n <InputText\n ref={setInputElRef}\n size={size}\n type=\"search\"\n {...rest}\n value={innerValue}\n onChange={handleOnChange}\n className={cn(\n size === 'sm' ? 'pr-8' : 'pr-10',\n '[&::-webkit-search-decoration]:appearance-none',\n '[&::-webkit-search-cancel-button]:appearance-none',\n '[&::-webkit-search-results-button]:appearance-none'\n )}\n />\n {getIcon()}\n </InputBackground>\n )\n}\n"],"mappings":";;;;;;;;;;AAyBA,IAAM,aAAa,OAAO,MAAM;CAC9B,MAAM;EAAC;EAAiB;EAAY;CAAqB;CACzD,UAAU,EACR,MAAM;EACJ,IAAI,CAAC,WAAW,QAAQ;EACxB,IAAI,CAAC,aAAa,QAAQ;EAC1B,IAAI,CAAC,aAAa,QAAQ;CAC5B,EACF;AACF,CAAC;AAED,IAAa,eAAe,EAC1B,KACA,OAAO,MACP,aAAa,YACb,OACA,WACA,OACA,eAAe,IACf,eACA,YAAY,SACZ,UACA,GAAG,WACmB;CACtB,MAAM,CAAC,YAAY,iBAAiB,eAAe;CACnD,MAAM,CAAC,YAAY,iBAAiB,QAAM,SAAS,YAAY;CAC/D,MAAM,CAAC,YAAY,iBAAiB,QAAM,SACxC,eAAA,UAAA,QACF;CACA,QAAM,gBAAgB;EACpB,IAAI,OAAO,UAAU,aAAa;EAClC,cAAc,KAAK;EACnB,cAAc,QAAA,UAAA,QAA4C;CAC5D,GAAG,CAAC,KAAK,CAAC;CAEV,MAAM,WAAW,QAAM,cAAc,iBAAiB,IAAI,GAAG,CAAC,IAAI,CAAC;CAEnE,QAAM,oBAAoB,WAAW,WAAW,OAA2B;CAE3E,MAAM,oBAAoB;EACxB,MAAM,UAAU,WAAW;EAC3B,IAAI,CAAC,SAAS;EAOd,CAJ+B,OAAO,yBACpC,OAAO,iBAAiB,WACxB,OACF,CAAC,EAAE,IAAA,EACqB,OAAO,SAAS,EAAE;EAC1C,MAAM,MAAM,IAAI,MAAM,SAAS,EAC7B,SAAS,KACX,CAAC;EACD,QAAQ,cAAc,GAAG;EACzB,QAAQ,MAAM;EACd,gBAAgB,EAAE;CACpB;CAEA,MAAM,kBAAkB,UAA+C;EACrE,WAAW,KAAK;EAEhB,MAAM,WAAW,MAAM,OAAO;EAC9B,cAAc,QAAQ;EACtB,gBAAgB,QAAQ;EACxB,cAAc,WAAA,UAAA,QAA+C;CAC/D;CAEA,MAAM,gBAAgB;EACpB,IAAI,eAAA,UACF,OACE,oBAAC,YAAD;GACE,IAAI;GACE;GACN,WAAW,GACT,QAAQ,OAAO,WAAW,UAC1B,WACA,kBACF;EACD,CAAA;EAGL,OACE,oBAAC,YAAD;GACE,OAAO;GACP,OAAM;GACN,MAAM;GACN,SAAS;GACT,WAAU;aAEV,oBAAC,MAAD,EAAM,IAAI,MAAQ,CAAA;EACR,CAAA;CAEhB;CAEA,OACE,qBAAC,iBAAD;EACQ;EACM;EACL;EACP,WAAW,GAAG,YAAY,UAAU,SAAS;YAJ/C,CAME,oBAAC,WAAD;GACE,KAAK;GACC;GACN,MAAK;GACL,GAAI;GACJ,OAAO;GACP,UAAU;GACV,WAAW,GACT,SAAS,OAAO,SAAS,SACzB,kDACA,qDACA,oDACF;EACD,CAAA,GACA,QAAQ,CACM;;AAErB"}
1
+ {"version":3,"file":"SearchInput.js","names":[],"sources":["../../../src/components/search-input/SearchInput.tsx"],"sourcesContent":["import { Close, Search } from '@atom-learning/icons'\nimport { useComposedRefs } from '@radix-ui/react-compose-refs'\nimport * as React from 'react'\n\nimport { styled, cn } from '../../styled'\nimport { useCallbackRef } from '../../utilities/hooks/useCallbackRef'\nimport { getFieldIconSize } from '../../utilities/style/get-icon-size'\nimport { ActionIcon } from '../action-icon/ActionIcon'\nimport { Icon } from '../icon/Icon'\nimport { Input, InputBackground, InputText } from '../input/Input'\n\nexport type SearchInputProps = React.ComponentProps<typeof Input> & {\n size?: 'sm' | 'md' | 'lg'\n className?: string\n value?: string\n defaultValue?: string\n onValueChange?: (newValue: string) => void\n clearText?: string\n onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void\n}\n\nenum INPUT_ICON {\n SEARCH = 'SEARCH',\n CLEAR = 'CLEAR'\n}\n\nconst StyledIcon = styled(Icon, {\n base: ['text-grey-700', 'absolute', 'pointer-events-none'],\n variants: {\n size: {\n sm: ['right-2', 'size-4'],\n md: ['right-2.5', 'size-5'],\n lg: ['right-2.5', 'size-5']\n }\n }\n})\n\nexport const SearchInput = ({\n ref,\n size = 'md',\n appearance = 'standard',\n theme,\n className,\n value,\n defaultValue = '',\n onValueChange,\n clearText = 'Clear',\n onChange,\n ...rest\n}: SearchInputProps) => {\n const [inputElRef, setInputElRef] = useCallbackRef()\n const [innerValue, setInnerValue] = React.useState(defaultValue)\n // Derived during render mirroring `value` into state via an effect would\n // paint one stale frame per controlled update.\n const currentValue = value ?? innerValue\n const activeIcon = currentValue ? INPUT_ICON.CLEAR : INPUT_ICON.SEARCH\n\n const iconSize = getFieldIconSize(size)\n\n const composedInputRef = useComposedRefs(\n ref as React.Ref<HTMLElement>,\n setInputElRef\n )\n\n const handleClear = () => {\n const inputEl = inputElRef.current\n if (!inputEl) return\n\n // https://stackoverflow.com/a/46012210\n const nativeInputValueSetter = Object.getOwnPropertyDescriptor(\n window.HTMLInputElement.prototype,\n 'value'\n )?.set\n nativeInputValueSetter?.call?.(inputEl, '')\n const ev2 = new Event('input', {\n bubbles: true\n })\n inputEl.dispatchEvent(ev2)\n inputEl.focus()\n onValueChange?.('')\n }\n\n const handleOnChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(event)\n\n const newValue = event.target.value\n setInnerValue(newValue)\n onValueChange?.(newValue)\n }\n\n const getIcon = () => {\n if (activeIcon === INPUT_ICON.SEARCH)\n return (\n <StyledIcon\n is={Search}\n size={size}\n className={cn(\n size == 'sm' ? 'size-4' : 'size-5',\n 'top-1/2',\n '-translate-y-1/2'\n )}\n />\n )\n\n return (\n <ActionIcon\n label={clearText}\n theme=\"neutral\"\n size={iconSize}\n onClick={handleClear}\n className=\"absolute top-1/2 right-1 -translate-y-1/2\"\n >\n <Icon is={Close} />\n </ActionIcon>\n )\n }\n\n return (\n <InputBackground\n size={size}\n appearance={appearance}\n theme={theme}\n className={cn('relative', 'w-auto', className)}\n >\n <InputText\n ref={composedInputRef}\n size={size}\n type=\"search\"\n {...rest}\n value={currentValue}\n onChange={handleOnChange}\n className={cn(\n size === 'sm' ? 'pr-8' : 'pr-10',\n '[&::-webkit-search-decoration]:appearance-none',\n '[&::-webkit-search-cancel-button]:appearance-none',\n '[&::-webkit-search-results-button]:appearance-none'\n )}\n />\n {getIcon()}\n </InputBackground>\n )\n}\n"],"mappings":";;;;;;;;;;;AA0BA,IAAM,aAAa,OAAO,MAAM;CAC9B,MAAM;EAAC;EAAiB;EAAY;CAAqB;CACzD,UAAU,EACR,MAAM;EACJ,IAAI,CAAC,WAAW,QAAQ;EACxB,IAAI,CAAC,aAAa,QAAQ;EAC1B,IAAI,CAAC,aAAa,QAAQ;CAC5B,EACF;AACF,CAAC;AAED,IAAa,eAAe,EAC1B,KACA,OAAO,MACP,aAAa,YACb,OACA,WACA,OACA,eAAe,IACf,eACA,YAAY,SACZ,UACA,GAAG,WACmB;CACtB,MAAM,CAAC,YAAY,iBAAiB,eAAe;CACnD,MAAM,CAAC,YAAY,iBAAiB,QAAM,SAAS,YAAY;CAG/D,MAAM,eAAe,SAAS;CAC9B,MAAM,aAAa,eAAA,UAAA;CAEnB,MAAM,WAAW,iBAAiB,IAAI;CAEtC,MAAM,mBAAmB,gBACvB,KACA,aACF;CAEA,MAAM,oBAAoB;EACxB,MAAM,UAAU,WAAW;EAC3B,IAAI,CAAC,SAAS;EAOd,CAJ+B,OAAO,yBACpC,OAAO,iBAAiB,WACxB,OACF,CAAC,EAAE,IAAA,EACqB,OAAO,SAAS,EAAE;EAC1C,MAAM,MAAM,IAAI,MAAM,SAAS,EAC7B,SAAS,KACX,CAAC;EACD,QAAQ,cAAc,GAAG;EACzB,QAAQ,MAAM;EACd,gBAAgB,EAAE;CACpB;CAEA,MAAM,kBAAkB,UAA+C;EACrE,WAAW,KAAK;EAEhB,MAAM,WAAW,MAAM,OAAO;EAC9B,cAAc,QAAQ;EACtB,gBAAgB,QAAQ;CAC1B;CAEA,MAAM,gBAAgB;EACpB,IAAI,eAAA,UACF,OACE,oBAAC,YAAD;GACE,IAAI;GACE;GACN,WAAW,GACT,QAAQ,OAAO,WAAW,UAC1B,WACA,kBACF;EACD,CAAA;EAGL,OACE,oBAAC,YAAD;GACE,OAAO;GACP,OAAM;GACN,MAAM;GACN,SAAS;GACT,WAAU;aAEV,oBAAC,MAAD,EAAM,IAAI,MAAQ,CAAA;EACR,CAAA;CAEhB;CAEA,OACE,qBAAC,iBAAD;EACQ;EACM;EACL;EACP,WAAW,GAAG,YAAY,UAAU,SAAS;YAJ/C,CAME,oBAAC,WAAD;GACE,KAAK;GACC;GACN,MAAK;GACL,GAAI;GACJ,OAAO;GACP,UAAU;GACV,WAAW,GACT,SAAS,OAAO,SAAS,SACzB,kDACA,qDACA,oDACF;EACD,CAAA,GACA,QAAQ,CACM;;AAErB"}
@@ -5,26 +5,25 @@ var SectionMessageContext = React$1.createContext(null);
5
5
  var SectionMessageProvider = ({ theme = "info", children }) => {
6
6
  const [hasIcon, setHasIcon] = React$1.useState(false);
7
7
  const [hasDismiss, setHasDismiss] = React$1.useState(false);
8
- const value = React$1.useMemo(() => ({
9
- theme,
10
- hasIcon,
11
- setHasIcon,
12
- hasDismiss,
13
- setHasDismiss
14
- }), [
15
- theme,
16
- hasIcon,
17
- setHasIcon,
18
- hasDismiss,
19
- setHasDismiss
20
- ]);
21
- return /* @__PURE__ */ jsx(SectionMessageContext.Provider, {
22
- value,
8
+ return /* @__PURE__ */ jsx(SectionMessageContext, {
9
+ value: React$1.useMemo(() => ({
10
+ theme,
11
+ hasIcon,
12
+ setHasIcon,
13
+ hasDismiss,
14
+ setHasDismiss
15
+ }), [
16
+ theme,
17
+ hasIcon,
18
+ setHasIcon,
19
+ hasDismiss,
20
+ setHasDismiss
21
+ ]),
23
22
  children
24
23
  });
25
24
  };
26
25
  var useSectionMessageContext = () => {
27
- const context = React$1.useContext(SectionMessageContext);
26
+ const context = React$1.use(SectionMessageContext);
28
27
  if (!context) throw new Error("useSectionMessageContext must be used within a SectionMessageProvider");
29
28
  return context;
30
29
  };
@@ -1 +1 @@
1
- {"version":3,"file":"SectionMessage.context.js","names":[],"sources":["../../../src/components/section-message/SectionMessage.context.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport type { SectionMessageTheme } from './SectionMessage'\n\nexport type SectionMessageContextValue = {\n theme: SectionMessageTheme\n hasIcon: boolean\n setHasIcon: React.Dispatch<React.SetStateAction<boolean>>\n hasDismiss: boolean\n setHasDismiss: React.Dispatch<React.SetStateAction<boolean>>\n}\nexport type SectionMessageProviderProps = {\n theme: SectionMessageTheme\n children: React.ReactNode\n}\n\nexport const SectionMessageContext =\n React.createContext<SectionMessageContextValue | null>(null)\n\nexport const SectionMessageProvider = ({\n theme = 'info',\n children\n}: SectionMessageProviderProps) => {\n const [hasIcon, setHasIcon] = React.useState(false)\n const [hasDismiss, setHasDismiss] = React.useState(false)\n\n const value = React.useMemo<SectionMessageContextValue>(\n () => ({ theme, hasIcon, setHasIcon, hasDismiss, setHasDismiss }),\n [theme, hasIcon, setHasIcon, hasDismiss, setHasDismiss]\n )\n\n return (\n <SectionMessageContext.Provider value={value}>\n {children}\n </SectionMessageContext.Provider>\n )\n}\n\nexport const useSectionMessageContext = (): SectionMessageContextValue => {\n const context = React.useContext(SectionMessageContext)\n\n if (!context) {\n throw new Error(\n 'useSectionMessageContext must be used within a SectionMessageProvider'\n )\n }\n\n return context\n}\n"],"mappings":";;;AAgBA,IAAa,wBACX,QAAM,cAAiD,IAAI;AAE7D,IAAa,0BAA0B,EACrC,QAAQ,QACR,eACiC;CACjC,MAAM,CAAC,SAAS,cAAc,QAAM,SAAS,KAAK;CAClD,MAAM,CAAC,YAAY,iBAAiB,QAAM,SAAS,KAAK;CAExD,MAAM,QAAQ,QAAM,eACX;EAAE;EAAO;EAAS;EAAY;EAAY;CAAc,IAC/D;EAAC;EAAO;EAAS;EAAY;EAAY;CAAa,CACxD;CAEA,OACE,oBAAC,sBAAsB,UAAvB;EAAuC;EACpC;CAC6B,CAAA;AAEpC;AAEA,IAAa,iCAA6D;CACxE,MAAM,UAAU,QAAM,WAAW,qBAAqB;CAEtD,IAAI,CAAC,SACH,MAAM,IAAI,MACR,uEACF;CAGF,OAAO;AACT"}
1
+ {"version":3,"file":"SectionMessage.context.js","names":[],"sources":["../../../src/components/section-message/SectionMessage.context.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport type { SectionMessageTheme } from './SectionMessage'\n\nexport type SectionMessageContextValue = {\n theme: SectionMessageTheme\n hasIcon: boolean\n setHasIcon: React.Dispatch<React.SetStateAction<boolean>>\n hasDismiss: boolean\n setHasDismiss: React.Dispatch<React.SetStateAction<boolean>>\n}\nexport type SectionMessageProviderProps = {\n theme: SectionMessageTheme\n children: React.ReactNode\n}\n\nexport const SectionMessageContext =\n React.createContext<SectionMessageContextValue | null>(null)\n\nexport const SectionMessageProvider = ({\n theme = 'info',\n children\n}: SectionMessageProviderProps) => {\n const [hasIcon, setHasIcon] = React.useState(false)\n const [hasDismiss, setHasDismiss] = React.useState(false)\n\n const value = React.useMemo<SectionMessageContextValue>(\n () => ({ theme, hasIcon, setHasIcon, hasDismiss, setHasDismiss }),\n [theme, hasIcon, setHasIcon, hasDismiss, setHasDismiss]\n )\n\n return <SectionMessageContext value={value}>{children}</SectionMessageContext>\n}\n\nexport const useSectionMessageContext = (): SectionMessageContextValue => {\n const context = React.use(SectionMessageContext)\n\n if (!context) {\n throw new Error(\n 'useSectionMessageContext must be used within a SectionMessageProvider'\n )\n }\n\n return context\n}\n"],"mappings":";;;AAgBA,IAAa,wBACX,QAAM,cAAiD,IAAI;AAE7D,IAAa,0BAA0B,EACrC,QAAQ,QACR,eACiC;CACjC,MAAM,CAAC,SAAS,cAAc,QAAM,SAAS,KAAK;CAClD,MAAM,CAAC,YAAY,iBAAiB,QAAM,SAAS,KAAK;CAOxD,OAAO,oBAAC,uBAAD;EAA8B,OALvB,QAAM,eACX;GAAE;GAAO;GAAS;GAAY;GAAY;EAAc,IAC/D;GAAC;GAAO;GAAS;GAAY;GAAY;EAAa,CAGnB;EAAQ;CAAgC,CAAA;AAC/E;AAEA,IAAa,iCAA6D;CACxE,MAAM,UAAU,QAAM,IAAI,qBAAqB;CAE/C,IAAI,CAAC,SACH,MAAM,IAAI,MACR,uEACF;CAGF,OAAO;AACT"}
@@ -10,7 +10,7 @@ var badgeSizeMap = {
10
10
  lg: "sm"
11
11
  };
12
12
  var SegmentedControlBadge = ({ className, ...rest }) => {
13
- const { size } = React$1.useContext(SegmentedControlContext);
13
+ const { size } = React$1.use(SegmentedControlContext);
14
14
  return /* @__PURE__ */ jsx(Badge, {
15
15
  ...rest,
16
16
  size: badgeSizeMap[size],
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentedControlBadge.js","names":[],"sources":["../../../src/components/segmented-control/SegmentedControlBadge.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { cn } from '../../styled'\nimport { Badge } from '../badge/Badge'\nimport { SegmentedControlContext } from './SegmentedControl.context'\n\nconst badgeSizeMap = {\n sm: 'xs',\n md: 'xs',\n lg: 'sm'\n}\n\nexport const SegmentedControlBadge = ({\n className,\n ...rest\n}: Omit<React.ComponentProps<typeof Badge>, 'size'>) => {\n const { size } = React.useContext(SegmentedControlContext)\n\n return (\n <Badge\n {...rest}\n size={badgeSizeMap[size as string]}\n className={cn('border-none', 'font-normal', className)}\n />\n )\n}\n"],"mappings":";;;;;;AAMA,IAAM,eAAe;CACnB,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,IAAa,yBAAyB,EACpC,WACA,GAAG,WACmD;CACtD,MAAM,EAAE,SAAS,QAAM,WAAW,uBAAuB;CAEzD,OACE,oBAAC,OAAD;EACE,GAAI;EACJ,MAAM,aAAa;EACnB,WAAW,GAAG,eAAe,eAAe,SAAS;CACtD,CAAA;AAEL"}
1
+ {"version":3,"file":"SegmentedControlBadge.js","names":[],"sources":["../../../src/components/segmented-control/SegmentedControlBadge.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { cn } from '../../styled'\nimport { Badge } from '../badge/Badge'\nimport { SegmentedControlContext } from './SegmentedControl.context'\n\nconst badgeSizeMap = {\n sm: 'xs',\n md: 'xs',\n lg: 'sm'\n}\n\nexport const SegmentedControlBadge = ({\n className,\n ...rest\n}: Omit<React.ComponentProps<typeof Badge>, 'size'>) => {\n const { size } = React.use(SegmentedControlContext)\n\n return (\n <Badge\n {...rest}\n size={badgeSizeMap[size as string]}\n className={cn('border-none', 'font-normal', className)}\n />\n )\n}\n"],"mappings":";;;;;;AAMA,IAAM,eAAe;CACnB,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,IAAa,yBAAyB,EACpC,WACA,GAAG,WACmD;CACtD,MAAM,EAAE,SAAS,QAAM,IAAI,uBAAuB;CAElD,OACE,oBAAC,OAAD;EACE,GAAI;EACJ,MAAM,aAAa;EACnB,WAAW,GAAG,eAAe,eAAe,SAAS;CACtD,CAAA;AAEL"}
@@ -17,7 +17,7 @@ var StyledText = styled(Text, {
17
17
  } }
18
18
  }, { enableResponsiveVariants: true });
19
19
  var SegmentedControlDescription = (props) => {
20
- const { size } = React$1.useContext(SegmentedControlContext);
20
+ const { size } = React$1.use(SegmentedControlContext);
21
21
  return /* @__PURE__ */ jsx(StyledText, {
22
22
  ...props,
23
23
  size
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentedControlDescription.js","names":[],"sources":["../../../src/components/segmented-control/SegmentedControlDescription.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { styled } from '../../styled'\nimport { Text } from '../text/Text'\nimport { SegmentedControlContext } from './SegmentedControl.context'\n\nconst StyledText = styled(\n Text,\n {\n base: ['font-body', 'text-text-subtle', 'font-normal'],\n variants: {\n size: {\n sm: ['text-xs', 'leading-[1.6]'],\n md: ['text-sm', 'leading-[1.53]'],\n lg: ['text-md', 'leading-normal']\n }\n }\n },\n { enableResponsiveVariants: true }\n)\n\nexport const SegmentedControlDescription = (\n props: Omit<React.ComponentProps<typeof StyledText>, 'size'>\n) => {\n const { size } = React.useContext(SegmentedControlContext)\n\n return <StyledText {...props} size={size} />\n}\n"],"mappings":";;;;;;AAMA,IAAM,aAAa,OACjB,MACA;CACE,MAAM;EAAC;EAAa;EAAoB;CAAa;CACrD,UAAU,EACR,MAAM;EACJ,IAAI,CAAC,WAAW,eAAe;EAC/B,IAAI,CAAC,WAAW,gBAAgB;EAChC,IAAI,CAAC,WAAW,gBAAgB;CAClC,EACF;AACF,GACA,EAAE,0BAA0B,KAAK,CACnC;AAEA,IAAa,+BACX,UACG;CACH,MAAM,EAAE,SAAS,QAAM,WAAW,uBAAuB;CAEzD,OAAO,oBAAC,YAAD;EAAY,GAAI;EAAa;CAAO,CAAA;AAC7C"}
1
+ {"version":3,"file":"SegmentedControlDescription.js","names":[],"sources":["../../../src/components/segmented-control/SegmentedControlDescription.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { styled } from '../../styled'\nimport { Text } from '../text/Text'\nimport { SegmentedControlContext } from './SegmentedControl.context'\n\nconst StyledText = styled(\n Text,\n {\n base: ['font-body', 'text-text-subtle', 'font-normal'],\n variants: {\n size: {\n sm: ['text-xs', 'leading-[1.6]'],\n md: ['text-sm', 'leading-[1.53]'],\n lg: ['text-md', 'leading-normal']\n }\n }\n },\n { enableResponsiveVariants: true }\n)\n\nexport const SegmentedControlDescription = (\n props: Omit<React.ComponentProps<typeof StyledText>, 'size'>\n) => {\n const { size } = React.use(SegmentedControlContext)\n\n return <StyledText {...props} size={size} />\n}\n"],"mappings":";;;;;;AAMA,IAAM,aAAa,OACjB,MACA;CACE,MAAM;EAAC;EAAa;EAAoB;CAAa;CACrD,UAAU,EACR,MAAM;EACJ,IAAI,CAAC,WAAW,eAAe;EAC/B,IAAI,CAAC,WAAW,gBAAgB;EAChC,IAAI,CAAC,WAAW,gBAAgB;CAClC,EACF;AACF,GACA,EAAE,0BAA0B,KAAK,CACnC;AAEA,IAAa,+BACX,UACG;CACH,MAAM,EAAE,SAAS,QAAM,IAAI,uBAAuB;CAElD,OAAO,oBAAC,YAAD;EAAY,GAAI;EAAa;CAAO,CAAA;AAC7C"}
@@ -13,7 +13,7 @@ var StyledHeading = styled(Text, {
13
13
  } }
14
14
  }, { enableResponsiveVariants: true });
15
15
  var SegmentedControlHeading = (props) => {
16
- const { size } = React$1.useContext(SegmentedControlContext);
16
+ const { size } = React$1.use(SegmentedControlContext);
17
17
  return /* @__PURE__ */ jsx(StyledHeading, {
18
18
  ...props,
19
19
  size
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentedControlHeading.js","names":[],"sources":["../../../src/components/segmented-control/SegmentedControlHeading.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { styled } from '../../styled'\nimport { Text } from '../text/Text'\nimport { SegmentedControlContext } from './SegmentedControl.context'\n\nconst StyledHeading = styled(\n Text,\n {\n base: ['font-body', 'text-text-regular'],\n variants: {\n size: {\n sm: ['text-sm', 'leading-[1.53]'],\n md: ['text-md', 'leading-normal'],\n lg: ['text-lg', 'leading-[1.52]']\n }\n }\n },\n { enableResponsiveVariants: true }\n)\n\nexport const SegmentedControlHeading = (\n props: Omit<React.ComponentProps<typeof StyledHeading>, 'size'>\n) => {\n const { size } = React.useContext(SegmentedControlContext)\n\n return <StyledHeading {...props} size={size} />\n}\n"],"mappings":";;;;;;AAMA,IAAM,gBAAgB,OACpB,MACA;CACE,MAAM,CAAC,aAAa,mBAAmB;CACvC,UAAU,EACR,MAAM;EACJ,IAAI,CAAC,WAAW,gBAAgB;EAChC,IAAI,CAAC,WAAW,gBAAgB;EAChC,IAAI,CAAC,WAAW,gBAAgB;CAClC,EACF;AACF,GACA,EAAE,0BAA0B,KAAK,CACnC;AAEA,IAAa,2BACX,UACG;CACH,MAAM,EAAE,SAAS,QAAM,WAAW,uBAAuB;CAEzD,OAAO,oBAAC,eAAD;EAAe,GAAI;EAAa;CAAO,CAAA;AAChD"}
1
+ {"version":3,"file":"SegmentedControlHeading.js","names":[],"sources":["../../../src/components/segmented-control/SegmentedControlHeading.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { styled } from '../../styled'\nimport { Text } from '../text/Text'\nimport { SegmentedControlContext } from './SegmentedControl.context'\n\nconst StyledHeading = styled(\n Text,\n {\n base: ['font-body', 'text-text-regular'],\n variants: {\n size: {\n sm: ['text-sm', 'leading-[1.53]'],\n md: ['text-md', 'leading-normal'],\n lg: ['text-lg', 'leading-[1.52]']\n }\n }\n },\n { enableResponsiveVariants: true }\n)\n\nexport const SegmentedControlHeading = (\n props: Omit<React.ComponentProps<typeof StyledHeading>, 'size'>\n) => {\n const { size } = React.use(SegmentedControlContext)\n\n return <StyledHeading {...props} size={size} />\n}\n"],"mappings":";;;;;;AAMA,IAAM,gBAAgB,OACpB,MACA;CACE,MAAM,CAAC,aAAa,mBAAmB;CACvC,UAAU,EACR,MAAM;EACJ,IAAI,CAAC,WAAW,gBAAgB;EAChC,IAAI,CAAC,WAAW,gBAAgB;EAChC,IAAI,CAAC,WAAW,gBAAgB;CAClC,EACF;AACF,GACA,EAAE,0BAA0B,KAAK,CACnC;AAEA,IAAa,2BACX,UACG;CACH,MAAM,EAAE,SAAS,QAAM,IAAI,uBAAuB;CAElD,OAAO,oBAAC,eAAD;EAAe,GAAI;EAAa;CAAO,CAAA;AAChD"}
@@ -9,7 +9,7 @@ var sizeMap = {
9
9
  lg: "md"
10
10
  };
11
11
  var SegmentedControlIcon = (props) => {
12
- const { size } = React$1.useContext(SegmentedControlContext);
12
+ const { size } = React$1.use(SegmentedControlContext);
13
13
  return /* @__PURE__ */ jsx(Icon, {
14
14
  ...props,
15
15
  size: sizeMap[size]
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentedControlIcon.js","names":[],"sources":["../../../src/components/segmented-control/SegmentedControlIcon.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { Icon } from '../icon/Icon'\nimport { SegmentedControlContext } from './SegmentedControl.context'\n\nconst sizeMap = {\n sm: 'sm',\n md: 'md',\n lg: 'md'\n}\n\nexport const SegmentedControlIcon = (\n props: Omit<React.ComponentProps<typeof Icon>, 'size'>\n) => {\n const { size } = React.useContext(SegmentedControlContext)\n\n return (\n <Icon\n {...(props as React.ComponentProps<typeof Icon>)}\n size={sizeMap[size as string]}\n />\n )\n}\n"],"mappings":";;;;;AAKA,IAAM,UAAU;CACd,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,IAAa,wBACX,UACG;CACH,MAAM,EAAE,SAAS,QAAM,WAAW,uBAAuB;CAEzD,OACE,oBAAC,MAAD;EACE,GAAK;EACL,MAAM,QAAQ;CACf,CAAA;AAEL"}
1
+ {"version":3,"file":"SegmentedControlIcon.js","names":[],"sources":["../../../src/components/segmented-control/SegmentedControlIcon.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { Icon } from '../icon/Icon'\nimport { SegmentedControlContext } from './SegmentedControl.context'\n\nconst sizeMap = {\n sm: 'sm',\n md: 'md',\n lg: 'md'\n}\n\nexport const SegmentedControlIcon = (\n props: Omit<React.ComponentProps<typeof Icon>, 'size'>\n) => {\n const { size } = React.use(SegmentedControlContext)\n\n return (\n <Icon\n {...(props as React.ComponentProps<typeof Icon>)}\n size={sizeMap[size as string]}\n />\n )\n}\n"],"mappings":";;;;;AAKA,IAAM,UAAU;CACd,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,IAAa,wBACX,UACG;CACH,MAAM,EAAE,SAAS,QAAM,IAAI,uBAAuB;CAElD,OACE,oBAAC,MAAD;EACE,GAAK;EACL,MAAM,QAAQ;CACf,CAAA;AAEL"}
@@ -64,7 +64,7 @@ var StyledItem = styled(Trigger, {
64
64
  }
65
65
  }, { enableResponsiveVariants: true });
66
66
  var SegmentedControlItem = ({ ref, children, ...rest }) => {
67
- const { size, theme } = React$1.useContext(SegmentedControlContext);
67
+ const { size, theme } = React$1.use(SegmentedControlContext);
68
68
  return /* @__PURE__ */ jsx(StyledItem, {
69
69
  ...rest,
70
70
  theme,
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentedControlItem.js","names":[],"sources":["../../../src/components/segmented-control/SegmentedControlItem.tsx"],"sourcesContent":["import { Trigger } from '@radix-ui/react-tabs'\nimport * as React from 'react'\n\nimport { styled } from '../../styled'\nimport { SegmentedControlContext } from './SegmentedControl.context'\n\nconst StyledItem = styled(\n Trigger,\n {\n base: [\n 'relative',\n 'bg-transparent',\n 'rounded-md',\n 'z-2',\n 'min-w-35',\n 'border-2',\n 'border-transparent',\n 'cursor-pointer',\n 'select-none',\n 'flex',\n 'flex-col',\n 'items-center',\n 'justify-center',\n 'data-[state=active]:border-2',\n 'data-[state=active]:border-transparent',\n 'data-[state=active]:focus-visible:border-primary-800',\n 'data-[state=active]:focus-visible:shadow-none',\n 'data-[state=active]:font-semibold',\n 'data-[state=active]:shadow-none',\n 'data-[state=active]:text-(--text-bold)',\n 'data-[state=inactive]:font-normal',\n 'data-[state=inactive]:text-grey-900',\n 'disabled:cursor-not-allowed',\n 'disabled:opacity-30',\n 'focus-visible:outline-none'\n ],\n variants: {\n theme: {\n primary: [\n 'data-[state=inactive]:hover:bg-primary-300',\n 'focus-visible:border-primary-800'\n ],\n marsh: [\n 'data-[state=inactive]:hover:bg-marsh-300',\n 'focus-visible:border-marsh-800'\n ]\n },\n size: {\n sm: ['flex-[unset]', 'gap-3', 'px-6', 'py-4'],\n md: ['flex-1', 'gap-4', 'px-4', 'py-6'],\n lg: ['flex-1', 'gap-4', 'px-4', 'py-6']\n }\n },\n defaultVariants: {\n size: 'md',\n theme: 'primary'\n }\n },\n { enableResponsiveVariants: true }\n)\n\nexport const SegmentedControlItem = ({\n ref,\n children,\n ...rest\n}: Omit<React.ComponentProps<typeof StyledItem>, 'size'>) => {\n const { size, theme } = React.useContext(SegmentedControlContext)\n\n return (\n <StyledItem {...rest} theme={theme} size={size} ref={ref}>\n {children}\n </StyledItem>\n )\n}\n"],"mappings":";;;;;;AAMA,IAAM,aAAa,OACjB,SACA;CACE,MAAM;EACJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,UAAU;EACR,OAAO;GACL,SAAS,CACP,8CACA,kCACF;GACA,OAAO,CACL,4CACA,gCACF;EACF;EACA,MAAM;GACJ,IAAI;IAAC;IAAgB;IAAS;IAAQ;GAAM;GAC5C,IAAI;IAAC;IAAU;IAAS;IAAQ;GAAM;GACtC,IAAI;IAAC;IAAU;IAAS;IAAQ;GAAM;EACxC;CACF;CACA,iBAAiB;EACf,MAAM;EACN,OAAO;CACT;AACF,GACA,EAAE,0BAA0B,KAAK,CACnC;AAEA,IAAa,wBAAwB,EACnC,KACA,UACA,GAAG,WACwD;CAC3D,MAAM,EAAE,MAAM,UAAU,QAAM,WAAW,uBAAuB;CAEhE,OACE,oBAAC,YAAD;EAAY,GAAI;EAAa;EAAa;EAAW;EAClD;CACS,CAAA;AAEhB"}
1
+ {"version":3,"file":"SegmentedControlItem.js","names":[],"sources":["../../../src/components/segmented-control/SegmentedControlItem.tsx"],"sourcesContent":["import { Trigger } from '@radix-ui/react-tabs'\nimport * as React from 'react'\n\nimport { styled } from '../../styled'\nimport { SegmentedControlContext } from './SegmentedControl.context'\n\nconst StyledItem = styled(\n Trigger,\n {\n base: [\n 'relative',\n 'bg-transparent',\n 'rounded-md',\n 'z-2',\n 'min-w-35',\n 'border-2',\n 'border-transparent',\n 'cursor-pointer',\n 'select-none',\n 'flex',\n 'flex-col',\n 'items-center',\n 'justify-center',\n 'data-[state=active]:border-2',\n 'data-[state=active]:border-transparent',\n 'data-[state=active]:focus-visible:border-primary-800',\n 'data-[state=active]:focus-visible:shadow-none',\n 'data-[state=active]:font-semibold',\n 'data-[state=active]:shadow-none',\n 'data-[state=active]:text-(--text-bold)',\n 'data-[state=inactive]:font-normal',\n 'data-[state=inactive]:text-grey-900',\n 'disabled:cursor-not-allowed',\n 'disabled:opacity-30',\n 'focus-visible:outline-none'\n ],\n variants: {\n theme: {\n primary: [\n 'data-[state=inactive]:hover:bg-primary-300',\n 'focus-visible:border-primary-800'\n ],\n marsh: [\n 'data-[state=inactive]:hover:bg-marsh-300',\n 'focus-visible:border-marsh-800'\n ]\n },\n size: {\n sm: ['flex-[unset]', 'gap-3', 'px-6', 'py-4'],\n md: ['flex-1', 'gap-4', 'px-4', 'py-6'],\n lg: ['flex-1', 'gap-4', 'px-4', 'py-6']\n }\n },\n defaultVariants: {\n size: 'md',\n theme: 'primary'\n }\n },\n { enableResponsiveVariants: true }\n)\n\nexport const SegmentedControlItem = ({\n ref,\n children,\n ...rest\n}: Omit<React.ComponentProps<typeof StyledItem>, 'size'>) => {\n const { size, theme } = React.use(SegmentedControlContext)\n\n return (\n <StyledItem {...rest} theme={theme} size={size} ref={ref}>\n {children}\n </StyledItem>\n )\n}\n"],"mappings":";;;;;;AAMA,IAAM,aAAa,OACjB,SACA;CACE,MAAM;EACJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,UAAU;EACR,OAAO;GACL,SAAS,CACP,8CACA,kCACF;GACA,OAAO,CACL,4CACA,gCACF;EACF;EACA,MAAM;GACJ,IAAI;IAAC;IAAgB;IAAS;IAAQ;GAAM;GAC5C,IAAI;IAAC;IAAU;IAAS;IAAQ;GAAM;GACtC,IAAI;IAAC;IAAU;IAAS;IAAQ;GAAM;EACxC;CACF;CACA,iBAAiB;EACf,MAAM;EACN,OAAO;CACT;AACF,GACA,EAAE,0BAA0B,KAAK,CACnC;AAEA,IAAa,wBAAwB,EACnC,KACA,UACA,GAAG,WACwD;CAC3D,MAAM,EAAE,MAAM,UAAU,QAAM,IAAI,uBAAuB;CAEzD,OACE,oBAAC,YAAD;EAAY,GAAI;EAAa;EAAa;EAAW;EAClD;CACS,CAAA;AAEhB"}