@protonradio/proton-ui 0.11.15 → 0.11.16
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.
- package/README.md +148 -148
- package/dist/assets/svg/icons.svg.cjs.js.map +1 -1
- package/dist/assets/svg/icons.svg.es.js.map +1 -1
- package/dist/components/ActionMenu/ActionMenu.cjs.js.map +1 -1
- package/dist/components/ActionMenu/ActionMenu.es.js.map +1 -1
- package/dist/components/Badge/Badge.cjs.js.map +1 -1
- package/dist/components/Badge/Badge.es.js.map +1 -1
- package/dist/components/Banner/Banner.cjs.js.map +1 -1
- package/dist/components/Banner/Banner.es.js.map +1 -1
- package/dist/components/Button/Button.cjs.js.map +1 -1
- package/dist/components/Button/Button.es.js.map +1 -1
- package/dist/components/ButtonGroup/ButtonGroup.cjs.js.map +1 -1
- package/dist/components/ButtonGroup/ButtonGroup.es.js.map +1 -1
- package/dist/components/ButtonWithSelect/ButtonWithSelect.cjs.js +1 -1
- package/dist/components/ButtonWithSelect/ButtonWithSelect.cjs.js.map +1 -1
- package/dist/components/ButtonWithSelect/ButtonWithSelect.es.js +29 -27
- package/dist/components/ButtonWithSelect/ButtonWithSelect.es.js.map +1 -1
- package/dist/components/DataTable/DataTable.cjs.js.map +1 -1
- package/dist/components/DataTable/DataTable.es.js.map +1 -1
- package/dist/components/Dialog/Dialog.cjs.js.map +1 -1
- package/dist/components/Dialog/Dialog.es.js.map +1 -1
- package/dist/components/Elevation/Elevation.cjs.js.map +1 -1
- package/dist/components/Elevation/Elevation.es.js.map +1 -1
- package/dist/components/Icon/Icon.cjs.js.map +1 -1
- package/dist/components/Icon/Icon.es.js.map +1 -1
- package/dist/components/ImageBackground/ImageBackground.cjs.js.map +1 -1
- package/dist/components/ImageBackground/ImageBackground.es.js.map +1 -1
- package/dist/components/Input/BaseInput/Input.cjs.js.map +1 -1
- package/dist/components/Input/BaseInput/Input.es.js.map +1 -1
- package/dist/components/Input/CopyInput/CopyInput.cjs.js.map +1 -1
- package/dist/components/Input/CopyInput/CopyInput.es.js.map +1 -1
- package/dist/components/Input/SearchInput/SearchInput.cjs.js.map +1 -1
- package/dist/components/Input/SearchInput/SearchInput.es.js.map +1 -1
- package/dist/components/Menu/MenuTrigger.cjs.js.map +1 -1
- package/dist/components/Menu/MenuTrigger.es.js.map +1 -1
- package/dist/components/Menu/PopoverMenu.cjs.js +1 -1
- package/dist/components/Menu/PopoverMenu.cjs.js.map +1 -1
- package/dist/components/Menu/PopoverMenu.es.js +28 -32
- package/dist/components/Menu/PopoverMenu.es.js.map +1 -1
- package/dist/components/Modal/Modal.cjs.js.map +1 -1
- package/dist/components/Modal/Modal.es.js.map +1 -1
- package/dist/components/Popover/Popover.cjs.js.map +1 -1
- package/dist/components/Popover/Popover.es.js.map +1 -1
- package/dist/components/ScreenOverlay/ScreenOverlay.cjs.js.map +1 -1
- package/dist/components/ScreenOverlay/ScreenOverlay.es.js.map +1 -1
- package/dist/components/Select/Select.cjs.js.map +1 -1
- package/dist/components/Select/Select.es.js +3 -3
- package/dist/components/Select/Select.es.js.map +1 -1
- package/dist/components/Switch/Switch.cjs.js.map +1 -1
- package/dist/components/Switch/Switch.es.js.map +1 -1
- package/dist/components/Table/Collection/CompoundComponents.cjs.js.map +1 -1
- package/dist/components/Table/Collection/CompoundComponents.es.js.map +1 -1
- package/dist/components/Table/Collection/collectionParser.cjs.js.map +1 -1
- package/dist/components/Table/Collection/collectionParser.es.js.map +1 -1
- package/dist/components/Table/Collection/useTableCollection.cjs.js.map +1 -1
- package/dist/components/Table/Collection/useTableCollection.es.js.map +1 -1
- package/dist/components/Table/Table.cjs.js.map +1 -1
- package/dist/components/Table/Table.es.js +5 -5
- package/dist/components/Table/Table.es.js.map +1 -1
- package/dist/components/Text/TextEllipsis/TextEllipsis.cjs.js.map +1 -1
- package/dist/components/Text/TextEllipsis/TextEllipsis.es.js.map +1 -1
- package/dist/components/Text/TextEmphasis/TextEmphasis.cjs.js.map +1 -1
- package/dist/components/Text/TextEmphasis/TextEmphasis.es.js.map +1 -1
- package/dist/components/ThemeProvider.cjs.js.map +1 -1
- package/dist/components/ThemeProvider.es.js +4 -4
- package/dist/components/ThemeProvider.es.js.map +1 -1
- package/dist/components/Tombstone/Tombstone.cjs.js.map +1 -1
- package/dist/components/Tombstone/Tombstone.es.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.cjs.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.es.js.map +1 -1
- package/dist/components/Waveform/Waveform.cjs.js.map +1 -1
- package/dist/components/Waveform/Waveform.es.js.map +1 -1
- package/dist/components/Waveform/WaveformBar.cjs.js.map +1 -1
- package/dist/components/Waveform/WaveformBar.es.js.map +1 -1
- package/dist/constants/breakpoint.cjs.js.map +1 -1
- package/dist/constants/breakpoint.es.js.map +1 -1
- package/dist/constants/placement.cjs.js.map +1 -1
- package/dist/constants/placement.es.js.map +1 -1
- package/dist/design/colors.cjs.js.map +1 -1
- package/dist/design/colors.es.js.map +1 -1
- package/dist/design/darkTheme/colors.cjs.js.map +1 -1
- package/dist/design/darkTheme/colors.es.js +3 -3
- package/dist/design/darkTheme/colors.es.js.map +1 -1
- package/dist/design/darkTheme/stylesheet.cjs.js.map +1 -1
- package/dist/design/darkTheme/stylesheet.es.js +12 -12
- package/dist/design/darkTheme/stylesheet.es.js.map +1 -1
- package/dist/design/generateStylesheet.cjs.js.map +1 -1
- package/dist/design/generateStylesheet.es.js.map +1 -1
- package/dist/design/lightTheme/colors.cjs.js.map +1 -1
- package/dist/design/lightTheme/colors.es.js +3 -3
- package/dist/design/lightTheme/colors.es.js.map +1 -1
- package/dist/design/lightTheme/stylesheet.cjs.js.map +1 -1
- package/dist/design/lightTheme/stylesheet.es.js +12 -12
- package/dist/design/lightTheme/stylesheet.es.js.map +1 -1
- package/dist/design/theme.cjs.js.map +1 -1
- package/dist/design/theme.es.js.map +1 -1
- package/dist/hooks/useBreakpoint.cjs.js.map +1 -1
- package/dist/hooks/useBreakpoint.es.js.map +1 -1
- package/dist/hooks/useIsClosing.cjs.js.map +1 -1
- package/dist/hooks/useIsClosing.es.js.map +1 -1
- package/dist/hooks/useLockBodyScroll.cjs.js.map +1 -1
- package/dist/hooks/useLockBodyScroll.es.js.map +1 -1
- package/dist/hooks/usePalette.cjs.js.map +1 -1
- package/dist/hooks/usePalette.es.js.map +1 -1
- package/dist/icons.svg +10 -10
- package/dist/index.d.ts +38 -38
- package/dist/node_modules/@react-aria/button/dist/useButton.cjs.js +1 -1
- package/dist/node_modules/@react-aria/button/dist/useButton.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/button/dist/useButton.es.js +13 -12
- package/dist/node_modules/@react-aria/button/dist/useButton.es.js.map +1 -1
- package/dist/node_modules/@react-aria/dialog/dist/useDialog.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/dialog/dist/useDialog.es.js.map +1 -1
- package/dist/node_modules/@react-aria/focus/dist/FocusScope.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/focus/dist/FocusScope.es.js +3 -3
- package/dist/node_modules/@react-aria/focus/dist/FocusScope.es.js.map +1 -1
- package/dist/node_modules/@react-aria/form/dist/useFormValidation.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/form/dist/useFormValidation.es.js.map +1 -1
- package/dist/node_modules/@react-aria/i18n/dist/context.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/i18n/dist/context.es.js.map +1 -1
- package/dist/node_modules/@react-aria/i18n/dist/useDefaultLocale.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/i18n/dist/useDefaultLocale.es.js.map +1 -1
- package/dist/node_modules/@react-aria/i18n/dist/utils.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/i18n/dist/utils.es.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/context.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/context.es.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/createEventHandler.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/createEventHandler.es.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/focusSafely.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/focusSafely.es.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/textSelection.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/textSelection.es.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/useFocus.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/useFocus.es.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/useFocusVisible.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/useFocusVisible.es.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/useFocusWithin.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/useFocusWithin.es.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/useFocusable.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/useFocusable.es.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/useInteractOutside.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/useInteractOutside.es.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/useKeyboard.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/useKeyboard.es.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/usePress.cjs.js +2 -2
- package/dist/node_modules/@react-aria/interactions/dist/usePress.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/usePress.es.js +23 -23
- package/dist/node_modules/@react-aria/interactions/dist/usePress.es.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/utils.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/interactions/dist/utils.es.js.map +1 -1
- package/dist/node_modules/@react-aria/label/dist/useField.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/label/dist/useField.es.js.map +1 -1
- package/dist/node_modules/@react-aria/label/dist/useLabel.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/label/dist/useLabel.es.js.map +1 -1
- package/dist/node_modules/@react-aria/overlays/dist/Overlay.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/overlays/dist/Overlay.es.js.map +1 -1
- package/dist/node_modules/@react-aria/overlays/dist/ariaHideOutside.cjs.js +1 -1
- package/dist/node_modules/@react-aria/overlays/dist/ariaHideOutside.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/overlays/dist/ariaHideOutside.es.js +18 -18
- package/dist/node_modules/@react-aria/overlays/dist/ariaHideOutside.es.js.map +1 -1
- package/dist/node_modules/@react-aria/overlays/dist/useModalOverlay.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/overlays/dist/useModalOverlay.es.js.map +1 -1
- package/dist/node_modules/@react-aria/overlays/dist/useOverlay.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/overlays/dist/useOverlay.es.js.map +1 -1
- package/dist/node_modules/@react-aria/overlays/dist/usePreventScroll.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/overlays/dist/usePreventScroll.es.js.map +1 -1
- package/dist/node_modules/@react-aria/radio/dist/useRadio.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/radio/dist/useRadio.es.js.map +1 -1
- package/dist/node_modules/@react-aria/radio/dist/useRadioGroup.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/radio/dist/useRadioGroup.es.js.map +1 -1
- package/dist/node_modules/@react-aria/ssr/dist/SSRProvider.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/ssr/dist/SSRProvider.es.js.map +1 -1
- package/dist/node_modules/@react-aria/switch/dist/useSwitch.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/switch/dist/useSwitch.es.js.map +1 -1
- package/dist/node_modules/@react-aria/toggle/dist/useToggle.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/toggle/dist/useToggle.es.js.map +1 -1
- package/dist/node_modules/@react-aria/visually-hidden/dist/VisuallyHidden.cjs.js.map +1 -1
- package/dist/node_modules/@react-aria/visually-hidden/dist/VisuallyHidden.es.js.map +1 -1
- package/dist/node_modules/@react-stately/form/dist/useFormValidationState.cjs.js.map +1 -1
- package/dist/node_modules/@react-stately/form/dist/useFormValidationState.es.js +3 -3
- package/dist/node_modules/@react-stately/form/dist/useFormValidationState.es.js.map +1 -1
- package/dist/node_modules/@react-stately/overlays/dist/useOverlayTriggerState.cjs.js.map +1 -1
- package/dist/node_modules/@react-stately/overlays/dist/useOverlayTriggerState.es.js.map +1 -1
- package/dist/node_modules/@react-stately/radio/dist/useRadioGroupState.cjs.js.map +1 -1
- package/dist/node_modules/@react-stately/radio/dist/useRadioGroupState.es.js.map +1 -1
- package/dist/node_modules/@react-stately/toggle/dist/useToggleState.cjs.js.map +1 -1
- package/dist/node_modules/@react-stately/toggle/dist/useToggleState.es.js.map +1 -1
- package/dist/node_modules/@react-stately/utils/dist/useControlledState.cjs.js.map +1 -1
- package/dist/node_modules/@react-stately/utils/dist/useControlledState.es.js.map +1 -1
- package/dist/node_modules/@swc/helpers/esm/_check_private_redeclaration.cjs.js +1 -1
- package/dist/node_modules/@swc/helpers/esm/_check_private_redeclaration.cjs.js.map +1 -1
- package/dist/node_modules/@swc/helpers/esm/_check_private_redeclaration.es.js +1 -2
- package/dist/node_modules/@swc/helpers/esm/_check_private_redeclaration.es.js.map +1 -1
- package/dist/node_modules/@swc/helpers/esm/_class_apply_descriptor_get.cjs.js +1 -1
- package/dist/node_modules/@swc/helpers/esm/_class_apply_descriptor_get.cjs.js.map +1 -1
- package/dist/node_modules/@swc/helpers/esm/_class_apply_descriptor_get.es.js +1 -2
- package/dist/node_modules/@swc/helpers/esm/_class_apply_descriptor_get.es.js.map +1 -1
- package/dist/node_modules/@swc/helpers/esm/_class_apply_descriptor_set.cjs.js +1 -1
- package/dist/node_modules/@swc/helpers/esm/_class_apply_descriptor_set.cjs.js.map +1 -1
- package/dist/node_modules/@swc/helpers/esm/_class_apply_descriptor_set.es.js +1 -2
- package/dist/node_modules/@swc/helpers/esm/_class_apply_descriptor_set.es.js.map +1 -1
- package/dist/node_modules/@swc/helpers/esm/_class_extract_field_descriptor.cjs.js +1 -1
- package/dist/node_modules/@swc/helpers/esm/_class_extract_field_descriptor.cjs.js.map +1 -1
- package/dist/node_modules/@swc/helpers/esm/_class_extract_field_descriptor.es.js +1 -2
- package/dist/node_modules/@swc/helpers/esm/_class_extract_field_descriptor.es.js.map +1 -1
- package/dist/node_modules/@swc/helpers/esm/_class_private_field_get.cjs.js +1 -1
- package/dist/node_modules/@swc/helpers/esm/_class_private_field_get.cjs.js.map +1 -1
- package/dist/node_modules/@swc/helpers/esm/_class_private_field_get.es.js +6 -7
- package/dist/node_modules/@swc/helpers/esm/_class_private_field_get.es.js.map +1 -1
- package/dist/node_modules/@swc/helpers/esm/_class_private_field_init.cjs.js +1 -1
- package/dist/node_modules/@swc/helpers/esm/_class_private_field_init.cjs.js.map +1 -1
- package/dist/node_modules/@swc/helpers/esm/_class_private_field_init.es.js +3 -4
- package/dist/node_modules/@swc/helpers/esm/_class_private_field_init.es.js.map +1 -1
- package/dist/node_modules/@swc/helpers/esm/_class_private_field_set.cjs.js +1 -1
- package/dist/node_modules/@swc/helpers/esm/_class_private_field_set.cjs.js.map +1 -1
- package/dist/node_modules/@swc/helpers/esm/_class_private_field_set.es.js +6 -7
- package/dist/node_modules/@swc/helpers/esm/_class_private_field_set.es.js.map +1 -1
- package/dist/node_modules/color2k/dist/index.exports.import.es.cjs.js.map +1 -1
- package/dist/node_modules/color2k/dist/index.exports.import.es.es.js.map +1 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.development.cjs.js +7 -7
- package/dist/node_modules/react/cjs/react-jsx-runtime.development.cjs.js.map +1 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.development.es.js +167 -174
- package/dist/node_modules/react/cjs/react-jsx-runtime.development.es.js.map +1 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.production.min.cjs.js +1 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.production.min.cjs.js.map +1 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.production.min.es.js +3 -3
- package/dist/node_modules/react/cjs/react-jsx-runtime.production.min.es.js.map +1 -1
- package/dist/node_modules/react/jsx-runtime.cjs.js.map +1 -1
- package/dist/node_modules/react/jsx-runtime.es.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/utils/color2k.cjs.js.map +1 -1
- package/dist/utils/color2k.es.js.map +1 -1
- package/dist/utils/copy.cjs.js.map +1 -1
- package/dist/utils/copy.es.js.map +1 -1
- package/dist/utils/image.cjs.js.map +1 -1
- package/dist/utils/image.es.js.map +1 -1
- package/dist/utils/navigation.cjs.js.map +1 -1
- package/dist/utils/navigation.es.js.map +1 -1
- package/dist/utils/palette.cjs.js.map +1 -1
- package/dist/utils/palette.es.js +1 -1
- package/dist/utils/palette.es.js.map +1 -1
- package/dist/utils/string.cjs.js.map +1 -1
- package/dist/utils/string.es.js.map +1 -1
- package/package.json +140 -140
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTable.es.js","sources":["../../../src/components/DataTable/DataTable.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport { AriaAttributes, ReactNode, useMemo } from \"react\";\r\nimport { Table } from \"../Table/Table\";\r\nimport { Elevation } from \"../Elevation/Elevation\";\r\nimport { Tombstone } from \"../Tombstone/Tombstone\";\r\nimport { Icon } from \"../Icon/Icon\";\r\nimport \"./DataTable.css\";\r\n\r\nexport type SortDirection = \"ASC\" | \"DESC\";\r\n\r\ntype SortingConfig<T> =\r\n | {\r\n /** When sorting is enabled, all these props must be provided together. */\r\n sortableColumns: string[];\r\n sortedBy: string;\r\n sortDirection: SortDirection;\r\n onSort: (columnId: string, direction: SortDirection) => void;\r\n }\r\n | {\r\n /** When no sorting is needed, none of these props should be provided */\r\n sortableColumns?: never;\r\n sortedBy?: never;\r\n sortDirection?: never;\r\n onSort?: never;\r\n };\r\n\r\nexport interface DataTableColumn<T> {\r\n /** id for the column */\r\n id: string;\r\n /** Header text or component */\r\n header: ReactNode;\r\n /** Function to render cell content from row data */\r\n cell: (row: T) => ReactNode;\r\n /** Whether this column should be hidden */\r\n hidden?: boolean;\r\n}\r\n\r\ninterface BaseDataTableProps<T = any> {\r\n /** Array of column definitions\r\n * - {@link DataTableColumn}\r\n */\r\n columns: DataTableColumn<T>[];\r\n /** Array of data objects to display. Can be empty array for loading/empty states */\r\n data?: T[] | null;\r\n /** Loading state */\r\n loading?: boolean;\r\n /** Tombstone component to use when loading */\r\n tombstoneComponent?: ReactNode;\r\n /** Error state */\r\n error?: boolean | string;\r\n /** Table name/caption for accessibility. This provides essential context for screen readers. */\r\n name: string;\r\n /** Callback when a row is clicked */\r\n onRowClick?: (row: T) => void;\r\n /** Custom empty state message */\r\n emptyMessage?: string;\r\n /** Custom error message */\r\n errorMessage?: string;\r\n /** Number of skeleton rows to show in loading state */\r\n loadingRows?: number;\r\n /** Test ID for testing purposes */\r\n \"data-testid\"?: string;\r\n}\r\n\r\nexport type DataTableProps<T = any> = BaseDataTableProps<T> & SortingConfig<T>;\r\n\r\n/**\r\n * DataTable is a declarative wrapper around the base Table component that provides:\r\n *\r\n * API:\r\n * - {@link DataTableProps}\r\n * - {@link SortingConfig}\r\n */\r\nexport function DataTable<T = any>(props: DataTableProps<T>) {\r\n const {\r\n columns,\r\n data = [],\r\n loading = false,\r\n tombstoneComponent,\r\n error = false,\r\n name,\r\n onRowClick,\r\n emptyMessage = \"Data Unavailable\",\r\n errorMessage,\r\n loadingRows = 5,\r\n \"data-testid\": testId,\r\n } = props;\r\n\r\n const sortableColumns =\r\n \"sortableColumns\" in props ? props.sortableColumns : [];\r\n const sortedBy = \"sortedBy\" in props ? props.sortedBy : undefined;\r\n const sortDirection =\r\n \"sortDirection\" in props ? props.sortDirection : undefined;\r\n const onSort = \"onSort\" in props ? props.onSort : undefined;\r\n\r\n const visibleColumns = useMemo(\r\n () => columns.filter((col) => !col.hidden),\r\n [columns]\r\n );\r\n\r\n const handleSortClick = (column: DataTableColumn<T>) => {\r\n if (!onSort) return;\r\n\r\n const isCurrentlySorted = sortedBy === column.id;\r\n const newDirection =\r\n isCurrentlySorted && sortDirection === \"ASC\" ? \"DESC\" : \"ASC\";\r\n\r\n onSort(column.id, newDirection);\r\n };\r\n\r\n const getSortState = (columnId: string): AriaAttributes[\"aria-sort\"] => {\r\n if (sortedBy !== columnId) return \"none\";\r\n return sortDirection === \"ASC\" ? \"ascending\" : \"descending\";\r\n };\r\n\r\n if (error) {\r\n const message =\r\n typeof error === \"string\" ? error : errorMessage || \"An error occurred\";\r\n return (\r\n <EmptyState\r\n columns={visibleColumns}\r\n message={message}\r\n name={name}\r\n testId={testId}\r\n isError\r\n />\r\n );\r\n }\r\n\r\n if (loading) {\r\n return (\r\n <div\r\n className=\"proton-DataTable\"\r\n data-testid={testId}\r\n aria-busy=\"true\"\r\n aria-label={`Loading ${name}...`}\r\n >\r\n <Table name={name}>\r\n <Table.Header>\r\n {visibleColumns.map((column) => (\r\n <Table.Column key={column.id} id={column.id}>\r\n {column.header}\r\n </Table.Column>\r\n ))}\r\n </Table.Header>\r\n <Table.Body>\r\n {Array.from({ length: loadingRows }).map((_, index) => (\r\n <Table.Row key={`loading-${index}`}>\r\n {visibleColumns.map((column) => (\r\n <Table.Cell key={column.id}>\r\n {tombstoneComponent || (\r\n <Tombstone\r\n height=\"1rem\"\r\n width={\r\n // cascading tombstone widths\r\n index % 3 === 0\r\n ? \"80%\"\r\n : index % 3 === 1\r\n ? \"60%\"\r\n : \"90%\"\r\n }\r\n />\r\n )}\r\n </Table.Cell>\r\n ))}\r\n </Table.Row>\r\n ))}\r\n </Table.Body>\r\n </Table>\r\n </div>\r\n );\r\n }\r\n\r\n if (!data || data.length === 0) {\r\n return (\r\n <EmptyState\r\n columns={visibleColumns}\r\n message={emptyMessage}\r\n name={name}\r\n testId={testId}\r\n />\r\n );\r\n }\r\n\r\n return (\r\n <div className=\"proton-DataTable\" data-testid={testId}>\r\n <Table name={name}>\r\n <Table.Header>\r\n {visibleColumns.map((column) => {\r\n const isSortable = sortableColumns.includes(column.id);\r\n const sortState = getSortState(column.id);\r\n\r\n return (\r\n <Table.Column\r\n key={column.id}\r\n id={column.id}\r\n {...(isSortable && { \"aria-sort\": sortState })}\r\n >\r\n <span className=\"proton-DataTable__header-content\">\r\n {column.header}\r\n {isSortable && (\r\n <button\r\n className=\"proton-DataTable__sort-button\"\r\n onClick={() => handleSortClick(column)}\r\n aria-label={`Sort by ${column.header}: ${sortState}`}\r\n type=\"button\"\r\n >\r\n <Icon\r\n id={\"chevron-up\"}\r\n size={12}\r\n color={\r\n sortState === \"ascending\"\r\n ? \"var(--proton-color__primary)\"\r\n : \"currentColor\"\r\n }\r\n />\r\n </button>\r\n )}\r\n </span>\r\n </Table.Column>\r\n );\r\n })}\r\n </Table.Header>\r\n <Table.Body>\r\n {data.map((row, index) => {\r\n // Generate a key from the row data or use index as fallback\r\n const rowKey = ((row as any)?.id || (row as any)?.key) ?? index;\r\n\r\n return (\r\n <Table.Row\r\n key={rowKey}\r\n onClick={onRowClick ? () => onRowClick(row) : undefined}\r\n >\r\n {visibleColumns.map((column) => (\r\n <Table.Cell key={column.id}>{column.cell(row)}</Table.Cell>\r\n ))}\r\n </Table.Row>\r\n );\r\n })}\r\n </Table.Body>\r\n </Table>\r\n </div>\r\n );\r\n}\r\n\r\nconst EmptyState = ({\r\n columns,\r\n message,\r\n name,\r\n testId,\r\n isError = false,\r\n}: Partial<DataTableProps> & {\r\n testId?: string;\r\n message: string;\r\n isError?: boolean;\r\n}) => {\r\n return (\r\n <div className=\"proton-DataTable\" data-testid={testId}>\r\n <Table name={name}>\r\n <Table.Header>\r\n {columns?.map((column) => (\r\n <Table.Column key={column.id} id={column.id}>\r\n {column.header}\r\n </Table.Column>\r\n ))}\r\n </Table.Header>\r\n <Table.Body>\r\n <Table.Row>\r\n <Table.Cell colSpan={columns?.length || 1}>\r\n <div\r\n className=\"proton-DataTable__message-cell\"\r\n role={isError ? \"alert\" : \"status\"}\r\n aria-live=\"polite\"\r\n >\r\n <Elevation>\r\n <div className=\"proton-DataTable__empty-cell\">{message}</div>\r\n </Elevation>\r\n </div>\r\n </Table.Cell>\r\n </Table.Row>\r\n </Table.Body>\r\n </Table>\r\n </div>\r\n );\r\n};\r\n"],"names":["DataTable","props","columns","data","loading","tombstoneComponent","error","name","onRowClick","emptyMessage","errorMessage","loadingRows","testId","sortableColumns","sortedBy","sortDirection","onSort","visibleColumns","useMemo","col","handleSortClick","column","newDirection","getSortState","columnId","message","jsx","EmptyState","jsxs","Table","_","index","Tombstone","isSortable","sortState","Icon","row","rowKey","isError","Elevation"],"mappings":";;;;;;;AA0EO,SAASA,EAAmBC,GAA0B;AACrD,QAAA;AAAA,IACJ,SAAAC;AAAA,IACA,MAAAC,IAAO,CAAC;AAAA,IACR,SAAAC,IAAU;AAAA,IACV,oBAAAC;AAAA,IACA,OAAAC,IAAQ;AAAA,IACR,MAAAC;AAAA,IACA,YAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,IACf,cAAAC;AAAA,IACA,aAAAC,IAAc;AAAA,IACd,eAAeC;AAAA,EACb,IAAAX,GAEEY,IACJ,qBAAqBZ,IAAQA,EAAM,kBAAkB,CAAA,GACjDa,IAAW,cAAcb,IAAQA,EAAM,WAAW,QAClDc,IACJ,mBAAmBd,IAAQA,EAAM,gBAAgB,QAC7Ce,IAAS,YAAYf,IAAQA,EAAM,SAAS,QAE5CgB,IAAiBC;AAAA,IACrB,MAAMhB,EAAQ,OAAO,CAACiB,MAAQ,CAACA,EAAI,MAAM;AAAA,IACzC,CAACjB,CAAO;AAAA,EAAA,GAGJkB,IAAkB,CAACC,MAA+B;AACtD,QAAI,CAACL,EAAQ;AAGb,UAAMM,IADoBR,MAAaO,EAAO,MAEvBN,MAAkB,QAAQ,SAAS;AAEnD,IAAAC,EAAAK,EAAO,IAAIC,CAAY;AAAA,EAAA,GAG1B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;AAAA,EACF,CAAA,EACF,CAAA;"}
|
|
1
|
+
{"version":3,"file":"DataTable.es.js","sources":["../../../src/components/DataTable/DataTable.tsx"],"sourcesContent":["\"use client\";\n\nimport { AriaAttributes, ReactNode, useMemo } from \"react\";\nimport { Table } from \"../Table/Table\";\nimport { Elevation } from \"../Elevation/Elevation\";\nimport { Tombstone } from \"../Tombstone/Tombstone\";\nimport { Icon } from \"../Icon/Icon\";\nimport \"./DataTable.css\";\n\nexport type SortDirection = \"ASC\" | \"DESC\";\n\ntype SortingConfig<T> =\n | {\n /** When sorting is enabled, all these props must be provided together. */\n sortableColumns: string[];\n sortedBy: string;\n sortDirection: SortDirection;\n onSort: (columnId: string, direction: SortDirection) => void;\n }\n | {\n /** When no sorting is needed, none of these props should be provided */\n sortableColumns?: never;\n sortedBy?: never;\n sortDirection?: never;\n onSort?: never;\n };\n\nexport interface DataTableColumn<T> {\n /** id for the column */\n id: string;\n /** Header text or component */\n header: ReactNode;\n /** Function to render cell content from row data */\n cell: (row: T) => ReactNode;\n /** Whether this column should be hidden */\n hidden?: boolean;\n}\n\ninterface BaseDataTableProps<T = any> {\n /** Array of column definitions\n * - {@link DataTableColumn}\n */\n columns: DataTableColumn<T>[];\n /** Array of data objects to display. Can be empty array for loading/empty states */\n data?: T[] | null;\n /** Loading state */\n loading?: boolean;\n /** Tombstone component to use when loading */\n tombstoneComponent?: ReactNode;\n /** Error state */\n error?: boolean | string;\n /** Table name/caption for accessibility. This provides essential context for screen readers. */\n name: string;\n /** Callback when a row is clicked */\n onRowClick?: (row: T) => void;\n /** Custom empty state message */\n emptyMessage?: string;\n /** Custom error message */\n errorMessage?: string;\n /** Number of skeleton rows to show in loading state */\n loadingRows?: number;\n /** Test ID for testing purposes */\n \"data-testid\"?: string;\n}\n\nexport type DataTableProps<T = any> = BaseDataTableProps<T> & SortingConfig<T>;\n\n/**\n * DataTable is a declarative wrapper around the base Table component that provides:\n *\n * API:\n * - {@link DataTableProps}\n * - {@link SortingConfig}\n */\nexport function DataTable<T = any>(props: DataTableProps<T>) {\n const {\n columns,\n data = [],\n loading = false,\n tombstoneComponent,\n error = false,\n name,\n onRowClick,\n emptyMessage = \"Data Unavailable\",\n errorMessage,\n loadingRows = 5,\n \"data-testid\": testId,\n } = props;\n\n const sortableColumns =\n \"sortableColumns\" in props ? props.sortableColumns : [];\n const sortedBy = \"sortedBy\" in props ? props.sortedBy : undefined;\n const sortDirection =\n \"sortDirection\" in props ? props.sortDirection : undefined;\n const onSort = \"onSort\" in props ? props.onSort : undefined;\n\n const visibleColumns = useMemo(\n () => columns.filter((col) => !col.hidden),\n [columns]\n );\n\n const handleSortClick = (column: DataTableColumn<T>) => {\n if (!onSort) return;\n\n const isCurrentlySorted = sortedBy === column.id;\n const newDirection =\n isCurrentlySorted && sortDirection === \"ASC\" ? \"DESC\" : \"ASC\";\n\n onSort(column.id, newDirection);\n };\n\n const getSortState = (columnId: string): AriaAttributes[\"aria-sort\"] => {\n if (sortedBy !== columnId) return \"none\";\n return sortDirection === \"ASC\" ? \"ascending\" : \"descending\";\n };\n\n if (error) {\n const message =\n typeof error === \"string\" ? error : errorMessage || \"An error occurred\";\n return (\n <EmptyState\n columns={visibleColumns}\n message={message}\n name={name}\n testId={testId}\n isError\n />\n );\n }\n\n if (loading) {\n return (\n <div\n className=\"proton-DataTable\"\n data-testid={testId}\n aria-busy=\"true\"\n aria-label={`Loading ${name}...`}\n >\n <Table name={name}>\n <Table.Header>\n {visibleColumns.map((column) => (\n <Table.Column key={column.id} id={column.id}>\n {column.header}\n </Table.Column>\n ))}\n </Table.Header>\n <Table.Body>\n {Array.from({ length: loadingRows }).map((_, index) => (\n <Table.Row key={`loading-${index}`}>\n {visibleColumns.map((column) => (\n <Table.Cell key={column.id}>\n {tombstoneComponent || (\n <Tombstone\n height=\"1rem\"\n width={\n // cascading tombstone widths\n index % 3 === 0\n ? \"80%\"\n : index % 3 === 1\n ? \"60%\"\n : \"90%\"\n }\n />\n )}\n </Table.Cell>\n ))}\n </Table.Row>\n ))}\n </Table.Body>\n </Table>\n </div>\n );\n }\n\n if (!data || data.length === 0) {\n return (\n <EmptyState\n columns={visibleColumns}\n message={emptyMessage}\n name={name}\n testId={testId}\n />\n );\n }\n\n return (\n <div className=\"proton-DataTable\" data-testid={testId}>\n <Table name={name}>\n <Table.Header>\n {visibleColumns.map((column) => {\n const isSortable = sortableColumns.includes(column.id);\n const sortState = getSortState(column.id);\n\n return (\n <Table.Column\n key={column.id}\n id={column.id}\n {...(isSortable && { \"aria-sort\": sortState })}\n >\n <span className=\"proton-DataTable__header-content\">\n {column.header}\n {isSortable && (\n <button\n className=\"proton-DataTable__sort-button\"\n onClick={() => handleSortClick(column)}\n aria-label={`Sort by ${column.header}: ${sortState}`}\n type=\"button\"\n >\n <Icon\n id={\"chevron-up\"}\n size={12}\n color={\n sortState === \"ascending\"\n ? \"var(--proton-color__primary)\"\n : \"currentColor\"\n }\n />\n </button>\n )}\n </span>\n </Table.Column>\n );\n })}\n </Table.Header>\n <Table.Body>\n {data.map((row, index) => {\n // Generate a key from the row data or use index as fallback\n const rowKey = ((row as any)?.id || (row as any)?.key) ?? index;\n\n return (\n <Table.Row\n key={rowKey}\n onClick={onRowClick ? () => onRowClick(row) : undefined}\n >\n {visibleColumns.map((column) => (\n <Table.Cell key={column.id}>{column.cell(row)}</Table.Cell>\n ))}\n </Table.Row>\n );\n })}\n </Table.Body>\n </Table>\n </div>\n );\n}\n\nconst EmptyState = ({\n columns,\n message,\n name,\n testId,\n isError = false,\n}: Partial<DataTableProps> & {\n testId?: string;\n message: string;\n isError?: boolean;\n}) => {\n return (\n <div className=\"proton-DataTable\" data-testid={testId}>\n <Table name={name}>\n <Table.Header>\n {columns?.map((column) => (\n <Table.Column key={column.id} id={column.id}>\n {column.header}\n </Table.Column>\n ))}\n </Table.Header>\n <Table.Body>\n <Table.Row>\n <Table.Cell colSpan={columns?.length || 1}>\n <div\n className=\"proton-DataTable__message-cell\"\n role={isError ? \"alert\" : \"status\"}\n aria-live=\"polite\"\n >\n <Elevation>\n <div className=\"proton-DataTable__empty-cell\">{message}</div>\n </Elevation>\n </div>\n </Table.Cell>\n </Table.Row>\n </Table.Body>\n </Table>\n </div>\n );\n};\n"],"names":["DataTable","props","columns","data","loading","tombstoneComponent","error","name","onRowClick","emptyMessage","errorMessage","loadingRows","testId","sortableColumns","sortedBy","sortDirection","onSort","visibleColumns","useMemo","col","handleSortClick","column","newDirection","getSortState","columnId","message","jsx","EmptyState","jsxs","Table","_","index","Tombstone","isSortable","sortState","Icon","row","rowKey","isError","Elevation"],"mappings":";;;;;;;AA0EO,SAASA,EAAmBC,GAA0B;AAC3D,QAAM;AAAA,IACJ,SAAAC;AAAA,IACA,MAAAC,IAAO,CAAA;AAAA,IACP,SAAAC,IAAU;AAAA,IACV,oBAAAC;AAAA,IACA,OAAAC,IAAQ;AAAA,IACR,MAAAC;AAAA,IACA,YAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,IACf,cAAAC;AAAA,IACA,aAAAC,IAAc;AAAA,IACd,eAAeC;AAAA,EAAA,IACbX,GAEEY,IACJ,qBAAqBZ,IAAQA,EAAM,kBAAkB,CAAA,GACjDa,IAAW,cAAcb,IAAQA,EAAM,WAAW,QAClDc,IACJ,mBAAmBd,IAAQA,EAAM,gBAAgB,QAC7Ce,IAAS,YAAYf,IAAQA,EAAM,SAAS,QAE5CgB,IAAiBC;AAAA,IACrB,MAAMhB,EAAQ,OAAO,CAACiB,MAAQ,CAACA,EAAI,MAAM;AAAA,IACzC,CAACjB,CAAO;AAAA,EAAA,GAGJkB,IAAkB,CAACC,MAA+B;AACtD,QAAI,CAACL,EAAQ;AAGb,UAAMM,IADoBR,MAAaO,EAAO,MAEvBN,MAAkB,QAAQ,SAAS;AAE1D,IAAAC,EAAOK,EAAO,IAAIC,CAAY;AAAA,EAChC,GAEMC,IAAe,CAACC,MAChBV,MAAaU,IAAiB,SAC3BT,MAAkB,QAAQ,cAAc;AAGjD,MAAIT,GAAO;AACT,UA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 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.cjs.js","sources":["../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"Dialog.cjs.js","sources":["../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["\"use client\";\n\nimport { useRef } from \"react\";\nimport { type AriaDialogProps, useDialog } from \"@react-aria/dialog\";\n\nimport \"./Dialog.css\";\n\ninterface DialogProps extends AriaDialogProps {\n title?: React.ReactNode;\n children: React.ReactNode;\n}\n\n/**\n * Intended use in overlay containers such as modals or popovers.\n *\n * API:\n * - {@link DialogProps}\n * - extends {@link AriaDialogProps}\n */\nexport function Dialog({ title, children, ...props }: DialogProps) {\n let ref = useRef(null);\n let { dialogProps, titleProps } = useDialog(props, ref);\n\n return (\n <div {...dialogProps} ref={ref} className=\"proton-Dialog\">\n {title && (\n <h3 {...titleProps} className=\"proton-Dialog__header\">\n {title}\n </h3>\n )}\n {children}\n </div>\n );\n}\n"],"names":["Dialog","title","children","props","ref","useRef","dialogProps","titleProps","useDialog"],"mappings":"0QAmBO,SAASA,EAAO,CAAE,MAAAC,EAAO,SAAAC,EAAU,GAAGC,GAAsB,CACjE,IAAIC,EAAMC,EAAAA,OAAO,IAAI,EACjB,CAAE,YAAAC,EAAa,WAAAC,CAAA,EAAeC,EAAAA,UAAUL,EAAOC,CAAG,EAEtD,gCACG,MAAA,CAAK,GAAGE,EAAa,IAAAF,EAAU,UAAU,gBACvC,SAAA,CAAAH,2BACE,KAAA,CAAI,GAAGM,EAAY,UAAU,wBAC3B,SAAAN,EACH,EAEDC,CAAA,EACH,CAEJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.es.js","sources":["../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"Dialog.es.js","sources":["../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["\"use client\";\n\nimport { useRef } from \"react\";\nimport { type AriaDialogProps, useDialog } from \"@react-aria/dialog\";\n\nimport \"./Dialog.css\";\n\ninterface DialogProps extends AriaDialogProps {\n title?: React.ReactNode;\n children: React.ReactNode;\n}\n\n/**\n * Intended use in overlay containers such as modals or popovers.\n *\n * API:\n * - {@link DialogProps}\n * - extends {@link AriaDialogProps}\n */\nexport function Dialog({ title, children, ...props }: DialogProps) {\n let ref = useRef(null);\n let { dialogProps, titleProps } = useDialog(props, ref);\n\n return (\n <div {...dialogProps} ref={ref} className=\"proton-Dialog\">\n {title && (\n <h3 {...titleProps} className=\"proton-Dialog__header\">\n {title}\n </h3>\n )}\n {children}\n </div>\n );\n}\n"],"names":["Dialog","title","children","props","ref","useRef","dialogProps","titleProps","useDialog"],"mappings":";;;;AAmBO,SAASA,EAAO,EAAE,OAAAC,GAAO,UAAAC,GAAU,GAAGC,KAAsB;AACjE,MAAIC,IAAMC,EAAO,IAAI,GACjB,EAAE,aAAAC,GAAa,YAAAC,EAAA,IAAeC,EAAUL,GAAOC,CAAG;AAEtD,gCACG,OAAA,EAAK,GAAGE,GAAa,KAAAF,GAAU,WAAU,iBACvC,UAAA;AAAA,IAAAH,2BACE,MAAA,EAAI,GAAGM,GAAY,WAAU,yBAC3B,UAAAN,GACH;AAAA,IAEDC;AAAA,EAAA,GACH;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Elevation.cjs.js","sources":["../../../src/components/Elevation/Elevation.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"Elevation.cjs.js","sources":["../../../src/components/Elevation/Elevation.tsx"],"sourcesContent":["\"use client\";\n\nimport { ReactNode } from \"react\";\nimport { transparentize, mix } from \"color2k\";\nimport { useTheme } from \"../ThemeProvider\";\nimport \"./Elevation.css\";\n\nexport interface ElevationProps {\n /**\n * The content to be displayed within the elevation.\n */\n children?: ReactNode;\n /**\n * The data-testid attribute for testing purposes.\n */\n \"data-testid\"?: string;\n /**\n * Whether the elevation should have a background gradient.\n * @important only works in custom dark mode\n * @default false\n */\n hasPrimaryGradient?: boolean;\n}\n\n/**\n * Elevation component creates a visual elevation effect using the theme-aware background color.\n *\n * This component is designed to be used as a visual layer that sits on top of other content\n * to create a sense of depth or hierarchy in the UI. It uses the `--proton-control__background-color-light`\n * CSS variable which is theme-aware and will adapt to light, dark themes.\n *\n * API:\n * - {@link ElevationProps}\n */\nexport const Elevation = ({\n children,\n hasPrimaryGradient = false,\n \"data-testid\": dataTestId,\n}: ElevationProps) => {\n const { hasPalette, palette, style } = useTheme();\n\n const defaultBg = style[\"--proton-control__background-color-light\"];\n let primaryDark = defaultBg;\n let secondaryDark = transparentize(defaultBg, 0.01);\n\n if (hasPalette) {\n primaryDark = transparentize(defaultBg, 0.1);\n secondaryDark = transparentize(defaultBg, 0.12);\n if (hasPrimaryGradient) {\n const basePrimary = transparentize(palette.PRIMARY.MEDIUM_LIGHT, 0.88);\n const baseSecondary = transparentize(palette.PRIMARY.LIGHT, 0.84);\n primaryDark = mix(primaryDark, basePrimary, 0.15);\n secondaryDark = mix(secondaryDark, baseSecondary, 0.15);\n }\n }\n\n return (\n <div\n className=\"proton-Elevation\"\n data-testid={dataTestId}\n role=\"presentation\"\n aria-label=\"Elevated content area\"\n style={{\n background: `linear-gradient(to top left, ${primaryDark}, ${secondaryDark})`,\n }}\n >\n {children}\n </div>\n );\n};\n"],"names":["Elevation","children","hasPrimaryGradient","dataTestId","hasPalette","palette","style","useTheme","defaultBg","primaryDark","secondaryDark","transparentize","basePrimary","baseSecondary","mix","jsx"],"mappings":"kSAkCO,MAAMA,EAAY,CAAC,CACxB,SAAAC,EACA,mBAAAC,EAAqB,GACrB,cAAeC,CACjB,IAAsB,CACpB,KAAM,CAAE,WAAAC,EAAY,QAAAC,EAAS,MAAAC,CAAA,EAAUC,EAAAA,SAAA,EAEjCC,EAAYF,EAAM,0CAA0C,EAClE,IAAIG,EAAcD,EACdE,EAAgBC,EAAAA,eAAeH,EAAW,GAAI,EAElD,GAAIJ,IACFK,EAAcE,EAAAA,eAAeH,EAAW,EAAG,EAC3CE,EAAgBC,EAAAA,eAAeH,EAAW,GAAI,EAC1CN,GAAoB,CACtB,MAAMU,EAAcD,EAAAA,eAAeN,EAAQ,QAAQ,aAAc,GAAI,EAC/DQ,EAAgBF,EAAAA,eAAeN,EAAQ,QAAQ,MAAO,GAAI,EAChEI,EAAcK,EAAAA,IAAIL,EAAaG,EAAa,GAAI,EAChDF,EAAgBI,EAAAA,IAAIJ,EAAeG,EAAe,GAAI,CACxD,CAGF,OACEE,EAAAA,kBAAAA,IAAC,MAAA,CACC,UAAU,mBACV,cAAaZ,EACb,KAAK,eACL,aAAW,wBACX,MAAO,CACL,WAAY,gCAAgCM,CAAW,KAAKC,CAAa,GAAA,EAG1E,SAAAT,CAAA,CAAA,CAGP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Elevation.es.js","sources":["../../../src/components/Elevation/Elevation.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"Elevation.es.js","sources":["../../../src/components/Elevation/Elevation.tsx"],"sourcesContent":["\"use client\";\n\nimport { ReactNode } from \"react\";\nimport { transparentize, mix } from \"color2k\";\nimport { useTheme } from \"../ThemeProvider\";\nimport \"./Elevation.css\";\n\nexport interface ElevationProps {\n /**\n * The content to be displayed within the elevation.\n */\n children?: ReactNode;\n /**\n * The data-testid attribute for testing purposes.\n */\n \"data-testid\"?: string;\n /**\n * Whether the elevation should have a background gradient.\n * @important only works in custom dark mode\n * @default false\n */\n hasPrimaryGradient?: boolean;\n}\n\n/**\n * Elevation component creates a visual elevation effect using the theme-aware background color.\n *\n * This component is designed to be used as a visual layer that sits on top of other content\n * to create a sense of depth or hierarchy in the UI. It uses the `--proton-control__background-color-light`\n * CSS variable which is theme-aware and will adapt to light, dark themes.\n *\n * API:\n * - {@link ElevationProps}\n */\nexport const Elevation = ({\n children,\n hasPrimaryGradient = false,\n \"data-testid\": dataTestId,\n}: ElevationProps) => {\n const { hasPalette, palette, style } = useTheme();\n\n const defaultBg = style[\"--proton-control__background-color-light\"];\n let primaryDark = defaultBg;\n let secondaryDark = transparentize(defaultBg, 0.01);\n\n if (hasPalette) {\n primaryDark = transparentize(defaultBg, 0.1);\n secondaryDark = transparentize(defaultBg, 0.12);\n if (hasPrimaryGradient) {\n const basePrimary = transparentize(palette.PRIMARY.MEDIUM_LIGHT, 0.88);\n const baseSecondary = transparentize(palette.PRIMARY.LIGHT, 0.84);\n primaryDark = mix(primaryDark, basePrimary, 0.15);\n secondaryDark = mix(secondaryDark, baseSecondary, 0.15);\n }\n }\n\n return (\n <div\n className=\"proton-Elevation\"\n data-testid={dataTestId}\n role=\"presentation\"\n aria-label=\"Elevated content area\"\n style={{\n background: `linear-gradient(to top left, ${primaryDark}, ${secondaryDark})`,\n }}\n >\n {children}\n </div>\n );\n};\n"],"names":["Elevation","children","hasPrimaryGradient","dataTestId","hasPalette","palette","style","useTheme","defaultBg","primaryDark","secondaryDark","transparentize","basePrimary","baseSecondary","mix","jsx"],"mappings":";;;;AAkCO,MAAMA,IAAY,CAAC;AAAA,EACxB,UAAAC;AAAA,EACA,oBAAAC,IAAqB;AAAA,EACrB,eAAeC;AACjB,MAAsB;AACpB,QAAM,EAAE,YAAAC,GAAY,SAAAC,GAAS,OAAAC,EAAA,IAAUC,EAAA,GAEjCC,IAAYF,EAAM,0CAA0C;AAClE,MAAIG,IAAcD,GACdE,IAAgBC,EAAeH,GAAW,IAAI;AAElD,MAAIJ,MACFK,IAAcE,EAAeH,GAAW,GAAG,GAC3CE,IAAgBC,EAAeH,GAAW,IAAI,GAC1CN,IAAoB;AACtB,UAAMU,IAAcD,EAAeN,EAAQ,QAAQ,cAAc,IAAI,GAC/DQ,IAAgBF,EAAeN,EAAQ,QAAQ,OAAO,IAAI;AAChE,IAAAI,IAAcK,EAAIL,GAAaG,GAAa,IAAI,GAChDF,IAAgBI,EAAIJ,GAAeG,GAAe,IAAI;AAAA,EACxD;AAGF,SACEE,gBAAAA,EAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV,eAAaZ;AAAA,MACb,MAAK;AAAA,MACL,cAAW;AAAA,MACX,OAAO;AAAA,QACL,YAAY,gCAAgCM,CAAW,KAAKC,CAAa;AAAA,MAAA;AAAA,MAG1E,UAAAT;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.cjs.js","sources":["../../../src/components/Icon/Icon.tsx"],"sourcesContent":["import { SVGProps } from \"react\";\
|
|
1
|
+
{"version":3,"file":"Icon.cjs.js","sources":["../../../src/components/Icon/Icon.tsx"],"sourcesContent":["import { SVGProps } from \"react\";\nimport iconURL from \"../../../assets/svg/icons.svg\";\n\ntype IconID =\n | \"external-link\"\n | \"caret-down\"\n | \"caret-right\"\n | \"chevron-right\"\n | \"chevron-left\"\n | \"chevron-up\"\n | \"chevron-down\";\n\n/*\n *\n * 🚧 UNDER CONSTRUCTION 🚧\n *\n */\n\nexport interface IconProps {\n /**\n * The spritesheet ID defined in the Icons spritesheet.\n */\n id: IconID;\n\n /**\n * The desired width/height of the icon. Accepts any valid CSS unit.\n */\n size?: number | string;\n\n /**\n * The stroke color of the icon.\n */\n color?: string;\n}\n\n/**\n * An icon component that displays SVG icons from a sprite sheet or inline.\n *\n * API:\n * - {@link IconProps}\n */\nexport function Icon(props: IconProps) {\n let iconStyle = {\n height: props.size || undefined,\n width: props.size || undefined,\n color: props.color || undefined,\n };\n\n if (props.id === \"chevron-right\") {\n return <Chevron direction=\"right\" {...iconStyle} />;\n }\n\n if (props.id === \"chevron-left\") {\n return <Chevron direction=\"left\" {...iconStyle} />;\n }\n\n if (props.id === \"chevron-up\") {\n return <Chevron direction=\"up\" {...iconStyle} />;\n }\n\n if (props.id === \"chevron-down\") {\n return <Chevron direction=\"down\" {...iconStyle} />;\n }\n\n return (\n <svg style={iconStyle} {...props}>\n <use href={`${iconURL}#${props.id}`} />\n </svg>\n );\n}\n\nfunction Chevron({\n direction,\n ...props\n}: {\n direction: \"right\" | \"left\" | \"up\" | \"down\";\n} & SVGProps<SVGSVGElement>) {\n const rotateMap = {\n right: 0,\n down: 90,\n left: 180,\n up: 270,\n };\n\n return (\n <svg\n viewBox=\"0 0 16 16\"\n style={{\n transform: `rotate(${rotateMap[direction]}deg)`,\n }}\n {...props}\n >\n {/* NOTE: this is the path for the \"right\" direction */}\n <path\n fill=\"currentColor\"\n d=\"M5.74 3.2a.75.75 0 0 0-.04 1.06L9.227 8L5.7 11.74a.75.75 0 1 0 1.1 1.02l4-4.25a.75.75 0 0 0 0-1.02l-4-4.25a.75.75 0 0 0-1.06-.04\"\n />\n </svg>\n );\n}\n"],"names":["Icon","props","iconStyle","jsx","Chevron","iconURL","direction","rotateMap"],"mappings":"8LAyCO,SAASA,EAAKC,EAAkB,CACrC,IAAIC,EAAY,CACd,OAAQD,EAAM,MAAQ,OACtB,MAAOA,EAAM,MAAQ,OACrB,MAAOA,EAAM,OAAS,MAAA,EAGxB,OAAIA,EAAM,KAAO,gBACRE,EAAAA,kBAAAA,IAACC,EAAA,CAAQ,UAAU,QAAS,GAAGF,EAAW,EAG/CD,EAAM,KAAO,eACRE,EAAAA,kBAAAA,IAACC,EAAA,CAAQ,UAAU,OAAQ,GAAGF,EAAW,EAG9CD,EAAM,KAAO,aACRE,EAAAA,kBAAAA,IAACC,EAAA,CAAQ,UAAU,KAAM,GAAGF,EAAW,EAG5CD,EAAM,KAAO,eACRE,EAAAA,kBAAAA,IAACC,EAAA,CAAQ,UAAU,OAAQ,GAAGF,EAAW,EAIhDC,EAAAA,kBAAAA,IAAC,MAAA,CAAI,MAAOD,EAAY,GAAGD,EACzB,SAAAE,wBAAC,MAAA,CAAI,KAAM,GAAGE,EAAAA,OAAO,IAAIJ,EAAM,EAAE,GAAI,EACvC,CAEJ,CAEA,SAASG,EAAQ,CACf,UAAAE,EACA,GAAGL,CACL,EAE6B,CAC3B,MAAMM,EAAY,CAChB,MAAO,EACP,KAAM,GACN,KAAM,IACN,GAAI,GAAA,EAGN,OACEJ,EAAAA,kBAAAA,IAAC,MAAA,CACC,QAAQ,YACR,MAAO,CACL,UAAW,UAAUI,EAAUD,CAAS,CAAC,MAAA,EAE1C,GAAGL,EAGJ,SAAAE,EAAAA,kBAAAA,IAAC,OAAA,CACC,KAAK,eACL,EAAE,kIAAA,CAAA,CACJ,CAAA,CAGN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.es.js","sources":["../../../src/components/Icon/Icon.tsx"],"sourcesContent":["import { SVGProps } from \"react\";\
|
|
1
|
+
{"version":3,"file":"Icon.es.js","sources":["../../../src/components/Icon/Icon.tsx"],"sourcesContent":["import { SVGProps } from \"react\";\nimport iconURL from \"../../../assets/svg/icons.svg\";\n\ntype IconID =\n | \"external-link\"\n | \"caret-down\"\n | \"caret-right\"\n | \"chevron-right\"\n | \"chevron-left\"\n | \"chevron-up\"\n | \"chevron-down\";\n\n/*\n *\n * 🚧 UNDER CONSTRUCTION 🚧\n *\n */\n\nexport interface IconProps {\n /**\n * The spritesheet ID defined in the Icons spritesheet.\n */\n id: IconID;\n\n /**\n * The desired width/height of the icon. Accepts any valid CSS unit.\n */\n size?: number | string;\n\n /**\n * The stroke color of the icon.\n */\n color?: string;\n}\n\n/**\n * An icon component that displays SVG icons from a sprite sheet or inline.\n *\n * API:\n * - {@link IconProps}\n */\nexport function Icon(props: IconProps) {\n let iconStyle = {\n height: props.size || undefined,\n width: props.size || undefined,\n color: props.color || undefined,\n };\n\n if (props.id === \"chevron-right\") {\n return <Chevron direction=\"right\" {...iconStyle} />;\n }\n\n if (props.id === \"chevron-left\") {\n return <Chevron direction=\"left\" {...iconStyle} />;\n }\n\n if (props.id === \"chevron-up\") {\n return <Chevron direction=\"up\" {...iconStyle} />;\n }\n\n if (props.id === \"chevron-down\") {\n return <Chevron direction=\"down\" {...iconStyle} />;\n }\n\n return (\n <svg style={iconStyle} {...props}>\n <use href={`${iconURL}#${props.id}`} />\n </svg>\n );\n}\n\nfunction Chevron({\n direction,\n ...props\n}: {\n direction: \"right\" | \"left\" | \"up\" | \"down\";\n} & SVGProps<SVGSVGElement>) {\n const rotateMap = {\n right: 0,\n down: 90,\n left: 180,\n up: 270,\n };\n\n return (\n <svg\n viewBox=\"0 0 16 16\"\n style={{\n transform: `rotate(${rotateMap[direction]}deg)`,\n }}\n {...props}\n >\n {/* NOTE: this is the path for the \"right\" direction */}\n <path\n fill=\"currentColor\"\n d=\"M5.74 3.2a.75.75 0 0 0-.04 1.06L9.227 8L5.7 11.74a.75.75 0 1 0 1.1 1.02l4-4.25a.75.75 0 0 0 0-1.02l-4-4.25a.75.75 0 0 0-1.06-.04\"\n />\n </svg>\n );\n}\n"],"names":["Icon","props","iconStyle","jsx","Chevron","iconURL","direction","rotateMap"],"mappings":";;AAyCO,SAASA,EAAKC,GAAkB;AACrC,MAAIC,IAAY;AAAA,IACd,QAAQD,EAAM,QAAQ;AAAA,IACtB,OAAOA,EAAM,QAAQ;AAAA,IACrB,OAAOA,EAAM,SAAS;AAAA,EAAA;AAGxB,SAAIA,EAAM,OAAO,kBACRE,gBAAAA,EAAAA,IAACC,GAAA,EAAQ,WAAU,SAAS,GAAGF,GAAW,IAG/CD,EAAM,OAAO,iBACRE,gBAAAA,EAAAA,IAACC,GAAA,EAAQ,WAAU,QAAQ,GAAGF,GAAW,IAG9CD,EAAM,OAAO,eACRE,gBAAAA,EAAAA,IAACC,GAAA,EAAQ,WAAU,MAAM,GAAGF,GAAW,IAG5CD,EAAM,OAAO,iBACRE,gBAAAA,EAAAA,IAACC,GAAA,EAAQ,WAAU,QAAQ,GAAGF,GAAW,IAIhDC,gBAAAA,EAAAA,IAAC,OAAA,EAAI,OAAOD,GAAY,GAAGD,GACzB,UAAAE,gBAAAA,MAAC,OAAA,EAAI,MAAM,GAAGE,CAAO,IAAIJ,EAAM,EAAE,IAAI,GACvC;AAEJ;AAEA,SAASG,EAAQ;AAAA,EACf,WAAAE;AAAA,EACA,GAAGL;AACL,GAE6B;AAC3B,QAAMM,IAAY;AAAA,IAChB,OAAO;AAAA,IACP,MAAM;AAAA,IACN,MAAM;AAAA,IACN,IAAI;AAAA,EAAA;AAGN,SACEJ,gBAAAA,EAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,SAAQ;AAAA,MACR,OAAO;AAAA,QACL,WAAW,UAAUI,EAAUD,CAAS,CAAC;AAAA,MAAA;AAAA,MAE1C,GAAGL;AAAA,MAGJ,UAAAE,gBAAAA,EAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,GAAE;AAAA,QAAA;AAAA,MAAA;AAAA,IACJ;AAAA,EAAA;AAGN;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageBackground.cjs.js","sources":["../../../src/components/ImageBackground/ImageBackground.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"ImageBackground.cjs.js","sources":["../../../src/components/ImageBackground/ImageBackground.tsx"],"sourcesContent":["\"use client\";\n\nimport \"../ScreenOverlay/ScreenOverlay.css\";\nimport { useTheme } from \"../ThemeProvider\";\nimport { parseToRgba } from \"color2k\";\n\ninterface ImageBackgroundProps {\n /**\n * Manually display a background image. Useful for server-side rendering.\n * @important When using this prop, you must style your own image component appropriately.\n * The component will be placed directly in the background without additional styling.\n */\n image?: React.ReactNode;\n /**\n * The URL of the image to display in the background.\n * @important Client-side only. Cannot be used in Server Components.\n * When using this prop, the image will be automatically styled with the background effect.\n */\n imageUrl?: string;\n /**\n * Callback function to handle the image load event.\n * @important Client-side only. Cannot be used in Server Components.\n */\n onLoad?: (image: HTMLImageElement) => void;\n}\n\n/**\n * Calculates a background color with appropriate opacity based on the brightness of the base color.\n * For dark colors (sum of RGB values < 65), returns a white overlay with variable opacity.\n * For brighter colors, returns an empty string (no overlay needed).\n */\nconst getBgWhiteOverlayColor = (color: [number, number, number, number]) => {\n const [r, g, b] = color;\n const brightness = r + g + b;\n\n // Only apply white overlay for dark backgrounds\n if (brightness < 65) {\n // Calculate opacity inversely proportional to brightness\n // Brighter colors get less opacity, with a minimum of 0.1\n const brightnessPercentage = brightness / 100;\n const opacity = Math.max(0.14, 0.36 - brightnessPercentage);\n\n return `rgba(255, 255, 255, ${opacity})`;\n }\n\n return \"\";\n};\n\n/**\n * ImageOverlay component for displaying an image with a blur effect.\n *\n * API:\n * - {@link ImageBackgroundProps}\n */\nexport function ImageBackground({\n image,\n imageUrl = \"\",\n onLoad,\n}: ImageBackgroundProps) {\n const { palette } = useTheme();\n const baseColor = parseToRgba(palette.BASE_COLOR);\n const backgroundColor = getBgWhiteOverlayColor(baseColor);\n\n return (\n <div\n id=\"image-background\"\n aria-label=\"Background overlay\"\n role=\"dialog\"\n aria-modal=\"true\"\n className=\"proton-ScreenOverlay__background\"\n >\n {image ? (\n <div aria-hidden=\"true\">{image}</div>\n ) : (\n <img\n alt=\"\" // Decorative image\n src={imageUrl}\n className=\"proton-ScreenOverlay__image\"\n onLoad={(event) => onLoad?.(event.currentTarget)}\n aria-hidden=\"true\"\n />\n )}\n <div\n className=\"proton-ScreenOverlay__blur\"\n aria-hidden=\"true\"\n style={{\n background: backgroundColor,\n }}\n />\n </div>\n );\n}\n"],"names":["getBgWhiteOverlayColor","color","r","g","b","brightness","brightnessPercentage","ImageBackground","image","imageUrl","onLoad","palette","useTheme","baseColor","parseToRgba","backgroundColor","jsxs","jsx","event"],"mappings":"2TA+BMA,EAA0BC,GAA4C,CAC1E,KAAM,CAACC,EAAGC,EAAGC,CAAC,EAAIH,EACZI,EAAaH,EAAIC,EAAIC,EAG3B,GAAIC,EAAa,GAAI,CAGnB,MAAMC,EAAuBD,EAAa,IAG1C,MAAO,uBAFS,KAAK,IAAI,IAAM,IAAOC,CAAoB,CAErB,GACvC,CAEA,MAAO,EACT,EAQO,SAASC,EAAgB,CAC9B,MAAAC,EACA,SAAAC,EAAW,GACX,OAAAC,CACF,EAAyB,CACvB,KAAM,CAAE,QAAAC,CAAA,EAAYC,WAAA,EACdC,EAAYC,EAAAA,YAAYH,EAAQ,UAAU,EAC1CI,EAAkBf,EAAuBa,CAAS,EAExD,OACEG,EAAAA,kBAAAA,KAAC,MAAA,CACC,GAAG,mBACH,aAAW,qBACX,KAAK,SACL,aAAW,OACX,UAAU,mCAET,SAAA,CAAAR,EACCS,EAAAA,kBAAAA,IAAC,MAAA,CAAI,cAAY,OAAQ,WAAM,EAE/BA,EAAAA,kBAAAA,IAAC,MAAA,CACC,IAAI,GACJ,IAAKR,EACL,UAAU,8BACV,OAASS,GAAUR,GAAA,YAAAA,EAASQ,EAAM,eAClC,cAAY,MAAA,CAAA,EAGhBD,EAAAA,kBAAAA,IAAC,MAAA,CACC,UAAU,6BACV,cAAY,OACZ,MAAO,CACL,WAAYF,CAAA,CACd,CAAA,CACF,CAAA,CAAA,CAGN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageBackground.es.js","sources":["../../../src/components/ImageBackground/ImageBackground.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"ImageBackground.es.js","sources":["../../../src/components/ImageBackground/ImageBackground.tsx"],"sourcesContent":["\"use client\";\n\nimport \"../ScreenOverlay/ScreenOverlay.css\";\nimport { useTheme } from \"../ThemeProvider\";\nimport { parseToRgba } from \"color2k\";\n\ninterface ImageBackgroundProps {\n /**\n * Manually display a background image. Useful for server-side rendering.\n * @important When using this prop, you must style your own image component appropriately.\n * The component will be placed directly in the background without additional styling.\n */\n image?: React.ReactNode;\n /**\n * The URL of the image to display in the background.\n * @important Client-side only. Cannot be used in Server Components.\n * When using this prop, the image will be automatically styled with the background effect.\n */\n imageUrl?: string;\n /**\n * Callback function to handle the image load event.\n * @important Client-side only. Cannot be used in Server Components.\n */\n onLoad?: (image: HTMLImageElement) => void;\n}\n\n/**\n * Calculates a background color with appropriate opacity based on the brightness of the base color.\n * For dark colors (sum of RGB values < 65), returns a white overlay with variable opacity.\n * For brighter colors, returns an empty string (no overlay needed).\n */\nconst getBgWhiteOverlayColor = (color: [number, number, number, number]) => {\n const [r, g, b] = color;\n const brightness = r + g + b;\n\n // Only apply white overlay for dark backgrounds\n if (brightness < 65) {\n // Calculate opacity inversely proportional to brightness\n // Brighter colors get less opacity, with a minimum of 0.1\n const brightnessPercentage = brightness / 100;\n const opacity = Math.max(0.14, 0.36 - brightnessPercentage);\n\n return `rgba(255, 255, 255, ${opacity})`;\n }\n\n return \"\";\n};\n\n/**\n * ImageOverlay component for displaying an image with a blur effect.\n *\n * API:\n * - {@link ImageBackgroundProps}\n */\nexport function ImageBackground({\n image,\n imageUrl = \"\",\n onLoad,\n}: ImageBackgroundProps) {\n const { palette } = useTheme();\n const baseColor = parseToRgba(palette.BASE_COLOR);\n const backgroundColor = getBgWhiteOverlayColor(baseColor);\n\n return (\n <div\n id=\"image-background\"\n aria-label=\"Background overlay\"\n role=\"dialog\"\n aria-modal=\"true\"\n className=\"proton-ScreenOverlay__background\"\n >\n {image ? (\n <div aria-hidden=\"true\">{image}</div>\n ) : (\n <img\n alt=\"\" // Decorative image\n src={imageUrl}\n className=\"proton-ScreenOverlay__image\"\n onLoad={(event) => onLoad?.(event.currentTarget)}\n aria-hidden=\"true\"\n />\n )}\n <div\n className=\"proton-ScreenOverlay__blur\"\n aria-hidden=\"true\"\n style={{\n background: backgroundColor,\n }}\n />\n </div>\n );\n}\n"],"names":["getBgWhiteOverlayColor","color","r","g","b","brightness","brightnessPercentage","ImageBackground","image","imageUrl","onLoad","palette","useTheme","baseColor","parseToRgba","backgroundColor","jsxs","jsx","event"],"mappings":";;;;AA+BA,MAAMA,IAAyB,CAACC,MAA4C;AAC1E,QAAM,CAACC,GAAGC,GAAGC,CAAC,IAAIH,GACZI,IAAaH,IAAIC,IAAIC;AAG3B,MAAIC,IAAa,IAAI;AAGnB,UAAMC,IAAuBD,IAAa;AAG1C,WAAO,uBAFS,KAAK,IAAI,MAAM,OAAOC,CAAoB,CAErB;AAAA,EACvC;AAEA,SAAO;AACT;AAQO,SAASC,EAAgB;AAAA,EAC9B,OAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,QAAAC;AACF,GAAyB;AACvB,QAAM,EAAE,SAAAC,EAAA,IAAYC,EAAA,GACdC,IAAYC,EAAYH,EAAQ,UAAU,GAC1CI,IAAkBf,EAAuBa,CAAS;AAExD,SACEG,gBAAAA,EAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAG;AAAA,MACH,cAAW;AAAA,MACX,MAAK;AAAA,MACL,cAAW;AAAA,MACX,WAAU;AAAA,MAET,UAAA;AAAA,QAAAR,IACCS,gBAAAA,EAAAA,IAAC,OAAA,EAAI,eAAY,QAAQ,aAAM,IAE/BA,gBAAAA,EAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,KAAI;AAAA,YACJ,KAAKR;AAAA,YACL,WAAU;AAAA,YACV,QAAQ,CAACS,MAAUR,KAAA,gBAAAA,EAASQ,EAAM;AAAA,YAClC,eAAY;AAAA,UAAA;AAAA,QAAA;AAAA,QAGhBD,gBAAAA,EAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,eAAY;AAAA,YACZ,OAAO;AAAA,cACL,YAAYF;AAAA,YAAA;AAAA,UACd;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.cjs.js","sources":["../../../../src/components/Input/BaseInput/Input.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport React, { forwardRef, useEffect, useRef } from \"react\";\r\n\r\nimport { useTheme } from \"../../ThemeProvider\";\r\nimport { csx } from \"../../../utils\";\r\nimport \"./Input.css\";\r\nimport { copyTextToClipboard } from \"../../../utils/copy\";\r\n\r\nexport interface BaseInputProps {\r\n /**\r\n * onChange handler for the input\r\n */\r\n onChange?: (value: string) => void;\r\n\r\n /** Whether the input is disabled. */\r\n isDisabled?: boolean;\r\n\r\n /** Description text shown above the input. */\r\n description?: React.ReactNode | string;\r\n\r\n /**\r\n * The position of the description text.\r\n * @default \"top\"\r\n */\r\n descriptionPosition?: \"top\" | \"bottom\";\r\n\r\n /** Error state that changes the input's visual style and displays an error message. */\r\n error?: React.ReactNode | string;\r\n\r\n /**\r\n * Label for the input element.\r\n * @note When a label is provided, the input will have extra padding, and the label will float above the text input when focused or filled.\r\n */\r\n label?: string;\r\n\r\n /** Test ID for the component. */\r\n \"data-testid\"?: string;\r\n\r\n /** Content to display before the input. Typically used for icons. */\r\n prefix?: React.ReactNode;\r\n\r\n /** Content to display after the input. Typically used for icons. */\r\n suffix?: React.ReactNode;\r\n\r\n /**\r\n * Should the browser's autocomplete be enabled?\r\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete\r\n */\r\n autoComplete?: boolean;\r\n\r\n /**\r\n * Should the input be autofocused?\r\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autofocus\r\n */\r\n autoFocus?: boolean;\r\n\r\n /**\r\n * The name attribute of the input element.\r\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/name\r\n */\r\n name: string;\r\n\r\n /**\r\n * The placeholder text to display when the input is empty.\r\n * @note label takes precedence over placeholder, if both are provided.\r\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/placeholder\r\n */\r\n placeholder?: string;\r\n\r\n /**\r\n * The type attribute of the input element.\r\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/type\r\n * @default \"text\"\r\n */\r\n type?: string;\r\n\r\n /**\r\n * The value of the input.\r\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value\r\n */\r\n value?: string;\r\n\r\n /**\r\n * Whether the input is required.\r\n * @default false\r\n */\r\n isRequired?: boolean;\r\n\r\n /**\r\n * Whether the input is read-only.\r\n * @default false\r\n */\r\n isReadOnly?: boolean;\r\n\r\n /**\r\n * Called when the input is submitted (e.g. by pressing Enter).\r\n */\r\n onSubmit?: React.FormEventHandler<HTMLInputElement>;\r\n\r\n /**\r\n * Called when the input is cleared (e.g. by pressing Escape).\r\n */\r\n onClear?: () => void;\r\n}\r\n\r\n/**\r\n * A controlled and customizable input component with support for labels, prefixes, suffixes, and error states.\r\n *\r\n * API:\r\n * - {@link BaseInputProps}\r\n */\r\nexport const Input = forwardRef<HTMLInputElement, BaseInputProps>(\r\n (\r\n {\r\n prefix,\r\n suffix,\r\n description,\r\n descriptionPosition = \"top\",\r\n isDisabled,\r\n error,\r\n onChange,\r\n label,\r\n name,\r\n placeholder,\r\n type = \"text\",\r\n value,\r\n autoFocus,\r\n autoComplete,\r\n isRequired = false,\r\n isReadOnly = false,\r\n onSubmit,\r\n onClear,\r\n \"data-testid\": testId,\r\n },\r\n forwardedRef: React.RefObject<HTMLInputElement>\r\n ) => {\r\n const inputRef = useRef<HTMLInputElement>(null);\r\n const prefixRef = useRef<HTMLDivElement>(null);\r\n const suffixRef = useRef<HTMLDivElement>(null);\r\n const containerRef = useRef<HTMLDivElement>(null);\r\n const { className } = useTheme();\r\n const ref = forwardedRef || inputRef;\r\n\r\n // Control dynamic prefix and suffix widths using ResizeObserver\r\n useEffect(() => {\r\n if (!containerRef.current) return;\r\n\r\n const updateSizes = () => {\r\n if (containerRef.current) {\r\n const containerWidth = containerRef.current.offsetWidth || 200;\r\n containerRef.current.style.setProperty(\r\n \"--container-width\",\r\n `${containerWidth}px`\r\n );\r\n }\r\n\r\n if (prefixRef.current) {\r\n const prefixWidth = prefixRef.current.offsetWidth || 32;\r\n containerRef.current?.style.setProperty(\r\n \"--prefix-width\",\r\n `${prefixWidth}px`\r\n );\r\n }\r\n\r\n if (suffixRef.current) {\r\n const suffixWidth = suffixRef.current.offsetWidth || 32;\r\n containerRef.current?.style.setProperty(\r\n \"--suffix-width\",\r\n `${suffixWidth}px`\r\n );\r\n }\r\n };\r\n\r\n updateSizes();\r\n\r\n const resizeObserver = new ResizeObserver(updateSizes);\r\n\r\n if (containerRef.current) {\r\n resizeObserver.observe(containerRef.current);\r\n }\r\n if (prefixRef.current) {\r\n resizeObserver.observe(prefixRef.current);\r\n }\r\n if (suffixRef.current) {\r\n resizeObserver.observe(suffixRef.current);\r\n }\r\n\r\n return () => {\r\n resizeObserver.disconnect();\r\n };\r\n }, [prefix, suffix]);\r\n\r\n const inputId = `${name}-input`;\r\n const errorId = `${name}-error`;\r\n const descriptionId = `${name}-description`;\r\n\r\n return (\r\n <div ref={containerRef}>\r\n {description && descriptionPosition === \"top\" && (\r\n <div\r\n id={descriptionId}\r\n className=\"proton-Input__text\"\r\n aria-live=\"polite\"\r\n >\r\n {description}\r\n </div>\r\n )}\r\n <div className={csx(\r\n \"proton-Input__container-inner\",\r\n prefix && \"proton-Input__has-prefix\",\r\n suffix && \"proton-Input__has-suffix\"\r\n )}>\r\n {prefix && (\r\n <div\r\n ref={prefixRef}\r\n className={csx(\r\n \"proton-Input__descriptor\",\r\n \"proton-Input__prefix\"\r\n )}\r\n >\r\n {prefix}\r\n </div>\r\n )}\r\n\r\n <input\r\n id={inputId}\r\n name={name}\r\n type={type}\r\n value={value}\r\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\r\n onChange?.(e.target.value);\r\n }}\r\n onKeyDown={(e: React.KeyboardEvent<HTMLInputElement>) => {\r\n switch (e.key) {\r\n case \"Enter\":\r\n if (onSubmit) {\r\n e.preventDefault();\r\n onSubmit(e);\r\n }\r\n break;\r\n case \"Escape\":\r\n if (onClear) {\r\n e.preventDefault();\r\n onClear();\r\n }\r\n break;\r\n }\r\n }}\r\n onCopy={async () =>\r\n await copyTextToClipboard(inputRef.current?.value)\r\n }\r\n disabled={isDisabled}\r\n readOnly={isReadOnly}\r\n required={isRequired}\r\n autoFocus={autoFocus}\r\n autoComplete={autoComplete ? \"on\" : \"off\"}\r\n placeholder={label ? undefined : placeholder}\r\n aria-label={label || name}\r\n aria-invalid={Boolean(error)}\r\n aria-errormessage={typeof error === \"string\" ? error : errorId}\r\n aria-required={isRequired}\r\n aria-readonly={isReadOnly}\r\n aria-describedby={\r\n error ? errorId : description ? descriptionId : undefined\r\n }\r\n aria-disabled={isDisabled}\r\n data-testid={testId}\r\n ref={ref}\r\n className={csx(\r\n \"proton-Input\",\r\n error && \"proton-Input--error\",\r\n label && \"proton-Input__label-top\",\r\n className\r\n )}\r\n />\r\n\r\n <label\r\n htmlFor={inputId}\r\n className={csx(\r\n \"proton-Input__label\",\r\n value && \"proton-Input__label--filled\"\r\n )}\r\n >\r\n {label}\r\n {isRequired && <span aria-hidden=\"true\"> *</span>}\r\n </label>\r\n\r\n {suffix && (\r\n <div\r\n ref={suffixRef}\r\n className={csx(\r\n \"proton-Input__descriptor\",\r\n \"proton-Input__suffix\"\r\n )}\r\n >\r\n {suffix}\r\n </div>\r\n )}\r\n </div>\r\n\r\n {error ? (\r\n <div\r\n role=\"alert\"\r\n className={csx(\"proton-Input__error\", \"proton-Input__text\")}\r\n id={errorId}\r\n >\r\n {error}\r\n </div>\r\n ) : description && descriptionPosition === \"bottom\" ? (\r\n <div\r\n id={descriptionId}\r\n className=\"proton-Input__text\"\r\n aria-live=\"polite\"\r\n >\r\n {description}\r\n </div>\r\n ) : null}\r\n </div>\r\n );\r\n }\r\n);\r\n\r\nInput.displayName = \"ProtonUIInput\";\r\n"],"names":["Input","forwardRef","prefix","suffix","description","descriptionPosition","isDisabled","error","onChange","label","name","placeholder","type","value","autoFocus","autoComplete","isRequired","isReadOnly","onSubmit","onClear","testId","forwardedRef","inputRef","useRef","prefixRef","suffixRef","containerRef","className","useTheme","ref","useEffect","updateSizes","containerWidth","prefixWidth","_a","suffixWidth","_b","resizeObserver","inputId","errorId","descriptionId","jsxs","jsx","csx","e","copyTextToClipboard"],"mappings":"mUAgHaA,EAAQC,EAAA,WACnB,CACE,CACE,OAAAC,EACA,OAAAC,EACA,YAAAC,EACA,oBAAAC,EAAsB,MACtB,WAAAC,EACA,MAAAC,EAC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9B,GAAS,6BACX,EAEC,SAAA,CAAAJ,EACAO,GAAc0B,EAAA,kBAAA,IAAC,OAAK,CAAA,cAAY,OAAO,SAAE,KAAA,CAAA,CAAA,CAC5C,EAECvC,GACCuC,EAAA,kBAAA,IAAC,MAAA,CACC,IAAKjB,EACL,UAAWkB,EAAA,IACT,2BACA,sBACF,EAEC,SAAAxC,CAAA,CACH,CAAA,EAEJ,EAECI,EACCmC,EAAA,kBAAA,IAAC,MAAA,CACC,KAAK,QACL,UAAWC,EAAAA,IAAI,sBAAuB,oBAAoB,EAC1D,GAAIJ,EAEH,SAAAhC,CAAA,CAAA,EAEDH,GAAeC,IAAwB,SACzCqC,EAAA,kBAAA,IAAC,MAAA,CACC,GAAIF,EACJ,UAAU,qBACV,YAAU,SAET,SAAApC,CAAA,CAAA,EAED,IACN,CAAA,CAAA,CAEJ,CACF,EAEAJ,EAAM,YAAc"}
|
|
1
|
+
{"version":3,"file":"Input.cjs.js","sources":["../../../../src/components/Input/BaseInput/Input.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { forwardRef, useEffect, useRef } from \"react\";\n\nimport { useTheme } from \"../../ThemeProvider\";\nimport { csx } from \"../../../utils\";\nimport \"./Input.css\";\nimport { copyTextToClipboard } from \"../../../utils/copy\";\n\nexport interface BaseInputProps {\n /**\n * onChange handler for the input\n */\n onChange?: (value: string) => void;\n\n /** Whether the input is disabled. */\n isDisabled?: boolean;\n\n /** Description text shown above the input. */\n description?: React.ReactNode | string;\n\n /**\n * The position of the description text.\n * @default \"top\"\n */\n descriptionPosition?: \"top\" | \"bottom\";\n\n /** Error state that changes the input's visual style and displays an error message. */\n error?: React.ReactNode | string;\n\n /**\n * Label for the input element.\n * @note When a label is provided, the input will have extra padding, and the label will float above the text input when focused or filled.\n */\n label?: string;\n\n /** Test ID for the component. */\n \"data-testid\"?: string;\n\n /** Content to display before the input. Typically used for icons. */\n prefix?: React.ReactNode;\n\n /** Content to display after the input. Typically used for icons. */\n suffix?: React.ReactNode;\n\n /**\n * Should the browser's autocomplete be enabled?\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete\n */\n autoComplete?: boolean;\n\n /**\n * Should the input be autofocused?\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autofocus\n */\n autoFocus?: boolean;\n\n /**\n * The name attribute of the input element.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/name\n */\n name: string;\n\n /**\n * The placeholder text to display when the input is empty.\n * @note label takes precedence over placeholder, if both are provided.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/placeholder\n */\n placeholder?: string;\n\n /**\n * The type attribute of the input element.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/type\n * @default \"text\"\n */\n type?: string;\n\n /**\n * The value of the input.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value\n */\n value?: string;\n\n /**\n * Whether the input is required.\n * @default false\n */\n isRequired?: boolean;\n\n /**\n * Whether the input is read-only.\n * @default false\n */\n isReadOnly?: boolean;\n\n /**\n * Called when the input is submitted (e.g. by pressing Enter).\n */\n onSubmit?: React.FormEventHandler<HTMLInputElement>;\n\n /**\n * Called when the input is cleared (e.g. by pressing Escape).\n */\n onClear?: () => void;\n}\n\n/**\n * A controlled and customizable input component with support for labels, prefixes, suffixes, and error states.\n *\n * API:\n * - {@link BaseInputProps}\n */\nexport const Input = forwardRef<HTMLInputElement, BaseInputProps>(\n (\n {\n prefix,\n suffix,\n description,\n descriptionPosition = \"top\",\n isDisabled,\n error,\n onChange,\n label,\n name,\n placeholder,\n type = \"text\",\n value,\n autoFocus,\n autoComplete,\n isRequired = false,\n isReadOnly = false,\n onSubmit,\n onClear,\n \"data-testid\": testId,\n },\n forwardedRef: React.RefObject<HTMLInputElement>\n ) => {\n const inputRef = useRef<HTMLInputElement>(null);\n const prefixRef = useRef<HTMLDivElement>(null);\n const suffixRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const { className } = useTheme();\n const ref = forwardedRef || inputRef;\n\n // Control dynamic prefix and suffix widths using ResizeObserver\n useEffect(() => {\n if (!containerRef.current) return;\n\n const updateSizes = () => {\n if (containerRef.current) {\n const containerWidth = containerRef.current.offsetWidth || 200;\n containerRef.current.style.setProperty(\n \"--container-width\",\n `${containerWidth}px`\n );\n }\n\n if (prefixRef.current) {\n const prefixWidth = prefixRef.current.offsetWidth || 32;\n containerRef.current?.style.setProperty(\n \"--prefix-width\",\n `${prefixWidth}px`\n );\n }\n\n if (suffixRef.current) {\n const suffixWidth = suffixRef.current.offsetWidth || 32;\n containerRef.current?.style.setProperty(\n \"--suffix-width\",\n `${suffixWidth}px`\n );\n }\n };\n\n updateSizes();\n\n const resizeObserver = new ResizeObserver(updateSizes);\n\n if (containerRef.current) {\n resizeObserver.observe(containerRef.current);\n }\n if (prefixRef.current) {\n resizeObserver.observe(prefixRef.current);\n }\n if (suffixRef.current) {\n resizeObserver.observe(suffixRef.current);\n }\n\n return () => {\n resizeObserver.disconnect();\n };\n }, [prefix, suffix]);\n\n const inputId = `${name}-input`;\n const errorId = `${name}-error`;\n const descriptionId = `${name}-description`;\n\n return (\n <div ref={containerRef}>\n {description && descriptionPosition === \"top\" && (\n <div\n id={descriptionId}\n className=\"proton-Input__text\"\n aria-live=\"polite\"\n >\n {description}\n </div>\n )}\n <div className={csx(\n \"proton-Input__container-inner\",\n prefix && \"proton-Input__has-prefix\",\n suffix && \"proton-Input__has-suffix\"\n )}>\n {prefix && (\n <div\n ref={prefixRef}\n className={csx(\n \"proton-Input__descriptor\",\n \"proton-Input__prefix\"\n )}\n >\n {prefix}\n </div>\n )}\n\n <input\n id={inputId}\n name={name}\n type={type}\n value={value}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(e.target.value);\n }}\n onKeyDown={(e: React.KeyboardEvent<HTMLInputElement>) => {\n switch (e.key) {\n case \"Enter\":\n if (onSubmit) {\n e.preventDefault();\n onSubmit(e);\n }\n break;\n case \"Escape\":\n if (onClear) {\n e.preventDefault();\n onClear();\n }\n break;\n }\n }}\n onCopy={async () =>\n await copyTextToClipboard(inputRef.current?.value)\n }\n disabled={isDisabled}\n readOnly={isReadOnly}\n required={isRequired}\n autoFocus={autoFocus}\n autoComplete={autoComplete ? \"on\" : \"off\"}\n placeholder={label ? undefined : placeholder}\n aria-label={label || name}\n aria-invalid={Boolean(error)}\n aria-errormessage={typeof error === \"string\" ? error : errorId}\n aria-required={isRequired}\n aria-readonly={isReadOnly}\n aria-describedby={\n error ? errorId : description ? descriptionId : undefined\n }\n aria-disabled={isDisabled}\n data-testid={testId}\n ref={ref}\n className={csx(\n \"proton-Input\",\n error && \"proton-Input--error\",\n label && \"proton-Input__label-top\",\n className\n )}\n />\n\n <label\n htmlFor={inputId}\n className={csx(\n \"proton-Input__label\",\n value && \"proton-Input__label--filled\"\n )}\n >\n {label}\n {isRequired && <span aria-hidden=\"true\"> *</span>}\n </label>\n\n {suffix && (\n <div\n ref={suffixRef}\n className={csx(\n \"proton-Input__descriptor\",\n \"proton-Input__suffix\"\n )}\n >\n {suffix}\n </div>\n )}\n </div>\n\n {error ? (\n <div\n role=\"alert\"\n className={csx(\"proton-Input__error\", \"proton-Input__text\")}\n id={errorId}\n >\n {error}\n </div>\n ) : description && descriptionPosition === \"bottom\" ? (\n <div\n id={descriptionId}\n className=\"proton-Input__text\"\n aria-live=\"polite\"\n >\n {description}\n </div>\n ) : null}\n </div>\n );\n }\n);\n\nInput.displayName = \"ProtonUIInput\";\n"],"names":["Input","forwardRef","prefix","suffix","description","descriptionPosition","isDisabled","error","onChange","label","name","placeholder","type","value","autoFocus","autoComplete","isRequired","isReadOnly","onSubmit","onClear","testId","forwardedRef","inputRef","useRef","prefixRef","suffixRef","containerRef","className","useTheme","ref","useEffect","updateSizes","containerWidth","prefixWidth","_a","suffixWidth","_b","resizeObserver","inputId","errorId","descriptionId","jsxs","jsx","csx","e","copyTextToClipboard"],"mappings":"mUAgHaA,EAAQ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AelC,EACf,cAAac,EACb,IAAAS,EACA,UAAWc,EAAAA,IACT,eACApC,GAAS,sBACTE,GAAS,0BACTkB,CAAA,CACF,CAAA,EAGFc,EAAAA,kBAAAA,KAAC,QAAA,CACC,QAASH,EACT,UAAWK,EAAAA,IACT,sBACA9B,GAAS,6BAAA,EAGV,SAAA,CAAAJ,EACAO,GAAc0B,EAAAA,kBAAAA,IAAC,OAAA,CAAK,cAAY,OAAO,SAAA,IAAA,CAAE,CAAA,CAAA,CAAA,EAG3CvC,GACCuC,EAAAA,kBAAAA,IAAC,MAAA,CACC,IAAKjB,EACL,UAAWkB,EAAAA,IACT,2BACA,sBAAA,EAGD,SAAAxC,CAAA,CAAA,CACH,EAEJ,EAECI,EACCmC,EAAAA,kBAAAA,IAAC,MAAA,CACC,KAAK,QACL,UAAWC,EAAAA,IAAI,sBAAuB,oBAAoB,EAC1D,GAAIJ,EAEH,SAAAhC,CAAA,CAAA,EAEDH,GAAeC,IAAwB,SACzCqC,EAAAA,kBAAAA,IAAC,MAAA,CACC,GAAIF,EACJ,UAAU,qBACV,YAAU,SAET,SAAApC,CAAA,CAAA,EAED,IAAA,EACN,CAEJ,CACF,EAEAJ,EAAM,YAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.es.js","sources":["../../../../src/components/Input/BaseInput/Input.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport React, { forwardRef, useEffect, useRef } from \"react\";\r\n\r\nimport { useTheme } from \"../../ThemeProvider\";\r\nimport { csx } from \"../../../utils\";\r\nimport \"./Input.css\";\r\nimport { copyTextToClipboard } from \"../../../utils/copy\";\r\n\r\nexport interface BaseInputProps {\r\n /**\r\n * onChange handler for the input\r\n */\r\n onChange?: (value: string) => void;\r\n\r\n /** Whether the input is disabled. */\r\n isDisabled?: boolean;\r\n\r\n /** Description text shown above the input. */\r\n description?: React.ReactNode | string;\r\n\r\n /**\r\n * The position of the description text.\r\n * @default \"top\"\r\n */\r\n descriptionPosition?: \"top\" | \"bottom\";\r\n\r\n /** Error state that changes the input's visual style and displays an error message. */\r\n error?: React.ReactNode | string;\r\n\r\n /**\r\n * Label for the input element.\r\n * @note When a label is provided, the input will have extra padding, and the label will float above the text input when focused or filled.\r\n */\r\n label?: string;\r\n\r\n /** Test ID for the component. */\r\n \"data-testid\"?: string;\r\n\r\n /** Content to display before the input. Typically used for icons. */\r\n prefix?: React.ReactNode;\r\n\r\n /** Content to display after the input. Typically used for icons. */\r\n suffix?: React.ReactNode;\r\n\r\n /**\r\n * Should the browser's autocomplete be enabled?\r\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete\r\n */\r\n autoComplete?: boolean;\r\n\r\n /**\r\n * Should the input be autofocused?\r\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autofocus\r\n */\r\n autoFocus?: boolean;\r\n\r\n /**\r\n * The name attribute of the input element.\r\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/name\r\n */\r\n name: string;\r\n\r\n /**\r\n * The placeholder text to display when the input is empty.\r\n * @note label takes precedence over placeholder, if both are provided.\r\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/placeholder\r\n */\r\n placeholder?: string;\r\n\r\n /**\r\n * The type attribute of the input element.\r\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/type\r\n * @default \"text\"\r\n */\r\n type?: string;\r\n\r\n /**\r\n * The value of the input.\r\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value\r\n */\r\n value?: string;\r\n\r\n /**\r\n * Whether the input is required.\r\n * @default false\r\n */\r\n isRequired?: boolean;\r\n\r\n /**\r\n * Whether the input is read-only.\r\n * @default false\r\n */\r\n isReadOnly?: boolean;\r\n\r\n /**\r\n * Called when the input is submitted (e.g. by pressing Enter).\r\n */\r\n onSubmit?: React.FormEventHandler<HTMLInputElement>;\r\n\r\n /**\r\n * Called when the input is cleared (e.g. by pressing Escape).\r\n */\r\n onClear?: () => void;\r\n}\r\n\r\n/**\r\n * A controlled and customizable input component with support for labels, prefixes, suffixes, and error states.\r\n *\r\n * API:\r\n * - {@link BaseInputProps}\r\n */\r\nexport const Input = forwardRef<HTMLInputElement, BaseInputProps>(\r\n (\r\n {\r\n prefix,\r\n suffix,\r\n description,\r\n descriptionPosition = \"top\",\r\n isDisabled,\r\n error,\r\n onChange,\r\n label,\r\n name,\r\n placeholder,\r\n type = \"text\",\r\n value,\r\n autoFocus,\r\n autoComplete,\r\n isRequired = false,\r\n isReadOnly = false,\r\n onSubmit,\r\n onClear,\r\n \"data-testid\": testId,\r\n },\r\n forwardedRef: React.RefObject<HTMLInputElement>\r\n ) => {\r\n const inputRef = useRef<HTMLInputElement>(null);\r\n const prefixRef = useRef<HTMLDivElement>(null);\r\n const suffixRef = useRef<HTMLDivElement>(null);\r\n const containerRef = useRef<HTMLDivElement>(null);\r\n const { className } = useTheme();\r\n const ref = forwardedRef || inputRef;\r\n\r\n // Control dynamic prefix and suffix widths using ResizeObserver\r\n useEffect(() => {\r\n if (!containerRef.current) return;\r\n\r\n const updateSizes = () => {\r\n if (containerRef.current) {\r\n const containerWidth = containerRef.current.offsetWidth || 200;\r\n containerRef.current.style.setProperty(\r\n \"--container-width\",\r\n `${containerWidth}px`\r\n );\r\n }\r\n\r\n if (prefixRef.current) {\r\n const prefixWidth = prefixRef.current.offsetWidth || 32;\r\n containerRef.current?.style.setProperty(\r\n \"--prefix-width\",\r\n `${prefixWidth}px`\r\n );\r\n }\r\n\r\n if (suffixRef.current) {\r\n const suffixWidth = suffixRef.current.offsetWidth || 32;\r\n containerRef.current?.style.setProperty(\r\n \"--suffix-width\",\r\n `${suffixWidth}px`\r\n );\r\n }\r\n };\r\n\r\n updateSizes();\r\n\r\n const resizeObserver = new ResizeObserver(updateSizes);\r\n\r\n if (containerRef.current) {\r\n resizeObserver.observe(containerRef.current);\r\n }\r\n if (prefixRef.current) {\r\n resizeObserver.observe(prefixRef.current);\r\n }\r\n if (suffixRef.current) {\r\n resizeObserver.observe(suffixRef.current);\r\n }\r\n\r\n return () => {\r\n resizeObserver.disconnect();\r\n };\r\n }, [prefix, suffix]);\r\n\r\n const inputId = `${name}-input`;\r\n const errorId = `${name}-error`;\r\n const descriptionId = `${name}-description`;\r\n\r\n return (\r\n <div ref={containerRef}>\r\n {description && descriptionPosition === \"top\" && (\r\n <div\r\n id={descriptionId}\r\n className=\"proton-Input__text\"\r\n aria-live=\"polite\"\r\n >\r\n {description}\r\n </div>\r\n )}\r\n <div className={csx(\r\n \"proton-Input__container-inner\",\r\n prefix && \"proton-Input__has-prefix\",\r\n suffix && \"proton-Input__has-suffix\"\r\n )}>\r\n {prefix && (\r\n <div\r\n ref={prefixRef}\r\n className={csx(\r\n \"proton-Input__descriptor\",\r\n \"proton-Input__prefix\"\r\n )}\r\n >\r\n {prefix}\r\n </div>\r\n )}\r\n\r\n <input\r\n id={inputId}\r\n name={name}\r\n type={type}\r\n value={value}\r\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\r\n onChange?.(e.target.value);\r\n }}\r\n onKeyDown={(e: React.KeyboardEvent<HTMLInputElement>) => {\r\n switch (e.key) {\r\n case \"Enter\":\r\n if (onSubmit) {\r\n e.preventDefault();\r\n onSubmit(e);\r\n }\r\n break;\r\n case \"Escape\":\r\n if (onClear) {\r\n e.preventDefault();\r\n onClear();\r\n }\r\n break;\r\n }\r\n }}\r\n onCopy={async () =>\r\n await copyTextToClipboard(inputRef.current?.value)\r\n }\r\n disabled={isDisabled}\r\n readOnly={isReadOnly}\r\n required={isRequired}\r\n autoFocus={autoFocus}\r\n autoComplete={autoComplete ? \"on\" : \"off\"}\r\n placeholder={label ? undefined : placeholder}\r\n aria-label={label || name}\r\n aria-invalid={Boolean(error)}\r\n aria-errormessage={typeof error === \"string\" ? error : errorId}\r\n aria-required={isRequired}\r\n aria-readonly={isReadOnly}\r\n aria-describedby={\r\n error ? errorId : description ? descriptionId : undefined\r\n }\r\n aria-disabled={isDisabled}\r\n data-testid={testId}\r\n ref={ref}\r\n className={csx(\r\n \"proton-Input\",\r\n error && \"proton-Input--error\",\r\n label && \"proton-Input__label-top\",\r\n className\r\n )}\r\n />\r\n\r\n <label\r\n htmlFor={inputId}\r\n className={csx(\r\n \"proton-Input__label\",\r\n value && \"proton-Input__label--filled\"\r\n )}\r\n >\r\n {label}\r\n {isRequired && <span aria-hidden=\"true\"> *</span>}\r\n </label>\r\n\r\n {suffix && (\r\n <div\r\n ref={suffixRef}\r\n className={csx(\r\n \"proton-Input__descriptor\",\r\n \"proton-Input__suffix\"\r\n )}\r\n >\r\n {suffix}\r\n </div>\r\n )}\r\n </div>\r\n\r\n {error ? (\r\n <div\r\n role=\"alert\"\r\n className={csx(\"proton-Input__error\", \"proton-Input__text\")}\r\n id={errorId}\r\n >\r\n {error}\r\n </div>\r\n ) : description && descriptionPosition === \"bottom\" ? (\r\n <div\r\n id={descriptionId}\r\n className=\"proton-Input__text\"\r\n aria-live=\"polite\"\r\n >\r\n {description}\r\n </div>\r\n ) : null}\r\n </div>\r\n );\r\n }\r\n);\r\n\r\nInput.displayName = \"ProtonUIInput\";\r\n"],"names":["Input","forwardRef","prefix","suffix","description","descriptionPosition","isDisabled","error","onChange","label","name","placeholder","type","value","autoFocus","autoComplete","isRequired","isReadOnly","onSubmit","onClear","testId","forwardedRef","inputRef","useRef","prefixRef","suffixRef","containerRef","className","useTheme","ref","useEffect","updateSizes","containerWidth","prefixWidth","_a","suffixWidth","_b","resizeObserver","inputId","errorId","descriptionId","jsxs","jsx","csx","e","copyTextToClipboard"],"mappings":";;;;;;AAgHO,MAAMA,IAAQC;AAAA,EACnB,CACE;AAAA,IACE,QAAAC;AAAA,IACA,QAAAC;AAAA,IACA,aAAAC;AAAA,IACA,qBAAAC,IAAsB;AAAA,IACtB,YAAAC;AAAA,IACA,OAAAC;AAAA,IACA,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,MAAAC;AAAA,IACA,aAAAC;AAAA,IACA,MAAAC,IAA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A;AAAA,MAAA,IAED;AAAA,IACN,EAAA,CAAA;AAAA,EAEJ;AACF;AAEAJ,EAAM,cAAc;"}
|
|
1
|
+
{"version":3,"file":"Input.es.js","sources":["../../../../src/components/Input/BaseInput/Input.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { forwardRef, useEffect, useRef } from \"react\";\n\nimport { useTheme } from \"../../ThemeProvider\";\nimport { csx } from \"../../../utils\";\nimport \"./Input.css\";\nimport { copyTextToClipboard } from \"../../../utils/copy\";\n\nexport interface BaseInputProps {\n /**\n * onChange handler for the input\n */\n onChange?: (value: string) => void;\n\n /** Whether the input is disabled. */\n isDisabled?: boolean;\n\n /** Description text shown above the input. */\n description?: React.ReactNode | string;\n\n /**\n * The position of the description text.\n * @default \"top\"\n */\n descriptionPosition?: \"top\" | \"bottom\";\n\n /** Error state that changes the input's visual style and displays an error message. */\n error?: React.ReactNode | string;\n\n /**\n * Label for the input element.\n * @note When a label is provided, the input will have extra padding, and the label will float above the text input when focused or filled.\n */\n label?: string;\n\n /** Test ID for the component. */\n \"data-testid\"?: string;\n\n /** Content to display before the input. Typically used for icons. */\n prefix?: React.ReactNode;\n\n /** Content to display after the input. Typically used for icons. */\n suffix?: React.ReactNode;\n\n /**\n * Should the browser's autocomplete be enabled?\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete\n */\n autoComplete?: boolean;\n\n /**\n * Should the input be autofocused?\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autofocus\n */\n autoFocus?: boolean;\n\n /**\n * The name attribute of the input element.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/name\n */\n name: string;\n\n /**\n * The placeholder text to display when the input is empty.\n * @note label takes precedence over placeholder, if both are provided.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/placeholder\n */\n placeholder?: string;\n\n /**\n * The type attribute of the input element.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/type\n * @default \"text\"\n */\n type?: string;\n\n /**\n * The value of the input.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value\n */\n value?: string;\n\n /**\n * Whether the input is required.\n * @default false\n */\n isRequired?: boolean;\n\n /**\n * Whether the input is read-only.\n * @default false\n */\n isReadOnly?: boolean;\n\n /**\n * Called when the input is submitted (e.g. by pressing Enter).\n */\n onSubmit?: React.FormEventHandler<HTMLInputElement>;\n\n /**\n * Called when the input is cleared (e.g. by pressing Escape).\n */\n onClear?: () => void;\n}\n\n/**\n * A controlled and customizable input component with support for labels, prefixes, suffixes, and error states.\n *\n * API:\n * - {@link BaseInputProps}\n */\nexport const Input = forwardRef<HTMLInputElement, BaseInputProps>(\n (\n {\n prefix,\n suffix,\n description,\n descriptionPosition = \"top\",\n isDisabled,\n error,\n onChange,\n label,\n name,\n placeholder,\n type = \"text\",\n value,\n autoFocus,\n autoComplete,\n isRequired = false,\n isReadOnly = false,\n onSubmit,\n onClear,\n \"data-testid\": testId,\n },\n forwardedRef: React.RefObject<HTMLInputElement>\n ) => {\n const inputRef = useRef<HTMLInputElement>(null);\n const prefixRef = useRef<HTMLDivElement>(null);\n const suffixRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const { className } = useTheme();\n const ref = forwardedRef || inputRef;\n\n // Control dynamic prefix and suffix widths using ResizeObserver\n useEffect(() => {\n if (!containerRef.current) return;\n\n const updateSizes = () => {\n if (containerRef.current) {\n const containerWidth = containerRef.current.offsetWidth || 200;\n containerRef.current.style.setProperty(\n \"--container-width\",\n `${containerWidth}px`\n );\n }\n\n if (prefixRef.current) {\n const prefixWidth = prefixRef.current.offsetWidth || 32;\n containerRef.current?.style.setProperty(\n \"--prefix-width\",\n `${prefixWidth}px`\n );\n }\n\n if (suffixRef.current) {\n const suffixWidth = suffixRef.current.offsetWidth || 32;\n containerRef.current?.style.setProperty(\n \"--suffix-width\",\n `${suffixWidth}px`\n );\n }\n };\n\n updateSizes();\n\n const resizeObserver = new ResizeObserver(updateSizes);\n\n if (containerRef.current) {\n resizeObserver.observe(containerRef.current);\n }\n if (prefixRef.current) {\n resizeObserver.observe(prefixRef.current);\n }\n if (suffixRef.current) {\n resizeObserver.observe(suffixRef.current);\n }\n\n return () => {\n resizeObserver.disconnect();\n };\n }, [prefix, suffix]);\n\n const inputId = `${name}-input`;\n const errorId = `${name}-error`;\n const descriptionId = `${name}-description`;\n\n return (\n <div ref={containerRef}>\n {description && descriptionPosition === \"top\" && (\n <div\n id={descriptionId}\n className=\"proton-Input__text\"\n aria-live=\"polite\"\n >\n {description}\n </div>\n )}\n <div className={csx(\n \"proton-Input__container-inner\",\n prefix && \"proton-Input__has-prefix\",\n suffix && \"proton-Input__has-suffix\"\n )}>\n {prefix && (\n <div\n ref={prefixRef}\n className={csx(\n \"proton-Input__descriptor\",\n \"proton-Input__prefix\"\n )}\n >\n {prefix}\n </div>\n )}\n\n <input\n id={inputId}\n name={name}\n type={type}\n value={value}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(e.target.value);\n }}\n onKeyDown={(e: React.KeyboardEvent<HTMLInputElement>) => {\n switch (e.key) {\n case \"Enter\":\n if (onSubmit) {\n e.preventDefault();\n onSubmit(e);\n }\n break;\n case \"Escape\":\n if (onClear) {\n e.preventDefault();\n onClear();\n }\n break;\n }\n }}\n onCopy={async () =>\n await copyTextToClipboard(inputRef.current?.value)\n }\n disabled={isDisabled}\n readOnly={isReadOnly}\n required={isRequired}\n autoFocus={autoFocus}\n autoComplete={autoComplete ? \"on\" : \"off\"}\n placeholder={label ? undefined : placeholder}\n aria-label={label || name}\n aria-invalid={Boolean(error)}\n aria-errormessage={typeof error === \"string\" ? error : errorId}\n aria-required={isRequired}\n aria-readonly={isReadOnly}\n aria-describedby={\n error ? errorId : description ? descriptionId : undefined\n }\n aria-disabled={isDisabled}\n data-testid={testId}\n ref={ref}\n className={csx(\n \"proton-Input\",\n error && \"proton-Input--error\",\n label && \"proton-Input__label-top\",\n className\n )}\n />\n\n <label\n htmlFor={inputId}\n className={csx(\n \"proton-Input__label\",\n value && \"proton-Input__label--filled\"\n )}\n >\n {label}\n {isRequired && <span aria-hidden=\"true\"> *</span>}\n </label>\n\n {suffix && (\n <div\n ref={suffixRef}\n className={csx(\n \"proton-Input__descriptor\",\n \"proton-Input__suffix\"\n )}\n >\n {suffix}\n </div>\n )}\n </div>\n\n {error ? (\n <div\n role=\"alert\"\n className={csx(\"proton-Input__error\", \"proton-Input__text\")}\n id={errorId}\n >\n {error}\n </div>\n ) : description && descriptionPosition === \"bottom\" ? (\n <div\n id={descriptionId}\n className=\"proton-Input__text\"\n aria-live=\"polite\"\n >\n {description}\n </div>\n ) : null}\n </div>\n );\n }\n);\n\nInput.displayName = \"ProtonUIInput\";\n"],"names":["Input","forwardRef","prefix","suffix","description","descriptionPosition","isDisabled","error","onChange","label","name","placeholder","type","value","autoFocus","autoComplete","isRequired","isReadOnly","onSubmit","onClear","testId","forwardedRef","inputRef","useRef","prefixRef","suffixRef","containerRef","className","useTheme","ref","useEffect","updateSizes","containerWidth","prefixWidth","_a","suffixWidth","_b","resizeObserver","inputId","errorId","descriptionId","jsxs","jsx","csx","e","copyTextToClipboard"],"mappings":";;;;;;AAgHO,MAAMA,IAAQC;AAAA,EACnB,CACE;AAAA,IACE,QAAAC;AAAA,IACA,QAAAC;AAAA,IACA,aAAAC;AAAA,IACA,qBAAAC,IAAsB;AAAA,IACtB,YAAAC;AAAA,IACA,OAAAC;AAAA,IACA,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,MAAAC;AAAA,IACA,aAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,cAAAC;AAAA,IACA,YAAAC,IAAa;AAAA,IACb,YAAAC,IAAa;AAAA,IACb,UAAAC;AAAA,IACA,SAAAC;AAAA,IACA,eAAeC;AAAA,EAAA,GAEjBC,MACG;AACH,UAAMC,IAAWC,EAAyB,IAAI,GACxCC,IAAYD,EAA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sx"],"sourcesContent":["import { useState } from \"react\";\
|
|
1
|
+
{"version":3,"file":"CopyInput.cjs.js","sources":["../../../../src/components/Input/CopyInput/CopyInput.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { csx } from \"../../../utils\";\nimport { copyTextToClipboard } from \"../../../utils/copy\";\nimport { Input } from \"../BaseInput/Input\";\nimport \"./CopyInput.css\";\n\nexport interface CopyInputProps {\n /** The name of the input field */\n name: string;\n\n /** The value to display in the input and copy to clipboard */\n value: string;\n\n /** Whether the input is disabled */\n isDisabled?: boolean;\n\n /** Optional callback when copy fails, receives the error object */\n onError?: (error: Error) => void;\n\n /** Optional callback when copy succeeds */\n onSuccess?: () => void;\n}\n\n/**\n * Input with a button to copy value to the clipboard.\n *\n * API:\n * - {@link CopyInputProps}\n */\nexport function CopyInput({\n name,\n value,\n isDisabled,\n onError,\n onSuccess,\n}: CopyInputProps) {\n const [isCopied, setCopied] = useState(false);\n\n return (\n <Input\n name={name}\n value={value}\n isDisabled={isDisabled}\n suffix={\n <CopyButton\n isCopied={isCopied}\n onClick={async () => {\n const copySuccess = await copyTextToClipboard(value, onError);\n if (!copySuccess) return;\n\n setCopied(true);\n onSuccess?.();\n setTimeout(() => setCopied(false), 5000);\n }}\n />\n }\n />\n );\n}\n\nconst CopyButton = ({ isCopied, onClick }) => {\n return (\n <div className=\"proton-CopyInput-button-container\" onClick={onClick}>\n <button\n data-testid=\"COPY_BUTTON\"\n className={csx(\n \"proton-CopyInput-button\",\n isCopied && \"proton-CopyInput-button--copied\"\n )}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 512 512\"\n >\n <path\n fill=\"currentColor\"\n d=\"M408 480H184a72 72 0 0 1-72-72V184a72 72 0 0 1 72-72h224a72 72 0 0 1 72 72v224a72 72 0 0 1-72 72\"\n />\n <path\n fill=\"currentColor\"\n d=\"M160 80h235.88A72.12 72.12 0 0 0 328 32H104a72 72 0 0 0-72 72v224a72.12 72.12 0 0 0 48 67.88V160a80 80 0 0 1 80-80\"\n />\n </svg>\n <span\n className={csx(\n \"proton-CopyInput-button-text\",\n isCopied && \"proton-CopyInput-button-text--copied\"\n )}\n >\n {isCopied ? \"Copied!\" : \"Copy\"}\n </span>\n </button>\n </div>\n );\n};\n"],"names":["CopyInput","name","value","isDisabled","onError","onSuccess","isCopied","setCopied","useState","jsx","Input","CopyButton","copyTextToClipboard","onClick","jsxs","csx"],"mappings":"sUA6BO,SAASA,EAAU,CACxB,KAAAC,EACA,MAAAC,EACA,WAAAC,EACA,QAAAC,EACA,UAAAC,CACF,EAAmB,CACjB,KAAM,CAACC,EAAUC,CAAS,EAAIC,EAAAA,SAAS,EAAK,EAE5C,OACEC,EAAAA,kBAAAA,IAACC,EAAAA,MAAA,CACC,KAAAT,EACA,MAAAC,EACA,WAAAC,EACA,OACEM,EAAAA,kBAAAA,IAACE,EAAA,CACC,SAAAL,EACA,QAAS,SAAY,CACC,MAAMM,sBAAoBV,EAAOE,CAAO,IAG5DG,EAAU,EAAI,EACdF,GAAA,MAAAA,IACA,WAAW,IAAME,EAAU,EAAK,EAAG,GAAI,EACzC,CAAA,CAAA,CACF,CAAA,CAIR,CAEA,MAAMI,EAAa,CAAC,CAAE,SAAAL,EAAU,QAAAO,KAE5BJ,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,oCAAoC,QAAAI,EACjD,SAAAC,EAAAA,kBAAAA,KAAC,SAAA,CACC,cAAY,cACZ,UAAWC,EAAAA,IACT,0BACAT,GAAY,iCAAA,EAGd,SAAA,CAAAQ,EAAAA,kBAAAA,KAAC,MAAA,CACC,MAAM,6BACN,MAAM,KACN,OAAO,KACP,QAAQ,cAER,SAAA,CAAAL,EAAAA,kBAAAA,IAAC,OAAA,CACC,KAAK,eACL,EAAE,kGAAA,CAAA,EAEJA,EAAAA,kBAAAA,IAAC,OAAA,CACC,KAAK,eACL,EAAE,oHAAA,CAAA,CACJ,CAAA,CAAA,EAEFA,EAAAA,kBAAAA,IAAC,OAAA,CACC,UAAWM,EAAAA,IACT,+BACAT,GAAY,sCAAA,EAGb,WAAW,UAAY,MAAA,CAAA,CAC1B,CAAA,CAAA,EAEJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopyInput.es.js","sources":["../../../../src/components/Input/CopyInput/CopyInput.tsx"],"sourcesContent":["import { useState } from \"react\";\
|
|
1
|
+
{"version":3,"file":"CopyInput.es.js","sources":["../../../../src/components/Input/CopyInput/CopyInput.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { csx } from \"../../../utils\";\nimport { copyTextToClipboard } from \"../../../utils/copy\";\nimport { Input } from \"../BaseInput/Input\";\nimport \"./CopyInput.css\";\n\nexport interface CopyInputProps {\n /** The name of the input field */\n name: string;\n\n /** The value to display in the input and copy to clipboard */\n value: string;\n\n /** Whether the input is disabled */\n isDisabled?: boolean;\n\n /** Optional callback when copy fails, receives the error object */\n onError?: (error: Error) => void;\n\n /** Optional callback when copy succeeds */\n onSuccess?: () => void;\n}\n\n/**\n * Input with a button to copy value to the clipboard.\n *\n * API:\n * - {@link CopyInputProps}\n */\nexport function CopyInput({\n name,\n value,\n isDisabled,\n onError,\n onSuccess,\n}: CopyInputProps) {\n const [isCopied, setCopied] = useState(false);\n\n return (\n <Input\n name={name}\n value={value}\n isDisabled={isDisabled}\n suffix={\n <CopyButton\n isCopied={isCopied}\n onClick={async () => {\n const copySuccess = await copyTextToClipboard(value, onError);\n if (!copySuccess) return;\n\n setCopied(true);\n onSuccess?.();\n setTimeout(() => setCopied(false), 5000);\n }}\n />\n }\n />\n );\n}\n\nconst CopyButton = ({ isCopied, onClick }) => {\n return (\n <div className=\"proton-CopyInput-button-container\" onClick={onClick}>\n <button\n data-testid=\"COPY_BUTTON\"\n className={csx(\n \"proton-CopyInput-button\",\n isCopied && \"proton-CopyInput-button--copied\"\n )}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 512 512\"\n >\n <path\n fill=\"currentColor\"\n d=\"M408 480H184a72 72 0 0 1-72-72V184a72 72 0 0 1 72-72h224a72 72 0 0 1 72 72v224a72 72 0 0 1-72 72\"\n />\n <path\n fill=\"currentColor\"\n d=\"M160 80h235.88A72.12 72.12 0 0 0 328 32H104a72 72 0 0 0-72 72v224a72.12 72.12 0 0 0 48 67.88V160a80 80 0 0 1 80-80\"\n />\n </svg>\n <span\n className={csx(\n \"proton-CopyInput-button-text\",\n isCopied && \"proton-CopyInput-button-text--copied\"\n )}\n >\n {isCopied ? \"Copied!\" : \"Copy\"}\n </span>\n </button>\n </div>\n );\n};\n"],"names":["CopyInput","name","value","isDisabled","onError","onSuccess","isCopied","setCopied","useState","jsx","Input","CopyButton","copyTextToClipboard","onClick","jsxs","csx"],"mappings":";;;;;;AA6BO,SAASA,EAAU;AAAA,EACxB,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC;AACF,GAAmB;AACjB,QAAM,CAACC,GAAUC,CAAS,IAAIC,EAAS,EAAK;AAE5C,SACEC,gBAAAA,EAAAA;AAAAA,IAACC;AAAA,IAAA;AAAA,MACC,MAAAT;AAAA,MACA,OAAAC;AAAA,MACA,YAAAC;AAAA,MACA,QACEM,gBAAAA,EAAAA;AAAAA,QAACE;AAAA,QAAA;AAAA,UACC,UAAAL;AAAA,UACA,SAAS,YAAY;AAEnB,YADoB,MAAMM,EAAoBV,GAAOE,CAAO,MAG5DG,EAAU,EAAI,GACdF,KAAA,QAAAA,KACA,WAAW,MAAME,EAAU,EAAK,GAAG,GAAI;AAAA,UACzC;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAIR;AAEA,MAAMI,IAAa,CAAC,EAAE,UAAAL,GAAU,SAAAO,QAE5BJ,gBAAAA,EAAAA,IAAC,OAAA,EAAI,WAAU,qCAAoC,SAAAI,GACjD,UAAAC,gBAAAA,EAAAA;AAAAA,EAAC;AAAA,EAAA;AAAA,IACC,eAAY;AAAA,IACZ,WAAWC;AAAA,MACT;AAAA,MACAT,KAAY;AAAA,IAAA;AAAA,IAGd,UAAA;AAAA,MAAAQ,gBAAAA,EAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,OAAM;AAAA,UACN,OAAM;AAAA,UACN,QAAO;AAAA,UACP,SAAQ;AAAA,UAER,UAAA;AAAA,YAAAL,gBAAAA,EAAAA;AAAAA,cAAC;AAAA,cAAA;AAAA,gBACC,MAAK;AAAA,gBACL,GAAE;AAAA,cAAA;AAAA,YAAA;AAAA,YAEJA,gBAAAA,EAAAA;AAAAA,cAAC;AAAA,cAAA;AAAA,gBACC,MAAK;AAAA,gBACL,GAAE;AAAA,cAAA;AAAA,YAAA;AAAA,UACJ;AAAA,QAAA;AAAA,MAAA;AAAA,MAEFA,gBAAAA,EAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAWM;AAAA,YACT;AAAA,YACAT,KAAY;AAAA,UAAA;AAAA,UAGb,cAAW,YAAY;AAAA,QAAA;AAAA,MAAA;AAAA,IAC1B;AAAA,EAAA;AAAA,GAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchInput.cjs.js","sources":["../../../../src/components/Input/SearchInput/SearchInput.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"SearchInput.cjs.js","sources":["../../../../src/components/Input/SearchInput/SearchInput.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport \"./SearchInput.css\";\nimport { csx } from \"../../../utils\";\nimport { Input, type BaseInputProps } from \"../BaseInput/Input\";\n\nexport interface SearchInputProps\n extends Omit<\n BaseInputProps,\n | \"prefix\"\n | \"suffix\"\n | \"value\"\n | \"onChange\"\n | \"description\"\n | \"descriptionPosition\"\n | \"label\"\n > {\n /** The initial value of the input. */\n defaultValue?: string;\n\n /** Should the clear button be shown when there is text? */\n isClearable?: boolean;\n\n /** Called when the input value changes. */\n onChange?: (value: string) => void;\n\n /** Called when the clear button is clicked. */\n onClear?: () => void;\n\n /** The current value of the input (for controlled usage) */\n value?: string;\n}\n\n/**\n * A search input component with optional clear functionality and URL parameter sync.\n *\n * API:\n * - {@link SearchInputProps}\n * - extends {@link BaseInputProps}\n */\nexport const SearchInput = ({\n name = \"search\",\n placeholder = \"Search...\",\n autoComplete,\n isClearable = true,\n isDisabled = false,\n error,\n defaultValue,\n value: controlledValue,\n \"data-testid\": testId = \"proton-SearchInput\",\n onChange,\n onClear,\n}: SearchInputProps) => {\n const inputRef = useRef<HTMLInputElement>(null);\n const [value, setValue] = useState(controlledValue ?? defaultValue ?? \"\");\n\n // Sync with controlled value if provided\n useEffect(() => {\n if (controlledValue !== undefined) {\n setValue(controlledValue);\n }\n }, [controlledValue]);\n\n const handleChange = (newValue: string) => {\n setValue(newValue);\n onChange?.(newValue);\n };\n\n const handleClear = () => {\n setValue(\"\");\n onChange?.(\"\");\n onClear?.();\n inputRef.current?.focus();\n };\n\n return (\n <div\n className=\"proton-SearchInput__wrapper\"\n data-testid={testId}\n role=\"search\"\n >\n <Input\n type=\"search\"\n onChange={handleChange}\n value={value}\n name={name}\n placeholder={placeholder}\n autoComplete={autoComplete}\n error={error}\n ref={inputRef}\n isDisabled={isDisabled}\n prefix={\n <svg\n aria-hidden=\"true\"\n width=\"2.8em\"\n height=\"1.6em\"\n viewBox=\"0 0 24 24\"\n onClick={() => inputRef.current?.focus()}\n >\n <title>Magnifying Glass</title>\n <path\n fill=\"currentColor\"\n d=\"M10.5 18.5a8 8 0 1 1 0-16 8 8 0 0 1 0 16Zm0-1a7 7 0 1 0 0-14 7 7 0 0 0 0 14Zm5.25-.75 4.5 4.5-1.25 1.25-4.5-4.5 1.25-1.25Z\"\n />\n </svg>\n }\n suffix={\n isClearable && value.length > 0 ? (\n <button\n type=\"button\"\n className={csx(\n \"proton-SearchInput__button\",\n \"proton-Input__descriptor\",\n \"proton-Input__suffix\"\n )}\n data-testid={`${testId}-clear`}\n onClick={handleClear}\n aria-label=\"Clear search\"\n >\n <svg\n aria-hidden=\"true\"\n viewBox=\"0 0 50 50\"\n width=\"2.2em\"\n height=\"1.2em\"\n >\n <title>Clear</title>\n <path\n fill=\"currentColor\"\n d=\"m37.304 11.282l1.414 1.414l-26.022 26.02l-1.414-1.413z\"\n />\n <path\n fill=\"currentColor\"\n d=\"m12.696 11.282l26.022 26.02l-1.414 1.415l-26.022-26.02z\"\n />\n </svg>\n </button>\n ) : null\n }\n />\n </div>\n );\n};\n"],"names":["SearchInput","name","placeholder","autoComplete","isClearable","isDisabled","error","defaultValue","controlledValue","testId","onChange","onClear","inputRef","useRef","value","setValue","useState","useEffect","handleChange","newValue","handleClear","_a","jsx","Input","jsxs","csx"],"mappings":"gSAyCaA,EAAc,CAAC,CAC1B,KAAAC,EAAO,SACP,YAAAC,EAAc,YACd,aAAAC,EACA,YAAAC,EAAc,GACd,WAAAC,EAAa,GACb,MAAAC,EACA,aAAAC,EACA,MAAOC,EACP,cAAeC,EAAS,qBACxB,SAAAC,EACA,QAAAC,CACF,IAAwB,CACtB,MAAMC,EAAWC,EAAAA,OAAyB,IAAI,EACxC,CAACC,EAAOC,CAAQ,EAAIC,EAAAA,SAASR,GAAmBD,GAAgB,EAAE,EAGxEU,EAAAA,UAAU,IAAM,CACVT,IAAoB,QACtBO,EAASP,CAAe,CAE5B,EAAG,CAACA,CAAe,CAAC,EAEpB,MAAMU,EAAgBC,GAAqB,CACzCJ,EAASI,CAAQ,EACjBT,GAAA,MAAAA,EAAWS,EACb,EAEMC,EAAc,IAAM,OACxBL,EAAS,EAAE,EACXL,GAAA,MAAAA,EAAW,IACXC,GAAA,MAAAA,KACAU,EAAAT,EAAS,UAAT,MAAAS,EAAkB,OACpB,EAEA,OACEC,EAAAA,kBAAAA,IAAC,MAAA,CACC,UAAU,8BACV,cAAab,EACb,KAAK,SAEL,SAAAa,EAAAA,kBAAAA,IAACC,EAAAA,MAAA,CACC,KAAK,SACL,SAAUL,EACV,MAAAJ,EACA,KAAAb,EACA,YAAAC,EACA,aAAAC,EACA,MAAAG,EACA,IAAKM,EACL,WAAAP,EACA,OACEmB,EAAAA,kBAAAA,KAAC,MAAA,CACC,cAAY,OACZ,MAAM,QACN,OAAO,QACP,QAAQ,YACR,QAAS,IAAA,OAAM,OAAAH,EAAAT,EAAS,UAAT,YAAAS,EAAkB,SAEjC,SAAA,CAAAC,EAAAA,kBAAAA,IAAC,SAAM,SAAA,kBAAA,CAAgB,EACvBA,EAAAA,kBAAAA,IAAC,OAAA,CACC,KAAK,eACL,EAAE,4HAAA,CAAA,CACJ,CAAA,CAAA,EAGJ,OACElB,GAAeU,EAAM,OAAS,EAC5BQ,EAAAA,kBAAAA,IAAC,SAAA,CACC,KAAK,SACL,UAAWG,EAAAA,IACT,6BACA,2BACA,sBAAA,EAEF,cAAa,GAAGhB,CAAM,SACtB,QAASW,EACT,aAAW,eAEX,SAAAI,EAAAA,kBAAAA,KAAC,MAAA,CACC,cAAY,OACZ,QAAQ,YACR,MAAM,QACN,OAAO,QAEP,SAAA,CAAAF,EAAAA,kBAAAA,IAAC,SAAM,SAAA,OAAA,CAAK,EACZA,EAAAA,kBAAAA,IAAC,OAAA,CACC,KAAK,eACL,EAAE,wDAAA,CAAA,EAEJA,EAAAA,kBAAAA,IAAC,OAAA,CACC,KAAK,eACL,EAAE,yDAAA,CAAA,CACJ,CAAA,CAAA,CACF,CAAA,EAEA,IAAA,CAAA,CAER,CAAA,CAGN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchInput.es.js","sources":["../../../../src/components/Input/SearchInput/SearchInput.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"SearchInput.es.js","sources":["../../../../src/components/Input/SearchInput/SearchInput.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport \"./SearchInput.css\";\nimport { csx } from \"../../../utils\";\nimport { Input, type BaseInputProps } from \"../BaseInput/Input\";\n\nexport interface SearchInputProps\n extends Omit<\n BaseInputProps,\n | \"prefix\"\n | \"suffix\"\n | \"value\"\n | \"onChange\"\n | \"description\"\n | \"descriptionPosition\"\n | \"label\"\n > {\n /** The initial value of the input. */\n defaultValue?: string;\n\n /** Should the clear button be shown when there is text? */\n isClearable?: boolean;\n\n /** Called when the input value changes. */\n onChange?: (value: string) => void;\n\n /** Called when the clear button is clicked. */\n onClear?: () => void;\n\n /** The current value of the input (for controlled usage) */\n value?: string;\n}\n\n/**\n * A search input component with optional clear functionality and URL parameter sync.\n *\n * API:\n * - {@link SearchInputProps}\n * - extends {@link BaseInputProps}\n */\nexport const SearchInput = ({\n name = \"search\",\n placeholder = \"Search...\",\n autoComplete,\n isClearable = true,\n isDisabled = false,\n error,\n defaultValue,\n value: controlledValue,\n \"data-testid\": testId = \"proton-SearchInput\",\n onChange,\n onClear,\n}: SearchInputProps) => {\n const inputRef = useRef<HTMLInputElement>(null);\n const [value, setValue] = useState(controlledValue ?? defaultValue ?? \"\");\n\n // Sync with controlled value if provided\n useEffect(() => {\n if (controlledValue !== undefined) {\n setValue(controlledValue);\n }\n }, [controlledValue]);\n\n const handleChange = (newValue: string) => {\n setValue(newValue);\n onChange?.(newValue);\n };\n\n const handleClear = () => {\n setValue(\"\");\n onChange?.(\"\");\n onClear?.();\n inputRef.current?.focus();\n };\n\n return (\n <div\n className=\"proton-SearchInput__wrapper\"\n data-testid={testId}\n role=\"search\"\n >\n <Input\n type=\"search\"\n onChange={handleChange}\n value={value}\n name={name}\n placeholder={placeholder}\n autoComplete={autoComplete}\n error={error}\n ref={inputRef}\n isDisabled={isDisabled}\n prefix={\n <svg\n aria-hidden=\"true\"\n width=\"2.8em\"\n height=\"1.6em\"\n viewBox=\"0 0 24 24\"\n onClick={() => inputRef.current?.focus()}\n >\n <title>Magnifying Glass</title>\n <path\n fill=\"currentColor\"\n d=\"M10.5 18.5a8 8 0 1 1 0-16 8 8 0 0 1 0 16Zm0-1a7 7 0 1 0 0-14 7 7 0 0 0 0 14Zm5.25-.75 4.5 4.5-1.25 1.25-4.5-4.5 1.25-1.25Z\"\n />\n </svg>\n }\n suffix={\n isClearable && value.length > 0 ? (\n <button\n type=\"button\"\n className={csx(\n \"proton-SearchInput__button\",\n \"proton-Input__descriptor\",\n \"proton-Input__suffix\"\n )}\n data-testid={`${testId}-clear`}\n onClick={handleClear}\n aria-label=\"Clear search\"\n >\n <svg\n aria-hidden=\"true\"\n viewBox=\"0 0 50 50\"\n width=\"2.2em\"\n height=\"1.2em\"\n >\n <title>Clear</title>\n <path\n fill=\"currentColor\"\n d=\"m37.304 11.282l1.414 1.414l-26.022 26.02l-1.414-1.413z\"\n />\n <path\n fill=\"currentColor\"\n d=\"m12.696 11.282l26.022 26.02l-1.414 1.415l-26.022-26.02z\"\n />\n </svg>\n </button>\n ) : null\n }\n />\n </div>\n );\n};\n"],"names":["SearchInput","name","placeholder","autoComplete","isClearable","isDisabled","error","defaultValue","controlledValue","testId","onChange","onClear","inputRef","useRef","value","setValue","useState","useEffect","handleChange","newValue","handleClear","_a","jsx","Input","jsxs","csx"],"mappings":";;;;;AAyCO,MAAMA,IAAc,CAAC;AAAA,EAC1B,MAAAC,IAAO;AAAA,EACP,aAAAC,IAAc;AAAA,EACd,cAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,YAAAC,IAAa;AAAA,EACb,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,OAAOC;AAAA,EACP,eAAeC,IAAS;AAAA,EACxB,UAAAC;AAAA,EACA,SAAAC;AACF,MAAwB;AACtB,QAAMC,IAAWC,EAAyB,IAAI,GACxC,CAACC,GAAOC,CAAQ,IAAIC,EAASR,KAAmBD,KAAgB,EAAE;AAGxE,EAAAU,EAAU,MAAM;AACd,IAAIT,MAAoB,UACtBO,EAASP,CAAe;AAAA,EAE5B,GAAG,CAACA,CAAe,CAAC;AAEpB,QAAMU,IAAe,CAACC,MAA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