@atom-learning/components 10.0.0 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/accordion/Accordion.js +1 -1
- package/dist/components/accordion/AccordionContent.js +1 -1
- package/dist/components/accordion/AccordionItem.js +1 -1
- package/dist/components/accordion/AccordionTrigger.js +2 -2
- package/dist/components/action-icon/ActionIcon.js +2 -2
- package/dist/components/action-icon/ActionIcon.js.map +1 -1
- package/dist/components/alert-dialog/Alert.d.ts +3 -0
- package/dist/components/alert-dialog/Alert.js +7 -0
- package/dist/components/alert-dialog/Alert.js.map +1 -0
- package/dist/components/alert-dialog/alert-context/AlertDialog.js +1 -1
- package/dist/components/badge/BadgeText.js +1 -1
- package/dist/components/badge/BadgeText.js.map +1 -1
- package/dist/components/banner/BannerContainer.js.map +1 -1
- package/dist/components/banner/banner-regular/BannerRegularActions.js +1 -1
- package/dist/components/banner/banner-regular/BannerRegularActions.js.map +1 -1
- package/dist/components/calendar/Calendar.js +4 -4
- package/dist/components/calendar/Calendar.js.map +1 -1
- package/dist/components/carousel/Carousel.js.map +1 -1
- package/dist/components/checkbox-group/CheckboxGroup.d.ts +1 -1
- package/dist/components/checkbox-group/CheckboxGroupAllItem.js +3 -2
- package/dist/components/checkbox-group/CheckboxGroupAllItem.js.map +1 -1
- package/dist/components/checkbox-group/CheckboxGroupChecked.context.js +1 -1
- package/dist/components/checkbox-group/CheckboxGroupChecked.context.js.map +1 -1
- package/dist/components/checkbox-group/CheckboxGroupMounted.context.js +1 -1
- package/dist/components/checkbox-group/CheckboxGroupMounted.context.js.map +1 -1
- package/dist/components/chip/Chip.js +2 -2
- package/dist/components/chip/Chip.js.map +1 -1
- package/dist/components/create-password-field/CreatePasswordField.js +5 -5
- package/dist/components/create-password-field/CreatePasswordField.js.map +1 -1
- package/dist/components/data-table/DataTableBulkActionsFloating.js +1 -1
- package/dist/components/data-table/DataTableHeaderCell.js +9 -9
- package/dist/components/data-table/DataTableHeaderCell.js.map +1 -1
- package/dist/components/data-table/DataTableSelectAllRowsCheckbox.js.map +1 -1
- package/dist/components/data-table/getNewAsyncData.js +1 -1
- package/dist/components/data-table/getNewAsyncData.js.map +1 -1
- package/dist/components/date-input/DateInput.js.map +1 -1
- package/dist/components/file-drop/FileDrop.js +2 -2
- package/dist/components/file-drop/FileDrop.js.map +1 -1
- package/dist/components/file-input/FileInput.js +1 -1
- package/dist/components/form/useFieldError.js +2 -1
- package/dist/components/form/useFieldError.js.map +1 -1
- package/dist/components/index.d.ts +1 -3
- package/dist/components/inline-message/InlineMessage.js +1 -1
- package/dist/components/markdown-content/MarkdownContent.js +5 -5
- package/dist/components/markdown-content/MarkdownContent.js.map +1 -1
- package/dist/components/markdown-content/components/MarkdownEmphasis.d.ts +2 -2
- package/dist/components/markdown-content/components/MarkdownEmphasis.js.map +1 -1
- package/dist/components/markdown-content/components/MarkdownHeading.d.ts +2 -2
- package/dist/components/markdown-content/components/MarkdownHeading.js.map +1 -1
- package/dist/components/markdown-content/components/MarkdownLink.d.ts +2 -2
- package/dist/components/markdown-content/components/MarkdownLink.js.map +1 -1
- package/dist/components/markdown-content/components/MarkdownList.d.ts +2 -2
- package/dist/components/markdown-content/components/MarkdownList.js.map +1 -1
- package/dist/components/markdown-content/components/MarkdownListItem.d.ts +2 -2
- package/dist/components/markdown-content/components/MarkdownListItem.js.map +1 -1
- package/dist/components/markdown-content/components/MarkdownParagraph.d.ts +2 -2
- package/dist/components/markdown-content/components/MarkdownParagraph.js.map +1 -1
- package/dist/components/markdown-content/components/MarkdownStrong.d.ts +2 -2
- package/dist/components/markdown-content/components/MarkdownStrong.js.map +1 -1
- package/dist/components/navigation/NavigationMenu.js +1 -1
- package/dist/components/navigation/NavigationMenu.js.map +1 -1
- package/dist/components/pagination/PaginationItems.js +2 -2
- package/dist/components/pagination/PaginationItems.js.map +1 -1
- package/dist/components/pagination/pagination.helper.js +5 -3
- package/dist/components/pagination/pagination.helper.js.map +1 -1
- package/dist/components/select-menu/SelectMenu.d.ts +16 -9
- package/dist/components/select-menu/SelectMenu.js +6 -4
- package/dist/components/select-menu/SelectMenu.js.map +1 -1
- package/dist/components/select-menu/SelectMenuContent.d.ts +5 -3
- package/dist/components/select-menu/SelectMenuContent.js +24 -65
- package/dist/components/select-menu/SelectMenuContent.js.map +1 -1
- package/dist/components/select-menu/SelectMenuItem.d.ts +5 -3
- package/dist/components/select-menu/SelectMenuItem.js +15 -15
- package/dist/components/select-menu/SelectMenuItem.js.map +1 -1
- package/dist/components/select-menu/SelectMenuLabel.d.ts +2 -2
- package/dist/components/select-menu/SelectMenuLabel.js +2 -2
- package/dist/components/select-menu/SelectMenuLabel.js.map +1 -1
- package/dist/components/select-menu/SelectMenuSeparator.d.ts +2 -2
- package/dist/components/select-menu/SelectMenuSeparator.js +2 -2
- package/dist/components/select-menu/SelectMenuSeparator.js.map +1 -1
- package/dist/components/select-menu/SelectMenuTrigger.d.ts +3 -2
- package/dist/components/select-menu/SelectMenuTrigger.js +12 -12
- package/dist/components/select-menu/SelectMenuTrigger.js.map +1 -1
- package/dist/components/select-menu-field/SelectMenuField.js +5 -5
- package/dist/components/select-menu-field/SelectMenuField.js.map +1 -1
- package/dist/components/slider/Slider.js.map +1 -1
- package/dist/components/slider-field/SliderField.js +2 -1
- package/dist/components/slider-field/SliderField.js.map +1 -1
- package/dist/components/stepper/Stepper.js +1 -1
- package/dist/components/stepper/Stepper.js.map +1 -1
- package/dist/components/stepper/StepperSteps.js +7 -5
- package/dist/components/stepper/StepperSteps.js.map +1 -1
- package/dist/components/table/useStickyColumnsCss.js +1 -1
- package/dist/components/table/useStickyColumnsCss.js.map +1 -1
- package/dist/components/tabs/TabsTriggerList.js +1 -1
- package/dist/docgen.json +1 -1
- package/dist/index.cjs.js +872 -903
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +7 -7
- package/dist/styled.js +15 -11
- package/dist/styled.js.map +1 -1
- package/dist/utilities/hooks/useResizeObserver.js +1 -3
- package/dist/utilities/hooks/useResizeObserver.js.map +1 -1
- package/dist/utilities/uri/index.js +2 -1
- package/dist/utilities/uri/index.js.map +1 -1
- package/package.json +25 -11
- package/dist/components/index.js +0 -102
- package/dist/components/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTableHeaderCell.js","names":[],"sources":["../../../src/components/data-table/DataTableHeaderCell.tsx"],"sourcesContent":["import { ArrowDown, ArrowUp } from '@atom-learning/icons'\nimport type { Header } from '@tanstack/react-table'\nimport { flexRender } from '@tanstack/react-table'\nimport * as React from 'react'\nimport { useHover } from 'react-aria'\n\nimport { styled, cn } from '../../styled'\nimport { Icon } from '../icon/Icon'\nimport { Table } from '../table/Table'\nimport { Text } from '../text/Text'\nimport { useDataTable } from './DataTable.context'\n\ntype DataTableHeaderProps = React.ComponentProps<typeof Table.HeaderCell> & {\n header: Header<Record<string, unknown>, unknown>\n includeTotal?: boolean\n totalSuffix?: string\n}\n\nconst StyledCount = styled(Text, {\n base: ['text-grey-600', 'whitespace-nowrap', 'hidden', 'min-[800px]:block']\n})\n\nconst StyledTableHeaderCell = styled(Table.HeaderCell, {\n base: [],\n variants: {\n isSortable: {\n true: [\n '*:relative',\n 'before:absolute',\n 'before:bg-primary-100',\n 'before:duration-200',\n 'before:ease-in',\n 'before:inset-0',\n 'before:opacity-0',\n 'before:transition-opacity',\n 'cursor-pointer',\n 'hover:before:opacity-50',\n 'relative'\n ]\n }\n }\n})\n\nconst sortIcons = {\n asc: ArrowUp,\n desc: ArrowDown\n}\n\nconst SortIcon = ({ direction }: { direction: 'asc' | 'desc' }) => (\n <Icon\n is={sortIcons[direction]}\n size=\"sm\"\n className=\"stroke-primary-900 absolute left-1\"\n />\n)\n\nexport const DataTableHeaderCell = ({\n header,\n includeTotal = false,\n totalSuffix = 'items',\n children,\n className,\n ...rest\n}: DataTableHeaderProps) => {\n const sortDirection = header.column.getIsSorted()\n const { isSortable: isSortableTable, getRowModel } = useDataTable()\n // false for display columns, e.g. \"Actions\"\n const isDataColumn = header.column.getCanSort()\n\n const totalRows = getRowModel()?.rows?.length\n\n const { hoverProps, isHovered } = useHover({})\n\n const
|
|
1
|
+
{"version":3,"file":"DataTableHeaderCell.js","names":[],"sources":["../../../src/components/data-table/DataTableHeaderCell.tsx"],"sourcesContent":["import { ArrowDown, ArrowUp } from '@atom-learning/icons'\nimport type { Header } from '@tanstack/react-table'\nimport { flexRender } from '@tanstack/react-table'\nimport * as React from 'react'\nimport { useHover } from 'react-aria'\n\nimport { styled, cn } from '../../styled'\nimport { Icon } from '../icon/Icon'\nimport { Table } from '../table/Table'\nimport { Text } from '../text/Text'\nimport { useDataTable } from './DataTable.context'\n\ntype DataTableHeaderProps = React.ComponentProps<typeof Table.HeaderCell> & {\n header: Header<Record<string, unknown>, unknown>\n includeTotal?: boolean\n totalSuffix?: string\n}\n\nconst StyledCount = styled(Text, {\n base: ['text-grey-600', 'whitespace-nowrap', 'hidden', 'min-[800px]:block']\n})\n\nconst StyledTableHeaderCell = styled(Table.HeaderCell, {\n base: [],\n variants: {\n isSortable: {\n true: [\n '*:relative',\n 'before:absolute',\n 'before:bg-primary-100',\n 'before:duration-200',\n 'before:ease-in',\n 'before:inset-0',\n 'before:opacity-0',\n 'before:transition-opacity',\n 'cursor-pointer',\n 'hover:before:opacity-50',\n 'relative'\n ]\n }\n }\n})\n\nconst sortIcons = {\n asc: ArrowUp,\n desc: ArrowDown\n}\n\nconst SortIcon = ({ direction }: { direction: 'asc' | 'desc' }) => (\n <Icon\n is={sortIcons[direction]}\n size=\"sm\"\n className=\"stroke-primary-900 absolute left-1\"\n />\n)\n\nconst handleKeyDown = (\n event: React.KeyboardEvent<HTMLTableCellElement>,\n callback: (event: unknown) => void | undefined\n) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault()\n callback(event as unknown)\n }\n}\n\nexport const DataTableHeaderCell = ({\n header,\n includeTotal = false,\n totalSuffix = 'items',\n children,\n className,\n ...rest\n}: DataTableHeaderProps) => {\n const sortDirection = header.column.getIsSorted()\n const { isSortable: isSortableTable, getRowModel } = useDataTable()\n // false for display columns, e.g. \"Actions\"\n const isDataColumn = header.column.getCanSort()\n\n const totalRows = getRowModel()?.rows?.length\n\n const { hoverProps, isHovered } = useHover({})\n\n const headerSortingHandler = header.column.getToggleSortingHandler()\n\n return (\n <StyledTableHeaderCell\n isSortable={isSortableTable && isDataColumn}\n colSpan={header.colSpan}\n onClick={\n isSortableTable && isDataColumn && headerSortingHandler\n ? headerSortingHandler\n : undefined\n }\n onKeyDown={(event) =>\n isSortableTable &&\n isDataColumn &&\n headerSortingHandler &&\n handleKeyDown(event, headerSortingHandler)\n }\n tabIndex={isSortableTable && isDataColumn ? 0 : -1}\n {...hoverProps}\n className={className}\n {...rest}\n >\n <div\n className={cn(\n 'flex',\n 'gap-1',\n 'items-center',\n header.colSpan > 1 ? 'justify-center' : 'justify-start'\n )}\n >\n {flexRender(header.column.columnDef.header, header.getContext())}\n {sortDirection && isSortableTable && (\n <div\n className={cn(\n 'flex',\n 'items-center',\n 'relative',\n 'size-6',\n 'ml-2',\n isHovered ? 'bg-primary-200' : 'bg-primary-100',\n 'rounded-sm'\n )}\n >\n <SortIcon direction={sortDirection} />\n </div>\n )}\n {includeTotal ? (\n <StyledCount size=\"sm\" weight=\"normal\">\n ({totalRows} {totalSuffix})\n </StyledCount>\n ) : null}\n </div>\n </StyledTableHeaderCell>\n )\n}\n"],"mappings":";;;;;;;;;;;AAkBA,IAAM,cAAc,OAAO,MAAM,EAC/B,MAAM;CAAC;CAAiB;CAAqB;CAAU;AAAmB,EAC5E,CAAC;AAED,IAAM,wBAAwB,OAAO,MAAM,YAAY;CACrD,MAAM,CAAC;CACP,UAAU,EACR,YAAY,EACV,MAAM;EACJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,EACF,EACF;AACF,CAAC;AAED,IAAM,YAAY;CAChB,KAAK;CACL,MAAM;AACR;AAEA,IAAM,YAAY,EAAE,gBAClB,oBAAC,MAAD;CACE,IAAI,UAAU;CACd,MAAK;CACL,WAAU;AACX,CAAA;AAGH,IAAM,iBACJ,OACA,aACG;CACH,IAAI,MAAM,QAAQ,WAAW,MAAM,QAAQ,KAAK;EAC9C,MAAM,eAAe;EACrB,SAAS,KAAgB;CAC3B;AACF;AAEA,IAAa,uBAAuB,EAClC,QACA,eAAe,OACf,cAAc,SACd,UACA,WACA,GAAG,WACuB;CAC1B,MAAM,gBAAgB,OAAO,OAAO,YAAY;CAChD,MAAM,EAAE,YAAY,iBAAiB,gBAAgB,aAAa;CAElE,MAAM,eAAe,OAAO,OAAO,WAAW;CAE9C,MAAM,YAAY,YAAY,CAAC,EAAE,MAAM;CAEvC,MAAM,EAAE,YAAY,cAAc,SAAS,CAAC,CAAC;CAE7C,MAAM,uBAAuB,OAAO,OAAO,wBAAwB;CAEnE,OACE,oBAAC,uBAAD;EACE,YAAY,mBAAmB;EAC/B,SAAS,OAAO;EAChB,SACE,mBAAmB,gBAAgB,uBAC/B,uBACA,KAAA;EAEN,YAAY,UACV,mBACA,gBACA,wBACA,cAAc,OAAO,oBAAoB;EAE3C,UAAU,mBAAmB,eAAe,IAAI;EAChD,GAAI;EACO;EACX,GAAI;YAEJ,qBAAC,OAAD;GACE,WAAW,GACT,QACA,SACA,gBACA,OAAO,UAAU,IAAI,mBAAmB,eAC1C;aANF;IAQG,WAAW,OAAO,OAAO,UAAU,QAAQ,OAAO,WAAW,CAAC;IAC9D,iBAAiB,mBAChB,oBAAC,OAAD;KACE,WAAW,GACT,QACA,gBACA,YACA,UACA,QACA,YAAY,mBAAmB,kBAC/B,YACF;eAEA,oBAAC,UAAD,EAAU,WAAW,cAAgB,CAAA;IAClC,CAAA;IAEN,eACC,qBAAC,aAAD;KAAa,MAAK;KAAK,QAAO;eAA9B;MAAuC;MACnC;MAAU;MAAE;MAAY;KACf;SACX;GACD;;CACgB,CAAA;AAE3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTableSelectAllRowsCheckbox.js","names":[],"sources":["../../../src/components/data-table/DataTableSelectAllRowsCheckbox.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { Checkbox } from '../checkbox/Checkbox'\nimport {
|
|
1
|
+
{"version":3,"file":"DataTableSelectAllRowsCheckbox.js","names":[],"sources":["../../../src/components/data-table/DataTableSelectAllRowsCheckbox.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { Checkbox } from '../checkbox/Checkbox'\nimport { useDataTable } from './DataTable.context'\n\nexport const DataTableSelectAllRowsCheckbox = ({\n label = 'All rows selection'\n}: {\n label?: string\n}) => {\n const {\n getIsAllPageRowsSelected,\n getIsSomePageRowsSelected,\n toggleAllPageRowsSelected,\n tableId\n } = useDataTable()\n\n const getCheckedState = () => {\n if (getIsSomePageRowsSelected()) return 'indeterminate'\n if (getIsAllPageRowsSelected()) return true\n return false\n }\n\n const updateCheckedState = () => {\n if (getIsSomePageRowsSelected()) {\n return toggleAllPageRowsSelected(false)\n }\n return toggleAllPageRowsSelected(!getIsAllPageRowsSelected())\n }\n\n return (\n <>\n <label htmlFor={`${tableId}_all_rows_selection`} className=\"sr-only\">\n {label}\n </label>\n <Checkbox\n size=\"lg\"\n checked={getCheckedState()}\n onCheckedChange={updateCheckedState}\n id={`${tableId}_all_rows_selection`}\n name={`${tableId}_all_rows_selection`}\n />\n </>\n )\n}\n"],"mappings":";;;;;AAKA,IAAa,kCAAkC,EAC7C,QAAQ,2BAGJ;CACJ,MAAM,EACJ,0BACA,2BACA,2BACA,YACE,aAAa;CAEjB,MAAM,wBAAwB;EAC5B,IAAI,0BAA0B,GAAG,OAAO;EACxC,IAAI,yBAAyB,GAAG,OAAO;EACvC,OAAO;CACT;CAEA,MAAM,2BAA2B;EAC/B,IAAI,0BAA0B,GAC5B,OAAO,0BAA0B,KAAK;EAExC,OAAO,0BAA0B,CAAC,yBAAyB,CAAC;CAC9D;CAEA,OACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,SAAD;EAAO,SAAS,GAAG,QAAQ;EAAsB,WAAU;YACxD;CACI,CAAA,GACP,oBAAC,UAAD;EACE,MAAK;EACL,SAAS,gBAAgB;EACzB,iBAAiB;EACjB,IAAI,GAAG,QAAQ;EACf,MAAM,GAAG,QAAQ;CAClB,CAAA,CACD,EAAA,CAAA;AAEN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNewAsyncData.js","names":[],"sources":["../../../src/components/data-table/getNewAsyncData.ts"],"sourcesContent":["import type {\n PaginationState,\n SortDirection,\n SortingState\n} from '@tanstack/react-table'\nimport invariant from 'invariant'\n\nimport type {\n AsyncDataOptions,\n AsyncDataResult,\n GetAsyncData\n} from './DataTable.types'\n\nconst getSortDirection = (sorting: SortingState): SortDirection | undefined => {\n if (sorting[0]) {\n return sorting[0].desc ? 'desc' : 'asc'\n }\n return undefined\n}\n\nexport const getNewAsyncData = async (\n getAsyncData: GetAsyncData,\n asyncDataOptions: Partial<AsyncDataOptions>,\n paginationState: PaginationState,\n sorting: SortingState,\n globalFilter: string\n): Promise<AsyncDataResult | undefined> => {\n const { pageIndex, pageSize } = paginationState\n const params = {\n pageIndex: asyncDataOptions?.pageIndex ?? pageIndex,\n pageSize: asyncDataOptions?.pageSize ?? pageSize,\n sortBy: asyncDataOptions?.sortBy ?? sorting[0]?.id,\n sortDirection: asyncDataOptions?.sortDirection ?? getSortDirection(sorting),\n globalFilter: asyncDataOptions.globalFilter ?? globalFilter\n }\n\n const newData = await getAsyncData(params)\n\n invariant(\n Array.isArray(newData?.results),\n 'The getAsyncData function must return an object with a property `result` which must be an array'\n )\n invariant(\n newData && Number.isInteger(newData.total) && newData.total >= 0,\n 'The getAsyncData function must return an object with a property `total` which must be a positive integer or zero'\n )\n\n return newData\n}\n"],"mappings":";;AAaA,IAAM,oBAAoB,YAAqD;CAC7E,IAAI,QAAQ,IACV,OAAO,QAAQ,EAAE,CAAC,OAAO,SAAS;AAGtC;AAEA,IAAa,kBAAkB,OAC7B,cACA,kBACA,iBACA,SACA,iBACyC;CACzC,MAAM,EAAE,WAAW,aAAa;CAShC,MAAM,UAAU,MAAM,aAAa;EAPjC,WAAW,kBAAkB,aAAa;EAC1C,UAAU,kBAAkB,YAAY;EACxC,QAAQ,kBAAkB,UAAU,QAAQ,EAAE,EAAE;EAChD,eAAe,kBAAkB,iBAAiB,iBAAiB,OAAO;EAC1E,cAAc,iBAAiB,gBAAgB;CAGd,CAAM;CAEzC,UACE,MAAM,QAAQ,SAAS,OAAO,GAC9B,iGACF;CACA,UACE,WAAW,OAAO,UAAU,QAAQ,KAAK,KAAK,QAAQ,SAAS,GAC/D,kHACF;CAEA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"getNewAsyncData.js","names":[],"sources":["../../../src/components/data-table/getNewAsyncData.ts"],"sourcesContent":["import type {\n PaginationState,\n SortDirection,\n SortingState\n} from '@tanstack/react-table'\nimport invariant from 'tiny-invariant'\n\nimport type {\n AsyncDataOptions,\n AsyncDataResult,\n GetAsyncData\n} from './DataTable.types'\n\nconst getSortDirection = (sorting: SortingState): SortDirection | undefined => {\n if (sorting[0]) {\n return sorting[0].desc ? 'desc' : 'asc'\n }\n return undefined\n}\n\nexport const getNewAsyncData = async (\n getAsyncData: GetAsyncData,\n asyncDataOptions: Partial<AsyncDataOptions>,\n paginationState: PaginationState,\n sorting: SortingState,\n globalFilter: string\n): Promise<AsyncDataResult | undefined> => {\n const { pageIndex, pageSize } = paginationState\n const params = {\n pageIndex: asyncDataOptions?.pageIndex ?? pageIndex,\n pageSize: asyncDataOptions?.pageSize ?? pageSize,\n sortBy: asyncDataOptions?.sortBy ?? sorting[0]?.id,\n sortDirection: asyncDataOptions?.sortDirection ?? getSortDirection(sorting),\n globalFilter: asyncDataOptions.globalFilter ?? globalFilter\n }\n\n const newData = await getAsyncData(params)\n\n invariant(\n Array.isArray(newData?.results),\n 'The getAsyncData function must return an object with a property `result` which must be an array'\n )\n invariant(\n newData && Number.isInteger(newData.total) && newData.total >= 0,\n 'The getAsyncData function must return an object with a property `total` which must be a positive integer or zero'\n )\n\n return newData\n}\n"],"mappings":";;AAaA,IAAM,oBAAoB,YAAqD;CAC7E,IAAI,QAAQ,IACV,OAAO,QAAQ,EAAE,CAAC,OAAO,SAAS;AAGtC;AAEA,IAAa,kBAAkB,OAC7B,cACA,kBACA,iBACA,SACA,iBACyC;CACzC,MAAM,EAAE,WAAW,aAAa;CAShC,MAAM,UAAU,MAAM,aAAa;EAPjC,WAAW,kBAAkB,aAAa;EAC1C,UAAU,kBAAkB,YAAY;EACxC,QAAQ,kBAAkB,UAAU,QAAQ,EAAE,EAAE;EAChD,eAAe,kBAAkB,iBAAiB,iBAAiB,OAAO;EAC1E,cAAc,iBAAiB,gBAAgB;CAGd,CAAM;CAEzC,UACE,MAAM,QAAQ,SAAS,OAAO,GAC9B,iGACF;CACA,UACE,WAAW,OAAO,UAAU,QAAQ,KAAK,KAAK,QAAQ,SAAS,GAC/D,kHACF;CAEA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateInput.js","names":[],"sources":["../../../src/components/date-input/DateInput.tsx"],"sourcesContent":["import { CalendarEvent } from '@atom-learning/icons'\nimport { useComposedRefs } from '@radix-ui/react-compose-refs'\nimport dayjs from 'dayjs'\nimport customParseFormat from 'dayjs/plugin/customParseFormat.js'\nimport type { Props as DayzedInterface } from 'dayzed'\nimport * as React from 'react'\n\nimport { useCallbackRefState } from '../../utilities/hooks/useCallbackRef'\nimport { getFieldIconSize } from '../../utilities/style/get-icon-size'\nimport { ActionIcon } from '../action-icon/ActionIcon'\nimport { Calendar, type CalendarTranslationProps } from '../calendar/Calendar'\nimport { DEFAULT_LABELS } from '../calendar/constants'\nimport { Icon } from '../icon/Icon'\nimport { Input } from '../input/Input'\nimport { Popover } from '../popover/Popover'\nimport { DEFAULT_DATE_FORMAT } from './constants'\n\ndayjs.extend(customParseFormat)\n\nexport type DateInputProps = Omit<DayzedInterface, 'onDateSelected'> &\n CalendarTranslationProps & {\n initialDate?: Date\n dateFormat?: string\n disabled?: boolean\n size?: 'sm' | 'md' | 'lg'\n appearance?: 'standard' | 'modern'\n theme?: 'white' | 'grey'\n revalidate?: () => Promise<boolean>\n onChange?: (value?: Date) => void\n ref?: React.Ref<HTMLInputElement>\n }\n\nconst formatDateToString = (date?: Date, dateFormat = DEFAULT_DATE_FORMAT) =>\n date ? dayjs(date).format(dateFormat) : ''\n\nexport const DateInput = ({\n ref,\n initialDate,\n dateFormat = DEFAULT_DATE_FORMAT,\n firstDayOfWeek = 1,\n disabled,\n monthNames,\n weekdayNames,\n size = 'md',\n appearance,\n theme,\n labels,\n revalidate,\n onChange,\n minDate,\n maxDate,\n ...rest\n}: DateInputProps) => {\n const [date, setDate] = React.useState(\n initialDate ? dayjs(initialDate).toDate() : undefined\n )\n\n const [inputElRef, setInputElRef] = useCallbackRefState()\n const composedInputRef = useComposedRefs(\n ref as React.Ref<HTMLElement>,\n setInputElRef\n )\n\n const dateString = formatDateToString(date, dateFormat)\n\n const handleInputChange = React.useCallback(\n (event) => {\n const newDateString = event.target.value\n const parsedInputDate = dayjs(newDateString, dateFormat)\n const newDate = parsedInputDate.isValid()\n ? parsedInputDate.toDate()\n : undefined\n setDate(newDate)\n onChange?.(newDate)\n },\n [dateFormat, onChange]\n )\n\n const handleCalendarChange = React.useCallback(\n (newDate) => {\n setDate(newDate)\n\n const mirrorChangeToInputElement = () => {\n if (!inputElRef) return\n\n // Call the `set` function on the input value directly to mirror the change.\n // Props to: https://stackoverflow.com/a/46012210\n const nativeInputValueSetter = Object.getOwnPropertyDescriptor(\n window.HTMLInputElement.prototype,\n 'value'\n )?.set\n nativeInputValueSetter?.call(\n inputElRef,\n formatDateToString(newDate, dateFormat)\n )\n const event = new Event('input', { bubbles: true })\n inputElRef.dispatchEvent(event)\n }\n mirrorChangeToInputElement()\n },\n [dateFormat, inputElRef]\n )\n\n const updatedLabels = {\n ...DEFAULT_LABELS,\n ...labels\n }\n\n const [calendarOpen, setCalendarOpen] = React.useState(false)\n\n const refDateToday = React.useRef<HTMLButtonElement>(null)\n const refDateSelected = React.useRef<HTMLButtonElement>(null)\n\n const iconSize = getFieldIconSize(size)\n\n return (\n <div className=\"relative h-max\">\n <Input\n name=\"date\"\n disabled={disabled}\n size={size}\n appearance={appearance}\n theme={theme}\n {...(rest as React.ComponentProps<typeof Input>)}\n onChange={handleInputChange}\n ref={composedInputRef}\n defaultValue={dateString}\n />\n <Popover modal open={calendarOpen} onOpenChange={setCalendarOpen}>\n <Popover.Trigger asChild>\n <ActionIcon\n disabled={disabled}\n label={updatedLabels.open}\n size={iconSize}\n theme=\"neutral\"\n hasTooltip={false}\n className=\"absolute top-1/2 right-0 -translate-y-1/2\"\n >\n <Icon is={CalendarEvent} />\n </ActionIcon>\n </Popover.Trigger>\n <Popover.Portal>\n <Popover.Content\n side=\"bottom\"\n align=\"end\"\n showCloseButton={false}\n onOpenAutoFocus={(e) => {\n e.preventDefault()\n if (date) {\n refDateSelected.current?.focus()\n } else {\n refDateToday.current?.focus()\n }\n }}\n className=\"z-1147483646 pr-6\"\n >\n <Calendar\n date={date || new Date()}\n selected={date}\n onDateSelected={async (date) => {\n setCalendarOpen(false)\n await handleCalendarChange(date.date)\n if (revalidate) revalidate()\n }}\n setYear={async (date) => {\n await handleCalendarChange(date)\n if (revalidate) revalidate()\n }}\n minDate={minDate}\n maxDate={maxDate}\n refDateToday={refDateToday}\n refDateSelected={refDateSelected}\n firstDayOfWeek={firstDayOfWeek}\n monthNames={monthNames}\n weekdayNames={weekdayNames}\n labels={updatedLabels}\n />\n </Popover.Content>\n </Popover.Portal>\n </Popover>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAM,OAAO,iBAAiB;AAe9B,IAAM,sBAAsB,MAAa,aAAa,wBACpD,OAAO,MAAM,IAAI,CAAC,CAAC,OAAO,UAAU,IAAI;AAE1C,IAAa,aAAa,EACxB,KACA,aACA,aAAa,qBACb,iBAAiB,GACjB,UACA,YACA,cACA,OAAO,MACP,YACA,OACA,QACA,YACA,UACA,SACA,SACA,GAAG,WACiB;CACpB,MAAM,CAAC,MAAM,WAAW,QAAM,SAC5B,cAAc,MAAM,WAAW,CAAC,CAAC,OAAO,IAAI,KAAA,CAC9C;CAEA,MAAM,CAAC,YAAY,iBAAiB,oBAAoB;CACxD,MAAM,mBAAmB,gBACvB,KACA,aACF;CAEA,MAAM,aAAa,mBAAmB,MAAM,UAAU;CAEtD,MAAM,oBAAoB,QAAM,aAC7B,UAAU;EACT,MAAM,gBAAgB,MAAM,OAAO;EACnC,MAAM,kBAAkB,MAAM,eAAe,UAAU;EACvD,MAAM,UAAU,gBAAgB,QAAQ,IACpC,gBAAgB,OAAO,IACvB,KAAA;EACJ,QAAQ,OAAO;EACf,WAAW,OAAO;CACpB,GACA,CAAC,YAAY,QAAQ,CACvB;CAEA,MAAM,uBAAuB,QAAM,aAChC,YAAY;EACX,QAAQ,OAAO;EAEf,MAAM,mCAAmC;GACvC,IAAI,CAAC,YAAY;GAQjB,CAJ+B,OAAO,yBACpC,OAAO,iBAAiB,WACxB,OACF,CAAC,EAAE,IAAA,EACqB,KACtB,YACA,mBAAmB,SAAS,UAAU,CACxC;GACA,MAAM,QAAQ,IAAI,MAAM,SAAS,EAAE,SAAS,KAAK,CAAC;GAClD,WAAW,cAAc,KAAK;EAChC;EACA,2BAA2B;CAC7B,GACA,CAAC,YAAY,UAAU,CACzB;CAEA,MAAM,gBAAgB;EACpB,GAAG;EACH,GAAG;CACL;CAEA,MAAM,CAAC,cAAc,mBAAmB,QAAM,SAAS,KAAK;CAE5D,MAAM,eAAe,QAAM,OAA0B,IAAI;CACzD,MAAM,kBAAkB,QAAM,OAA0B,IAAI;CAE5D,MAAM,WAAW,iBAAiB,IAAI;CAEtC,OACE,qBAAC,OAAD;EAAK,WAAU;YAAf,CACE,oBAAC,OAAD;GACE,MAAK;GACK;GACJ;GACM;GACL;GACP,GAAK;GACL,UAAU;GACV,KAAK;GACL,cAAc;EACf,CAAA,GACD,qBAAC,SAAD;GAAS,OAAA;GAAM,MAAM;GAAc,cAAc;aAAjD,CACE,oBAAC,QAAQ,SAAT;IAAiB,SAAA;cACf,oBAAC,YAAD;KACY;KACV,OAAO,cAAc;KACrB,MAAM;KACN,OAAM;KACN,YAAY;KACZ,WAAU;eAEV,oBAAC,MAAD,EAAM,IAAI,cAAgB,CAAA;IAChB,CAAA;GACG,CAAA,GACjB,oBAAC,QAAQ,QAAT,EAAA,UACE,oBAAC,QAAQ,SAAT;IACE,MAAK;IACL,OAAM;IACN,iBAAiB;IACjB,kBAAkB,MAAM;KACtB,EAAE,eAAe;KACjB,IAAI,MACF,gBAAgB,SAAS,MAAM;UAE/B,aAAa,SAAS,MAAM;IAEhC;IACA,WAAU;cAEV,oBAAC,UAAD;KACE,
|
|
1
|
+
{"version":3,"file":"DateInput.js","names":[],"sources":["../../../src/components/date-input/DateInput.tsx"],"sourcesContent":["import { CalendarEvent } from '@atom-learning/icons'\nimport { useComposedRefs } from '@radix-ui/react-compose-refs'\nimport dayjs from 'dayjs'\nimport customParseFormat from 'dayjs/plugin/customParseFormat.js'\nimport type { Props as DayzedInterface } from 'dayzed'\nimport * as React from 'react'\n\nimport { useCallbackRefState } from '../../utilities/hooks/useCallbackRef'\nimport { getFieldIconSize } from '../../utilities/style/get-icon-size'\nimport { ActionIcon } from '../action-icon/ActionIcon'\nimport { Calendar, type CalendarTranslationProps } from '../calendar/Calendar'\nimport { DEFAULT_LABELS } from '../calendar/constants'\nimport { Icon } from '../icon/Icon'\nimport { Input } from '../input/Input'\nimport { Popover } from '../popover/Popover'\nimport { DEFAULT_DATE_FORMAT } from './constants'\n\ndayjs.extend(customParseFormat)\n\nexport type DateInputProps = Omit<DayzedInterface, 'onDateSelected'> &\n CalendarTranslationProps & {\n initialDate?: Date\n dateFormat?: string\n disabled?: boolean\n size?: 'sm' | 'md' | 'lg'\n appearance?: 'standard' | 'modern'\n theme?: 'white' | 'grey'\n revalidate?: () => Promise<boolean>\n onChange?: (value?: Date) => void\n ref?: React.Ref<HTMLInputElement>\n }\n\nconst formatDateToString = (date?: Date, dateFormat = DEFAULT_DATE_FORMAT) =>\n date ? dayjs(date).format(dateFormat) : ''\n\nexport const DateInput = ({\n ref,\n initialDate,\n dateFormat = DEFAULT_DATE_FORMAT,\n firstDayOfWeek = 1,\n disabled,\n monthNames,\n weekdayNames,\n size = 'md',\n appearance,\n theme,\n labels,\n revalidate,\n onChange,\n minDate,\n maxDate,\n ...rest\n}: DateInputProps) => {\n const [date, setDate] = React.useState(\n initialDate ? dayjs(initialDate).toDate() : undefined\n )\n\n const [inputElRef, setInputElRef] = useCallbackRefState()\n const composedInputRef = useComposedRefs(\n ref as React.Ref<HTMLElement>,\n setInputElRef\n )\n\n const dateString = formatDateToString(date, dateFormat)\n\n const handleInputChange = React.useCallback(\n (event) => {\n const newDateString = event.target.value\n const parsedInputDate = dayjs(newDateString, dateFormat)\n const newDate = parsedInputDate.isValid()\n ? parsedInputDate.toDate()\n : undefined\n setDate(newDate)\n onChange?.(newDate)\n },\n [dateFormat, onChange]\n )\n\n const handleCalendarChange = React.useCallback(\n (newDate) => {\n setDate(newDate)\n\n const mirrorChangeToInputElement = () => {\n if (!inputElRef) return\n\n // Call the `set` function on the input value directly to mirror the change.\n // Props to: https://stackoverflow.com/a/46012210\n const nativeInputValueSetter = Object.getOwnPropertyDescriptor(\n window.HTMLInputElement.prototype,\n 'value'\n )?.set\n nativeInputValueSetter?.call(\n inputElRef,\n formatDateToString(newDate, dateFormat)\n )\n const event = new Event('input', { bubbles: true })\n inputElRef.dispatchEvent(event)\n }\n mirrorChangeToInputElement()\n },\n [dateFormat, inputElRef]\n )\n\n const updatedLabels = {\n ...DEFAULT_LABELS,\n ...labels\n }\n\n const [calendarOpen, setCalendarOpen] = React.useState(false)\n\n const refDateToday = React.useRef<HTMLButtonElement>(null)\n const refDateSelected = React.useRef<HTMLButtonElement>(null)\n\n const iconSize = getFieldIconSize(size)\n\n return (\n <div className=\"relative h-max\">\n <Input\n name=\"date\"\n disabled={disabled}\n size={size}\n appearance={appearance}\n theme={theme}\n {...(rest as React.ComponentProps<typeof Input>)}\n onChange={handleInputChange}\n ref={composedInputRef}\n defaultValue={dateString}\n />\n <Popover modal open={calendarOpen} onOpenChange={setCalendarOpen}>\n <Popover.Trigger asChild>\n <ActionIcon\n disabled={disabled}\n label={updatedLabels.open}\n size={iconSize}\n theme=\"neutral\"\n hasTooltip={false}\n className=\"absolute top-1/2 right-0 -translate-y-1/2\"\n >\n <Icon is={CalendarEvent} />\n </ActionIcon>\n </Popover.Trigger>\n <Popover.Portal>\n <Popover.Content\n side=\"bottom\"\n align=\"end\"\n showCloseButton={false}\n onOpenAutoFocus={(e) => {\n e.preventDefault()\n if (date) {\n refDateSelected.current?.focus()\n } else {\n refDateToday.current?.focus()\n }\n }}\n className=\"z-1147483646 pr-6\"\n >\n <Calendar\n date={\n // The calendar only mounts inside the opened popover (a\n // client-only interaction), so this `new Date()` fallback never\n // renders on the server and can't cause a hydration mismatch.\n // eslint-disable-next-line react-doctor/rendering-hydration-mismatch-time\n date || new Date()\n }\n selected={date}\n onDateSelected={async (date) => {\n setCalendarOpen(false)\n await handleCalendarChange(date.date)\n if (revalidate) revalidate()\n }}\n setYear={async (date) => {\n await handleCalendarChange(date)\n if (revalidate) revalidate()\n }}\n minDate={minDate}\n maxDate={maxDate}\n refDateToday={refDateToday}\n refDateSelected={refDateSelected}\n firstDayOfWeek={firstDayOfWeek}\n monthNames={monthNames}\n weekdayNames={weekdayNames}\n labels={updatedLabels}\n />\n </Popover.Content>\n </Popover.Portal>\n </Popover>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAM,OAAO,iBAAiB;AAe9B,IAAM,sBAAsB,MAAa,aAAa,wBACpD,OAAO,MAAM,IAAI,CAAC,CAAC,OAAO,UAAU,IAAI;AAE1C,IAAa,aAAa,EACxB,KACA,aACA,aAAa,qBACb,iBAAiB,GACjB,UACA,YACA,cACA,OAAO,MACP,YACA,OACA,QACA,YACA,UACA,SACA,SACA,GAAG,WACiB;CACpB,MAAM,CAAC,MAAM,WAAW,QAAM,SAC5B,cAAc,MAAM,WAAW,CAAC,CAAC,OAAO,IAAI,KAAA,CAC9C;CAEA,MAAM,CAAC,YAAY,iBAAiB,oBAAoB;CACxD,MAAM,mBAAmB,gBACvB,KACA,aACF;CAEA,MAAM,aAAa,mBAAmB,MAAM,UAAU;CAEtD,MAAM,oBAAoB,QAAM,aAC7B,UAAU;EACT,MAAM,gBAAgB,MAAM,OAAO;EACnC,MAAM,kBAAkB,MAAM,eAAe,UAAU;EACvD,MAAM,UAAU,gBAAgB,QAAQ,IACpC,gBAAgB,OAAO,IACvB,KAAA;EACJ,QAAQ,OAAO;EACf,WAAW,OAAO;CACpB,GACA,CAAC,YAAY,QAAQ,CACvB;CAEA,MAAM,uBAAuB,QAAM,aAChC,YAAY;EACX,QAAQ,OAAO;EAEf,MAAM,mCAAmC;GACvC,IAAI,CAAC,YAAY;GAQjB,CAJ+B,OAAO,yBACpC,OAAO,iBAAiB,WACxB,OACF,CAAC,EAAE,IAAA,EACqB,KACtB,YACA,mBAAmB,SAAS,UAAU,CACxC;GACA,MAAM,QAAQ,IAAI,MAAM,SAAS,EAAE,SAAS,KAAK,CAAC;GAClD,WAAW,cAAc,KAAK;EAChC;EACA,2BAA2B;CAC7B,GACA,CAAC,YAAY,UAAU,CACzB;CAEA,MAAM,gBAAgB;EACpB,GAAG;EACH,GAAG;CACL;CAEA,MAAM,CAAC,cAAc,mBAAmB,QAAM,SAAS,KAAK;CAE5D,MAAM,eAAe,QAAM,OAA0B,IAAI;CACzD,MAAM,kBAAkB,QAAM,OAA0B,IAAI;CAE5D,MAAM,WAAW,iBAAiB,IAAI;CAEtC,OACE,qBAAC,OAAD;EAAK,WAAU;YAAf,CACE,oBAAC,OAAD;GACE,MAAK;GACK;GACJ;GACM;GACL;GACP,GAAK;GACL,UAAU;GACV,KAAK;GACL,cAAc;EACf,CAAA,GACD,qBAAC,SAAD;GAAS,OAAA;GAAM,MAAM;GAAc,cAAc;aAAjD,CACE,oBAAC,QAAQ,SAAT;IAAiB,SAAA;cACf,oBAAC,YAAD;KACY;KACV,OAAO,cAAc;KACrB,MAAM;KACN,OAAM;KACN,YAAY;KACZ,WAAU;eAEV,oBAAC,MAAD,EAAM,IAAI,cAAgB,CAAA;IAChB,CAAA;GACG,CAAA,GACjB,oBAAC,QAAQ,QAAT,EAAA,UACE,oBAAC,QAAQ,SAAT;IACE,MAAK;IACL,OAAM;IACN,iBAAiB;IACjB,kBAAkB,MAAM;KACtB,EAAE,eAAe;KACjB,IAAI,MACF,gBAAgB,SAAS,MAAM;UAE/B,aAAa,SAAS,MAAM;IAEhC;IACA,WAAU;cAEV,oBAAC,UAAD;KACE,MAKE,wBAAQ,IAAI,KAAK;KAEnB,UAAU;KACV,gBAAgB,OAAO,SAAS;MAC9B,gBAAgB,KAAK;MACrB,MAAM,qBAAqB,KAAK,IAAI;MACpC,IAAI,YAAY,WAAW;KAC7B;KACA,SAAS,OAAO,SAAS;MACvB,MAAM,qBAAqB,IAAI;MAC/B,IAAI,YAAY,WAAW;KAC7B;KACS;KACA;KACK;KACG;KACD;KACJ;KACE;KACd,QAAQ;IACT,CAAA;GACc,CAAA,EACH,CAAA,CACT;IACN;;AAET"}
|
|
@@ -29,12 +29,12 @@ var FileDrop = ({ children, accept, multiple, onDrop, ...rest }) => {
|
|
|
29
29
|
const handleDrop = (fileList) => {
|
|
30
30
|
if (!fileList) return;
|
|
31
31
|
setIsDragging(false);
|
|
32
|
-
const files =
|
|
32
|
+
const files = [...fileList];
|
|
33
33
|
onDrop(files);
|
|
34
34
|
setFiles(files);
|
|
35
35
|
};
|
|
36
36
|
const handleKeyDown = (event) => {
|
|
37
|
-
if (
|
|
37
|
+
if ("Space" === event.key || "Enter" === event.key) fileUploadInputRef.current?.click();
|
|
38
38
|
};
|
|
39
39
|
const value = React$1.useMemo(() => ({
|
|
40
40
|
isDragging,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileDrop.js","names":[],"sources":["../../../src/components/file-drop/FileDrop.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { styled } from '../../styled'\nimport { FileDropContext } from './FileDrop.context'\nimport { type FileDropContextValue } from './types'\n\ninterface FileDropProps extends Omit<\n React.ComponentProps<'div'>,\n 'onDrop' | 'ref' | 'children'\n> {\n onDrop: (files: File[]) => void\n children?:\n | React.ReactNode\n | ((value: FileDropContextValue) => React.ReactNode)\n accept?: React.InputHTMLAttributes<HTMLInputElement>['accept']\n multiple?: React.InputHTMLAttributes<HTMLInputElement>['multiple']\n}\n\nconst StyledContainer = styled('div', {\n base: [\n 'flex',\n 'flex-col',\n 'gap-6',\n 'items-center',\n 'border',\n 'border-dashed',\n 'border-grey-500',\n 'px-12',\n 'py-8',\n 'rounded-md',\n 'cursor-pointer',\n '**:pointer-events-none'\n ]\n})\n\nexport const FileDrop = ({\n children,\n accept,\n multiple,\n onDrop,\n ...rest\n}: FileDropProps) => {\n const [isDragging, setIsDragging] = React.useState(false)\n const [files, setFiles] = React.useState<File[]>([])\n const fileUploadInputRef = React.useRef<HTMLInputElement>(null)\n\n const handleDragOver = (event: React.DragEvent<HTMLDivElement>) => {\n event.preventDefault()\n setIsDragging(true)\n }\n\n const handleDragLeave = () => setIsDragging(false)\n\n const handleDrop = (fileList: FileList | null) => {\n if (!fileList) return\n\n setIsDragging(false)\n\n const files =
|
|
1
|
+
{"version":3,"file":"FileDrop.js","names":[],"sources":["../../../src/components/file-drop/FileDrop.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { styled } from '../../styled'\nimport { FileDropContext } from './FileDrop.context'\nimport { type FileDropContextValue } from './types'\n\ninterface FileDropProps extends Omit<\n React.ComponentProps<'div'>,\n 'onDrop' | 'ref' | 'children'\n> {\n onDrop: (files: File[]) => void\n children?:\n | React.ReactNode\n | ((value: FileDropContextValue) => React.ReactNode)\n accept?: React.InputHTMLAttributes<HTMLInputElement>['accept']\n multiple?: React.InputHTMLAttributes<HTMLInputElement>['multiple']\n}\n\nconst StyledContainer = styled('div', {\n base: [\n 'flex',\n 'flex-col',\n 'gap-6',\n 'items-center',\n 'border',\n 'border-dashed',\n 'border-grey-500',\n 'px-12',\n 'py-8',\n 'rounded-md',\n 'cursor-pointer',\n '**:pointer-events-none'\n ]\n})\n\nexport const FileDrop = ({\n children,\n accept,\n multiple,\n onDrop,\n ...rest\n}: FileDropProps) => {\n const [isDragging, setIsDragging] = React.useState(false)\n const [files, setFiles] = React.useState<File[]>([])\n const fileUploadInputRef = React.useRef<HTMLInputElement>(null)\n\n const handleDragOver = (event: React.DragEvent<HTMLDivElement>) => {\n event.preventDefault()\n setIsDragging(true)\n }\n\n const handleDragLeave = () => setIsDragging(false)\n\n const handleDrop = (fileList: FileList | null) => {\n if (!fileList) return\n\n setIsDragging(false)\n\n const files = [...fileList]\n onDrop(files)\n setFiles(files)\n }\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if ('Space' === event.key || 'Enter' === event.key) {\n fileUploadInputRef.current?.click()\n }\n }\n\n // Memoized: consumers otherwise re-render at drag-over event frequency.\n const value = React.useMemo<FileDropContextValue>(\n () => ({ isDragging, files }),\n [isDragging, files]\n )\n\n return (\n <FileDropContext value={value}>\n <StyledContainer\n onDragOver={handleDragOver}\n onDragLeave={handleDragLeave}\n onDrop={(event) => {\n event.preventDefault()\n handleDrop(event.dataTransfer.files)\n }}\n onClick={() => fileUploadInputRef.current?.click()}\n // A drop zone wraps a file input and arbitrary (possibly interactive)\n // children, which a native <button> may not contain, so the button role\n // lives on this container instead.\n // eslint-disable-next-line jsx-a11y/prefer-tag-over-role\n role=\"button\"\n onKeyDown={handleKeyDown}\n tabIndex={0}\n {...rest}\n >\n {typeof children === 'function' ? children(value) : children}\n <input\n type=\"file\"\n ref={fileUploadInputRef}\n style={{ visibility: 'hidden' }}\n accept={accept}\n multiple={multiple}\n onChange={(event) => {\n handleDrop(event.target.files)\n }}\n />\n </StyledContainer>\n </FileDropContext>\n )\n}\n\nFileDrop.displayName = 'FileDrop'\n"],"mappings":";;;;;AAkBA,IAAM,kBAAkB,OAAO,OAAO,EACpC,MAAM;CACJ;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,EACF,CAAC;AAED,IAAa,YAAY,EACvB,UACA,QACA,UACA,QACA,GAAG,WACgB;CACnB,MAAM,CAAC,YAAY,iBAAiB,QAAM,SAAS,KAAK;CACxD,MAAM,CAAC,OAAO,YAAY,QAAM,SAAiB,CAAC,CAAC;CACnD,MAAM,qBAAqB,QAAM,OAAyB,IAAI;CAE9D,MAAM,kBAAkB,UAA2C;EACjE,MAAM,eAAe;EACrB,cAAc,IAAI;CACpB;CAEA,MAAM,wBAAwB,cAAc,KAAK;CAEjD,MAAM,cAAc,aAA8B;EAChD,IAAI,CAAC,UAAU;EAEf,cAAc,KAAK;EAEnB,MAAM,QAAQ,CAAC,GAAG,QAAQ;EAC1B,OAAO,KAAK;EACZ,SAAS,KAAK;CAChB;CAEA,MAAM,iBAAiB,UAA+C;EACpE,IAAI,YAAY,MAAM,OAAO,YAAY,MAAM,KAC7C,mBAAmB,SAAS,MAAM;CAEtC;CAGA,MAAM,QAAQ,QAAM,eACX;EAAE;EAAY;CAAM,IAC3B,CAAC,YAAY,KAAK,CACpB;CAEA,OACE,oBAAC,iBAAD;EAAwB;YACtB,qBAAC,iBAAD;GACE,YAAY;GACZ,aAAa;GACb,SAAS,UAAU;IACjB,MAAM,eAAe;IACrB,WAAW,MAAM,aAAa,KAAK;GACrC;GACA,eAAe,mBAAmB,SAAS,MAAM;GAKjD,MAAK;GACL,WAAW;GACX,UAAU;GACV,GAAI;aAfN,CAiBG,OAAO,aAAa,aAAa,SAAS,KAAK,IAAI,UACpD,oBAAC,SAAD;IACE,MAAK;IACL,KAAK;IACL,OAAO,EAAE,YAAY,SAAS;IACtB;IACE;IACV,WAAW,UAAU;KACnB,WAAW,MAAM,OAAO,KAAK;IAC/B;GACD,CAAA,CACc;;CACF,CAAA;AAErB;AAEA,SAAS,cAAc"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cn } from "../../styled.js";
|
|
2
|
-
import { Button } from "../button/Button.js";
|
|
3
2
|
import { Icon } from "../icon/Icon.js";
|
|
3
|
+
import { Button } from "../button/Button.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { Upload } from "@atom-learning/icons";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { useFormContext } from "react-hook-form";
|
|
2
2
|
import delve from "dlv";
|
|
3
3
|
//#region src/components/form/useFieldError.ts
|
|
4
|
+
var FIELD_PATH_SEPARATOR_RE = /[,[\].]+?/;
|
|
4
5
|
var useFieldError = (fieldName) => {
|
|
5
6
|
const { errors } = useFormContext();
|
|
6
|
-
const fieldPath = fieldName.split(
|
|
7
|
+
const fieldPath = fieldName.split(FIELD_PATH_SEPARATOR_RE).filter(Boolean);
|
|
7
8
|
const getErrors = () => delve(errors, fieldPath);
|
|
8
9
|
return { error: getErrors()?.message };
|
|
9
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFieldError.js","names":[],"sources":["../../../src/components/form/useFieldError.ts"],"sourcesContent":["import delve from 'dlv'\nimport { useFormContext } from 'react-hook-form'\n\nexport const useFieldError = (fieldName: string) => {\n const { errors } = useFormContext()\n\n // in case of migration to a newer version of react-hook-form the path needs to updated to account for dynamic fields naming convention\n const fieldPath = fieldName.split(
|
|
1
|
+
{"version":3,"file":"useFieldError.js","names":[],"sources":["../../../src/components/form/useFieldError.ts"],"sourcesContent":["import delve from 'dlv'\nimport { useFormContext } from 'react-hook-form'\n\n// Splits react-hook-form field paths on their `,` `[` `]` `.` separators.\nconst FIELD_PATH_SEPARATOR_RE = /[,[\\].]+?/\n\nexport const useFieldError = (fieldName: string) => {\n const { errors } = useFormContext()\n\n // in case of migration to a newer version of react-hook-form the path needs to updated to account for dynamic fields naming convention\n const fieldPath = fieldName.split(FIELD_PATH_SEPARATOR_RE).filter(Boolean)\n\n const getErrors = () => delve(errors, fieldPath)\n\n return {\n error: getErrors()?.message\n }\n}\n"],"mappings":";;;AAIA,IAAM,0BAA0B;AAEhC,IAAa,iBAAiB,cAAsB;CAClD,MAAM,EAAE,WAAW,eAAe;CAGlC,MAAM,YAAY,UAAU,MAAM,uBAAuB,CAAC,CAAC,OAAO,OAAO;CAEzE,MAAM,kBAAkB,MAAM,QAAQ,SAAS;CAE/C,OAAO,EACL,OAAO,UAAU,CAAC,EAAE,QACtB;AACF"}
|
|
@@ -3,9 +3,7 @@ export { Accordion } from './accordion/Accordion';
|
|
|
3
3
|
export { ActionIcon } from './action-icon/ActionIcon';
|
|
4
4
|
export { AlertDialog } from './alert-dialog/AlertDialog';
|
|
5
5
|
export { useAlert } from './alert-dialog/AlertDialog.context';
|
|
6
|
-
export
|
|
7
|
-
Provider: ({ children }: React.PropsWithChildren<unknown>) => import("react").JSX.Element;
|
|
8
|
-
};
|
|
6
|
+
export { Alert } from './alert-dialog/Alert';
|
|
9
7
|
export { Avatar } from './avatar/Avatar';
|
|
10
8
|
export { Badge, type BadgeProps } from './badge/Badge';
|
|
11
9
|
export { BannerRegular } from './banner/banner-regular/BannerRegular';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { styled } from "../../styled.js";
|
|
2
|
-
import { Text } from "../text/Text.js";
|
|
3
2
|
import { Icon } from "../icon/Icon.js";
|
|
3
|
+
import { Text } from "../text/Text.js";
|
|
4
4
|
import { INLINE_MESSAGE_ICONS } from "./InlineMessage.config.js";
|
|
5
5
|
import "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -13,9 +13,9 @@ import { MarkdownText } from "./components/MarkdownText.js";
|
|
|
13
13
|
import { MarkdownThematicBreak } from "./components/MarkdownThematicBreak.js";
|
|
14
14
|
import "react";
|
|
15
15
|
import { jsx } from "react/jsx-runtime";
|
|
16
|
-
import
|
|
17
|
-
import fromMarkdown from "mdast-util-from-markdown";
|
|
18
|
-
import
|
|
16
|
+
import { directiveFromMarkdown } from "mdast-util-directive";
|
|
17
|
+
import { fromMarkdown } from "mdast-util-from-markdown";
|
|
18
|
+
import { directive } from "micromark-extension-directive";
|
|
19
19
|
//#region src/components/markdown-content/MarkdownContent.tsx
|
|
20
20
|
var StyledMarkdownContent = styled("div", { base: [
|
|
21
21
|
"flex",
|
|
@@ -51,8 +51,8 @@ var generateNodeKey = (node, index) => {
|
|
|
51
51
|
};
|
|
52
52
|
var MarkdownContent = ({ content, customComponents = {}, className }) => {
|
|
53
53
|
const AST = fromMarkdown(content, {
|
|
54
|
-
extensions: [
|
|
55
|
-
mdastExtensions: [
|
|
54
|
+
extensions: [directive()],
|
|
55
|
+
mdastExtensions: [directiveFromMarkdown()]
|
|
56
56
|
});
|
|
57
57
|
const componentsMap = {
|
|
58
58
|
...defaultComponentsMap,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownContent.js","names":[],"sources":["../../../src/components/markdown-content/MarkdownContent.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"MarkdownContent.js","names":[],"sources":["../../../src/components/markdown-content/MarkdownContent.tsx"],"sourcesContent":["import { directiveFromMarkdown } from 'mdast-util-directive'\nimport { fromMarkdown } from 'mdast-util-from-markdown'\nimport { directive } from 'micromark-extension-directive'\nimport * as React from 'react'\n\nimport { styled } from '../../styled'\nimport { MarkdownCode } from './components/MarkdownCode'\nimport { MarkdownEmphasis } from './components/MarkdownEmphasis'\nimport { MarkdownHeading } from './components/MarkdownHeading'\nimport { MarkdownImage } from './components/MarkdownImage'\nimport { MarkdownInlineCode } from './components/MarkdownInlineCode'\nimport { MarkdownLink } from './components/MarkdownLink'\nimport { MarkdownList } from './components/MarkdownList'\nimport { MarkdownListItem } from './components/MarkdownListItem'\nimport { MarkdownParagraph } from './components/MarkdownParagraph'\nimport { MarkdownStrong } from './components/MarkdownStrong'\nimport { MarkdownText } from './components/MarkdownText'\nimport { MarkdownThematicBreak } from './components/MarkdownThematicBreak'\n\ntype HandleNode = (node, index?: number) => React.JSX.Element | null\n\nconst StyledMarkdownContent = styled('div', {\n base: [\n 'flex',\n 'flex-col',\n 'gap-8',\n '[&>h1]:max-w-[65ch]',\n '[&>h2]:max-w-[65ch]',\n '[&>h3]:max-w-[65ch]',\n '[&>h4]:max-w-[65ch]',\n '[&>p]:max-w-[75ch]',\n '[&>ul]:max-w-[75ch]'\n ]\n})\n\ntype MarkdownContentProps = React.ComponentProps<\n typeof StyledMarkdownContent\n> & {\n content: string\n customComponents?: {\n [key: string]: (props: {\n node: any\n handleNode: HandleNode\n }) => React.JSX.Element\n }\n}\n\nconst defaultComponentsMap = {\n code: MarkdownCode,\n emphasis: MarkdownEmphasis,\n heading: MarkdownHeading,\n inlineCode: MarkdownInlineCode,\n image: MarkdownImage,\n link: MarkdownLink,\n list: MarkdownList,\n listItem: MarkdownListItem,\n paragraph: MarkdownParagraph,\n strong: MarkdownStrong,\n text: MarkdownText,\n thematicBreak: MarkdownThematicBreak\n}\n\nconst generateNodeKey = (node, index: number) => {\n if (node.position?.start) {\n const { line, column, offset } = node.position.start\n return `${node.type}${line}${column}${offset}`\n }\n\n // Deterministic fallback: keys must be stable across renders and identical\n // between server and client, so no timestamps or random values.\n return `${node.type}${index}`\n}\n\nexport const MarkdownContent = ({\n content,\n customComponents = {},\n className\n}: MarkdownContentProps) => {\n const AST = fromMarkdown(content, {\n extensions: [directive()],\n mdastExtensions: [directiveFromMarkdown()]\n })\n\n const componentsMap = {\n ...defaultComponentsMap,\n ...customComponents\n }\n\n const handleNode: HandleNode = (node, index = 0) => {\n const MarkdownComponent = componentsMap[node.type]\n\n return MarkdownComponent ? (\n <MarkdownComponent\n key={generateNodeKey(node, index)}\n node={node}\n handleNode={handleNode}\n />\n ) : null\n }\n\n return (\n <StyledMarkdownContent className={className}>\n {AST.children.map(handleNode)}\n </StyledMarkdownContent>\n )\n}\n\nMarkdownContent.displayName = 'MarkdownContent'\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,IAAM,wBAAwB,OAAO,OAAO,EAC1C,MAAM;CACJ;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,EACF,CAAC;AAcD,IAAM,uBAAuB;CAC3B,MAAM;CACN,UAAU;CACV,SAAS;CACT,YAAY;CACZ,OAAO;CACP,MAAM;CACN,MAAM;CACN,UAAU;CACV,WAAW;CACX,QAAQ;CACR,MAAM;CACN,eAAe;AACjB;AAEA,IAAM,mBAAmB,MAAM,UAAkB;CAC/C,IAAI,KAAK,UAAU,OAAO;EACxB,MAAM,EAAE,MAAM,QAAQ,WAAW,KAAK,SAAS;EAC/C,OAAO,GAAG,KAAK,OAAO,OAAO,SAAS;CACxC;CAIA,OAAO,GAAG,KAAK,OAAO;AACxB;AAEA,IAAa,mBAAmB,EAC9B,SACA,mBAAmB,CAAC,GACpB,gBAC0B;CAC1B,MAAM,MAAM,aAAa,SAAS;EAChC,YAAY,CAAC,UAAU,CAAC;EACxB,iBAAiB,CAAC,sBAAsB,CAAC;CAC3C,CAAC;CAED,MAAM,gBAAgB;EACpB,GAAG;EACH,GAAG;CACL;CAEA,MAAM,cAA0B,MAAM,QAAQ,MAAM;EAClD,MAAM,oBAAoB,cAAc,KAAK;EAE7C,OAAO,oBACL,oBAAC,mBAAD;GAEQ;GACM;EACb,GAHM,gBAAgB,MAAM,KAAK,CAGjC,IACC;CACN;CAEA,OACE,oBAAC,uBAAD;EAAkC;YAC/B,IAAI,SAAS,IAAI,UAAU;CACP,CAAA;AAE3B;AAEA,gBAAgB,cAAc"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RootContent, Emphasis } from 'mdast';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
type MarkdownEmphasisProps = {
|
|
4
4
|
node: Emphasis;
|
|
5
|
-
handleNode: (node:
|
|
5
|
+
handleNode: (node: RootContent) => React.ReactElement<unknown>;
|
|
6
6
|
};
|
|
7
7
|
export declare const StyledMarkdownEmphasis: import("../../..").PolymorphicComponent<"em", unknown>;
|
|
8
8
|
export declare const MarkdownEmphasis: ({ node, handleNode }: MarkdownEmphasisProps) => React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownEmphasis.js","names":[],"sources":["../../../../src/components/markdown-content/components/MarkdownEmphasis.tsx"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"MarkdownEmphasis.js","names":[],"sources":["../../../../src/components/markdown-content/components/MarkdownEmphasis.tsx"],"sourcesContent":["import type { RootContent, Emphasis } from 'mdast'\nimport * as React from 'react'\n\nimport { styled } from '../../../styled'\n\ntype MarkdownEmphasisProps = {\n node: Emphasis\n handleNode: (node: RootContent) => React.ReactElement<unknown>\n}\n\nexport const StyledMarkdownEmphasis = styled('em', {\n base: ['italic']\n})\n\nexport const MarkdownEmphasis = ({\n node,\n handleNode\n}: MarkdownEmphasisProps) => (\n <StyledMarkdownEmphasis>\n {node.children?.map(handleNode)}\n </StyledMarkdownEmphasis>\n)\n"],"mappings":";;;;AAUA,IAAa,yBAAyB,OAAO,MAAM,EACjD,MAAM,CAAC,QAAQ,EACjB,CAAC;AAED,IAAa,oBAAoB,EAC/B,MACA,iBAEA,oBAAC,wBAAD,EAAA,UACG,KAAK,UAAU,IAAI,UAAU,EACR,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RootContent, Heading as HeadingType } from 'mdast';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
type MarkdownHeadingProps = {
|
|
4
4
|
node: HeadingType;
|
|
5
|
-
handleNode: (node:
|
|
5
|
+
handleNode: (node: RootContent) => React.ReactElement<unknown>;
|
|
6
6
|
};
|
|
7
7
|
export declare const MarkdownHeading: ({ node, handleNode, ...rest }: MarkdownHeadingProps) => React.JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownHeading.js","names":[],"sources":["../../../../src/components/markdown-content/components/MarkdownHeading.tsx"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"MarkdownHeading.js","names":[],"sources":["../../../../src/components/markdown-content/components/MarkdownHeading.tsx"],"sourcesContent":["import type { RootContent, Heading as HeadingType } from 'mdast'\nimport * as React from 'react'\n\nimport { Heading, type HeadingProps } from '../../heading/Heading'\n\ntype MarkdownHeadingProps = {\n node: HeadingType\n handleNode: (node: RootContent) => React.ReactElement<unknown>\n}\n\nconst getHeadingProps = (depth: number): HeadingProps => {\n switch (depth) {\n case 1:\n return { size: 'xl', as: 'h1' }\n case 2:\n return { size: 'lg', as: 'h2' }\n case 3:\n return { size: 'md', as: 'h3' }\n case 4:\n return { size: 'sm', as: 'h4' }\n case 5:\n return { size: 'xs', as: 'h5' }\n default:\n return { size: 'xs', as: 'h6' }\n }\n}\n\nexport const MarkdownHeading = ({\n node,\n handleNode,\n ...rest\n}: MarkdownHeadingProps) => {\n const { as, size } = getHeadingProps(node.depth)\n\n return (\n <Heading as={as} size={size} {...rest}>\n {node.children?.map(handleNode)}\n </Heading>\n )\n}\n"],"mappings":";;;;AAUA,IAAM,mBAAmB,UAAgC;CACvD,QAAQ,OAAR;EACE,KAAK,GACH,OAAO;GAAE,MAAM;GAAM,IAAI;EAAK;EAChC,KAAK,GACH,OAAO;GAAE,MAAM;GAAM,IAAI;EAAK;EAChC,KAAK,GACH,OAAO;GAAE,MAAM;GAAM,IAAI;EAAK;EAChC,KAAK,GACH,OAAO;GAAE,MAAM;GAAM,IAAI;EAAK;EAChC,KAAK,GACH,OAAO;GAAE,MAAM;GAAM,IAAI;EAAK;EAChC,SACE,OAAO;GAAE,MAAM;GAAM,IAAI;EAAK;CAClC;AACF;AAEA,IAAa,mBAAmB,EAC9B,MACA,YACA,GAAG,WACuB;CAC1B,MAAM,EAAE,IAAI,SAAS,gBAAgB,KAAK,KAAK;CAE/C,OACE,oBAAC,SAAD;EAAa;EAAU;EAAM,GAAI;YAC9B,KAAK,UAAU,IAAI,UAAU;CACvB,CAAA;AAEb"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RootContent, Link as LinkType } from 'mdast';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
type MarkdownLinkProps = {
|
|
4
4
|
node: LinkType;
|
|
5
|
-
handleNode: (node:
|
|
5
|
+
handleNode: (node: RootContent) => React.ReactElement<unknown>;
|
|
6
6
|
};
|
|
7
7
|
export declare const MarkdownLink: ({ node, handleNode }: MarkdownLinkProps) => React.JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownLink.js","names":[],"sources":["../../../../src/components/markdown-content/components/MarkdownLink.tsx"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"MarkdownLink.js","names":[],"sources":["../../../../src/components/markdown-content/components/MarkdownLink.tsx"],"sourcesContent":["import type { RootContent, Link as LinkType } from 'mdast'\nimport * as React from 'react'\n\nimport { Link } from '../../link/Link'\n\ntype MarkdownLinkProps = {\n node: LinkType\n handleNode: (node: RootContent) => React.ReactElement<unknown>\n}\n\nexport const MarkdownLink = ({ node, handleNode }: MarkdownLinkProps) => (\n <Link title={node.title ?? undefined} href={node.url}>\n {node.children?.map(handleNode)}\n </Link>\n)\n"],"mappings":";;;;AAUA,IAAa,gBAAgB,EAAE,MAAM,iBACnC,oBAAC,MAAD;CAAM,OAAO,KAAK,SAAS,KAAA;CAAW,MAAM,KAAK;WAC9C,KAAK,UAAU,IAAI,UAAU;AAC1B,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RootContent, List as ListType } from 'mdast';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
type MarkdownListProps = {
|
|
4
4
|
node: ListType;
|
|
5
|
-
handleNode: (node:
|
|
5
|
+
handleNode: (node: RootContent) => React.ReactElement<unknown>;
|
|
6
6
|
className?: string;
|
|
7
7
|
};
|
|
8
8
|
export declare const MarkdownList: ({ node, handleNode, className }: MarkdownListProps) => React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownList.js","names":[],"sources":["../../../../src/components/markdown-content/components/MarkdownList.tsx"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"MarkdownList.js","names":[],"sources":["../../../../src/components/markdown-content/components/MarkdownList.tsx"],"sourcesContent":["import type { RootContent, List as ListType } from 'mdast'\nimport * as React from 'react'\n\nimport { cn } from '../../../styled'\nimport { List } from '../../list/List'\n\ntype MarkdownListProps = {\n node: ListType\n handleNode: (node: RootContent) => React.ReactElement<unknown>\n className?: string\n}\n\nexport const MarkdownList = ({\n node,\n handleNode,\n className\n}: MarkdownListProps) => (\n <List\n ordered={node.ordered || undefined}\n className={cn(\n '[&_p]:inline',\n '[&_p]:before:hidden',\n '[&_p]:after:hidden',\n className\n )}\n >\n {node.children?.map(handleNode)}\n </List>\n)\n"],"mappings":";;;;;AAYA,IAAa,gBAAgB,EAC3B,MACA,YACA,gBAEA,oBAAC,MAAD;CACE,SAAS,KAAK,WAAW,KAAA;CACzB,WAAW,GACT,gBACA,uBACA,sBACA,SACF;WAEC,KAAK,UAAU,IAAI,UAAU;AAC1B,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RootContent, ListItem } from 'mdast';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
type MarkdownListItemProps = {
|
|
4
4
|
node: ListItem;
|
|
5
|
-
handleNode: (node:
|
|
5
|
+
handleNode: (node: RootContent) => React.ReactElement<unknown>;
|
|
6
6
|
};
|
|
7
7
|
export declare const MarkdownListItem: ({ node, handleNode }: MarkdownListItemProps) => React.JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownListItem.js","names":[],"sources":["../../../../src/components/markdown-content/components/MarkdownListItem.tsx"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"MarkdownListItem.js","names":[],"sources":["../../../../src/components/markdown-content/components/MarkdownListItem.tsx"],"sourcesContent":["import type { RootContent, ListItem } from 'mdast'\nimport * as React from 'react'\n\nimport { List } from '../../list/List'\n\ntype MarkdownListItemProps = {\n node: ListItem\n handleNode: (node: RootContent) => React.ReactElement<unknown>\n}\n\nexport const MarkdownListItem = ({\n node,\n handleNode\n}: MarkdownListItemProps) => (\n <List.Item>{node.children?.map(handleNode)}</List.Item>\n)\n"],"mappings":";;;;AAUA,IAAa,oBAAoB,EAC/B,MACA,iBAEA,oBAAC,KAAK,MAAN,EAAA,UAAY,KAAK,UAAU,IAAI,UAAU,EAAa,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RootContent, Paragraph } from 'mdast';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
type MarkdownParagraphProps = {
|
|
4
4
|
node: Paragraph;
|
|
5
|
-
handleNode: (node:
|
|
5
|
+
handleNode: (node: RootContent) => React.ReactElement<unknown>;
|
|
6
6
|
};
|
|
7
7
|
export declare const MarkdownParagraph: ({ node, handleNode, ...rest }: MarkdownParagraphProps) => React.JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownParagraph.js","names":[],"sources":["../../../../src/components/markdown-content/components/MarkdownParagraph.tsx"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"MarkdownParagraph.js","names":[],"sources":["../../../../src/components/markdown-content/components/MarkdownParagraph.tsx"],"sourcesContent":["import type { RootContent, Paragraph } from 'mdast'\nimport * as React from 'react'\n\nimport { Text } from '../../text/Text'\n\ntype MarkdownParagraphProps = {\n node: Paragraph\n handleNode: (node: RootContent) => React.ReactElement<unknown>\n}\n\nexport const MarkdownParagraph = ({\n node,\n handleNode,\n ...rest\n}: MarkdownParagraphProps) => (\n <Text {...rest}>{node.children?.map(handleNode)}</Text>\n)\n"],"mappings":";;;;AAUA,IAAa,qBAAqB,EAChC,MACA,YACA,GAAG,WAEH,oBAAC,MAAD;CAAM,GAAI;WAAO,KAAK,UAAU,IAAI,UAAU;AAAQ,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RootContent, Strong } from 'mdast';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
type MarkdownStrongProps = {
|
|
4
4
|
node: Strong;
|
|
5
|
-
handleNode: (node:
|
|
5
|
+
handleNode: (node: RootContent) => React.ReactElement<unknown>;
|
|
6
6
|
};
|
|
7
7
|
export declare const MarkdownStrong: ({ node, handleNode }: MarkdownStrongProps) => React.JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownStrong.js","names":[],"sources":["../../../../src/components/markdown-content/components/MarkdownStrong.tsx"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"MarkdownStrong.js","names":[],"sources":["../../../../src/components/markdown-content/components/MarkdownStrong.tsx"],"sourcesContent":["import type { RootContent, Strong } from 'mdast'\nimport * as React from 'react'\n\nimport { styled } from '../../../styled'\n\ntype MarkdownStrongProps = {\n node: Strong\n handleNode: (node: RootContent) => React.ReactElement<unknown>\n}\n\nconst StyledMarkdownStrong = styled('strong', {\n base: ['font-semibold']\n})\n\nexport const MarkdownStrong = ({ node, handleNode }: MarkdownStrongProps) => (\n <StyledMarkdownStrong>{node.children?.map(handleNode)}</StyledMarkdownStrong>\n)\n"],"mappings":";;;;AAUA,IAAM,uBAAuB,OAAO,UAAU,EAC5C,MAAM,CAAC,eAAe,EACxB,CAAC;AAED,IAAa,kBAAkB,EAAE,MAAM,iBACrC,oBAAC,sBAAD,EAAA,UAAuB,KAAK,UAAU,IAAI,UAAU,EAAwB,CAAA"}
|
|
@@ -41,7 +41,7 @@ var NavigationMenuComponent = ({ children, className, ...rest }) => {
|
|
|
41
41
|
}, [React$1.Children.toArray(children).length]);
|
|
42
42
|
React$1.useEffect(() => {
|
|
43
43
|
let timer;
|
|
44
|
-
if (activeItem === "") timer = setTimeout(
|
|
44
|
+
if (activeItem === "") timer = setTimeout(setOffset, 200, null);
|
|
45
45
|
return () => {
|
|
46
46
|
if (timer !== null) clearTimeout(timer);
|
|
47
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationMenu.js","names":[],"sources":["../../../src/components/navigation/NavigationMenu.tsx"],"sourcesContent":["import * as NavigationMenuPrimitive from '@radix-ui/react-navigation-menu'\nimport * as React from 'react'\n\nimport { styled, cn } from '../../styled'\nimport { colorSchemes as navigationMenuColorSchemes } from './NavigationMenu.colorscheme.config'\nimport { NavigationMenuContext } from './NavigationMenu.context'\nimport { NavigationMenuDropdown } from './NavigationMenuDropdown'\nimport { NavigationMenuDropdownContent } from './NavigationMenuDropdownContent'\nimport {\n NavigationMenuDropdownItem,\n NavigationMenuDropdownItemTitle\n} from './NavigationMenuDropdownItem'\nimport { NavigationMenuDropdownTrigger } from './NavigationMenuDropdownTrigger'\nimport { NavigationMenuLink } from './NavigationMenuLink'\n\nconst StyledMenu = styled(NavigationMenuPrimitive.Root, {\n base: ['flex', 'justify-center', 'relative']\n})\n\nconst StyledList = styled(NavigationMenuPrimitive.List, {\n base: ['flex', 'justify-center', 'items-center', 'gap-1', 'list-none']\n})\n\nconst StyledViewport = styled(NavigationMenuPrimitive.Viewport, {\n base: ['z-2147483647']\n})\n\nconst ViewportPosition = styled('div', {\n base: ['absolute', 'left-0', 'top-full', 'w-full', 'flex', 'justify-center']\n})\n\nconst NavigationMenuComponent = ({\n children,\n className,\n ...rest\n}: React.ComponentProps<typeof StyledMenu>) => {\n const [offset, setOffset] = React.useState<number | null | undefined>()\n const [activeItem, setActiveItem] = React.useState<string | undefined>()\n const listRef = React.useRef<HTMLUListElement>(null)\n const listWidthRef = React.useRef(0)\n\n // Cache the resting list width. It must be measured while the menu is closed:\n // as a dropdown opens, its content is briefly laid out inline in the trigger\n // row, so a width read during the open transition is inflated. Held in a ref\n // (not state) since it only feeds the imperative offset calc below and never\n // renders. Re-measured when the item count changes; stale on resize.\n React.useLayoutEffect(() => {\n if (listRef.current) {\n listWidthRef.current = listRef.current.offsetWidth\n }\n }, [React.Children.toArray(children).length])\n\n React.useEffect(() => {\n let timer: ReturnType<typeof setTimeout>\n\n // Delay transitioning back to initial position\n // to allow enough time for fadeOut animation to complete\n if (activeItem === '') {\n timer = setTimeout(
|
|
1
|
+
{"version":3,"file":"NavigationMenu.js","names":[],"sources":["../../../src/components/navigation/NavigationMenu.tsx"],"sourcesContent":["import * as NavigationMenuPrimitive from '@radix-ui/react-navigation-menu'\nimport * as React from 'react'\n\nimport { styled, cn } from '../../styled'\nimport { colorSchemes as navigationMenuColorSchemes } from './NavigationMenu.colorscheme.config'\nimport { NavigationMenuContext } from './NavigationMenu.context'\nimport { NavigationMenuDropdown } from './NavigationMenuDropdown'\nimport { NavigationMenuDropdownContent } from './NavigationMenuDropdownContent'\nimport {\n NavigationMenuDropdownItem,\n NavigationMenuDropdownItemTitle\n} from './NavigationMenuDropdownItem'\nimport { NavigationMenuDropdownTrigger } from './NavigationMenuDropdownTrigger'\nimport { NavigationMenuLink } from './NavigationMenuLink'\n\nconst StyledMenu = styled(NavigationMenuPrimitive.Root, {\n base: ['flex', 'justify-center', 'relative']\n})\n\nconst StyledList = styled(NavigationMenuPrimitive.List, {\n base: ['flex', 'justify-center', 'items-center', 'gap-1', 'list-none']\n})\n\nconst StyledViewport = styled(NavigationMenuPrimitive.Viewport, {\n base: ['z-2147483647']\n})\n\nconst ViewportPosition = styled('div', {\n base: ['absolute', 'left-0', 'top-full', 'w-full', 'flex', 'justify-center']\n})\n\nconst NavigationMenuComponent = ({\n children,\n className,\n ...rest\n}: React.ComponentProps<typeof StyledMenu>) => {\n const [offset, setOffset] = React.useState<number | null | undefined>()\n const [activeItem, setActiveItem] = React.useState<string | undefined>()\n const listRef = React.useRef<HTMLUListElement>(null)\n const listWidthRef = React.useRef(0)\n\n // Cache the resting list width. It must be measured while the menu is closed:\n // as a dropdown opens, its content is briefly laid out inline in the trigger\n // row, so a width read during the open transition is inflated. Held in a ref\n // (not state) since it only feeds the imperative offset calc below and never\n // renders. Re-measured when the item count changes; stale on resize.\n React.useLayoutEffect(() => {\n if (listRef.current) {\n listWidthRef.current = listRef.current.offsetWidth\n }\n }, [React.Children.toArray(children).length])\n\n React.useEffect(() => {\n let timer: ReturnType<typeof setTimeout>\n\n // Delay transitioning back to initial position\n // to allow enough time for fadeOut animation to complete\n if (activeItem === '') {\n timer = setTimeout(setOffset, 200, null)\n }\n\n return () => {\n if (timer !== null) {\n clearTimeout(timer)\n }\n }\n }, [activeItem])\n\n // Radix has no built-in way to align the viewport with the active trigger, so\n // the offset is computed here. https://github.com/radix-ui/primitives/issues/1462\n const onNodeUpdate = React.useCallback(\n (trigger: HTMLButtonElement, itemValue: string) => {\n const listWidth = listWidthRef.current\n if (trigger && listWidth && activeItem === itemValue) {\n const listCenter = listWidth / 2\n\n const triggerOffsetRight =\n listWidth -\n trigger.offsetLeft -\n trigger.offsetWidth +\n trigger.offsetWidth / 2\n\n setOffset(Math.round(listCenter - triggerOffsetRight))\n }\n\n return trigger\n },\n [activeItem]\n )\n\n const contextValue = React.useMemo(() => ({ onNodeUpdate }), [onNodeUpdate])\n\n return (\n <NavigationMenuContext value={contextValue}>\n <StyledMenu\n className={cn(className)}\n style={navigationMenuColorSchemes['light']}\n onValueChange={setActiveItem}\n {...rest}\n >\n <StyledList ref={listRef}>{children}</StyledList>\n <ViewportPosition>\n <StyledViewport\n style={{ '--navigation-menu-viewport-offset': `${offset || 0}px` }}\n className={cn([\n 'data-[state=open]:animate-fade-in',\n 'data-[state=closed]:animate-fade-out',\n 'translate-x-(--navigation-menu-viewport-offset)'\n ])}\n />\n </ViewportPosition>\n </StyledMenu>\n </NavigationMenuContext>\n )\n}\n\nexport const NavigationMenu = /* @__PURE__ */ Object.assign(\n NavigationMenuComponent,\n {\n Link: NavigationMenuLink,\n Dropdown: NavigationMenuDropdown,\n DropdownContent: NavigationMenuDropdownContent,\n DropdownItem: NavigationMenuDropdownItem,\n DropdownItemTitle: NavigationMenuDropdownItemTitle,\n DropdownTrigger: NavigationMenuDropdownTrigger\n }\n)\n\nNavigationMenuComponent.displayName = 'NavigationMenu'\n"],"mappings":";;;;;;;;;;;;AAeA,IAAM,aAAa,OAAO,wBAAwB,MAAM,EACtD,MAAM;CAAC;CAAQ;CAAkB;AAAU,EAC7C,CAAC;AAED,IAAM,aAAa,OAAO,wBAAwB,MAAM,EACtD,MAAM;CAAC;CAAQ;CAAkB;CAAgB;CAAS;AAAW,EACvE,CAAC;AAED,IAAM,iBAAiB,OAAO,wBAAwB,UAAU,EAC9D,MAAM,CAAC,cAAc,EACvB,CAAC;AAED,IAAM,mBAAmB,OAAO,OAAO,EACrC,MAAM;CAAC;CAAY;CAAU;CAAY;CAAU;CAAQ;AAAgB,EAC7E,CAAC;AAED,IAAM,2BAA2B,EAC/B,UACA,WACA,GAAG,WAC0C;CAC7C,MAAM,CAAC,QAAQ,aAAa,QAAM,SAAoC;CACtE,MAAM,CAAC,YAAY,iBAAiB,QAAM,SAA6B;CACvE,MAAM,UAAU,QAAM,OAAyB,IAAI;CACnD,MAAM,eAAe,QAAM,OAAO,CAAC;CAOnC,QAAM,sBAAsB;EAC1B,IAAI,QAAQ,SACV,aAAa,UAAU,QAAQ,QAAQ;CAE3C,GAAG,CAAC,QAAM,SAAS,QAAQ,QAAQ,CAAC,CAAC,MAAM,CAAC;CAE5C,QAAM,gBAAgB;EACpB,IAAI;EAIJ,IAAI,eAAe,IACjB,QAAQ,WAAW,WAAW,KAAK,IAAI;EAGzC,aAAa;GACX,IAAI,UAAU,MACZ,aAAa,KAAK;EAEtB;CACF,GAAG,CAAC,UAAU,CAAC;CAIf,MAAM,eAAe,QAAM,aACxB,SAA4B,cAAsB;EACjD,MAAM,YAAY,aAAa;EAC/B,IAAI,WAAW,aAAa,eAAe,WAAW;GACpD,MAAM,aAAa,YAAY;GAE/B,MAAM,qBACJ,YACA,QAAQ,aACR,QAAQ,cACR,QAAQ,cAAc;GAExB,UAAU,KAAK,MAAM,aAAa,kBAAkB,CAAC;EACvD;EAEA,OAAO;CACT,GACA,CAAC,UAAU,CACb;CAIA,OACE,oBAAC,uBAAD;EAAuB,OAHJ,QAAM,eAAe,EAAE,aAAa,IAAI,CAAC,YAAY,CAG1C;YAC5B,qBAAC,YAAD;GACE,WAAW,GAAG,SAAS;GACvB,OAAO,aAA2B;GAClC,eAAe;GACf,GAAI;aAJN,CAME,oBAAC,YAAD;IAAY,KAAK;IAAU;GAAqB,CAAA,GAChD,oBAAC,kBAAD,EAAA,UACE,oBAAC,gBAAD;IACE,OAAO,EAAE,qCAAqC,GAAG,UAAU,EAAE,IAAI;IACjE,WAAW,GAAG;KACZ;KACA;KACA;IACF,CAAC;GACF,CAAA,EACe,CAAA,CACR;;CACS,CAAA;AAE3B;AAEA,IAAa,iBAAiC,uBAAO,OACnD,yBACA;CACE,MAAM;CACN,UAAU;CACV,iBAAiB;CACjB,cAAc;CACd,mBAAmB;CACnB,iBAAiB;AACnB,CACF;AAEA,wBAAwB,cAAc"}
|
|
@@ -9,9 +9,9 @@ import { Fragment, jsx } from "react/jsx-runtime";
|
|
|
9
9
|
//#region src/components/pagination/PaginationItems.tsx
|
|
10
10
|
var PaginationItems = () => {
|
|
11
11
|
const { paginationItems } = usePagination();
|
|
12
|
-
return /* @__PURE__ */ jsx(Fragment, { children: paginationItems.map((paginationItem
|
|
12
|
+
return /* @__PURE__ */ jsx(Fragment, { children: paginationItems.map((paginationItem) => {
|
|
13
13
|
switch (paginationItem) {
|
|
14
|
-
case VIEW_ALL_POPOVER: return /* @__PURE__ */ jsx(PaginationPopover, {}, paginationItem
|
|
14
|
+
case VIEW_ALL_POPOVER: return /* @__PURE__ */ jsx(PaginationPopover, {}, paginationItem);
|
|
15
15
|
case GO_TO_PREVIOUS_PAGE: return /* @__PURE__ */ jsx(PaginationPreviousButton, {}, paginationItem);
|
|
16
16
|
case GO_TO_NEXT_PAGE: return /* @__PURE__ */ jsx(PaginationNextButton, {}, paginationItem);
|
|
17
17
|
default: return /* @__PURE__ */ jsx(PaginationPage, { pageNumber: paginationItem }, paginationItem);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaginationItems.js","names":[],"sources":["../../../src/components/pagination/PaginationItems.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {\n GO_TO_NEXT_PAGE,\n GO_TO_PREVIOUS_PAGE,\n VIEW_ALL_POPOVER\n} from './pagination.constants'\nimport { PaginationNextButton } from './PaginationNextButton'\nimport { PaginationPage } from './PaginationPage'\nimport { PaginationPopover } from './PaginationPopover'\nimport { PaginationPreviousButton } from './PaginationPreviousButton'\nimport { usePagination } from './usePagination'\n\nexport const PaginationItems = () => {\n const { paginationItems } = usePagination()\n\n return (\n <>\n {paginationItems.map((paginationItem
|
|
1
|
+
{"version":3,"file":"PaginationItems.js","names":[],"sources":["../../../src/components/pagination/PaginationItems.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {\n GO_TO_NEXT_PAGE,\n GO_TO_PREVIOUS_PAGE,\n VIEW_ALL_POPOVER\n} from './pagination.constants'\nimport { PaginationNextButton } from './PaginationNextButton'\nimport { PaginationPage } from './PaginationPage'\nimport { PaginationPopover } from './PaginationPopover'\nimport { PaginationPreviousButton } from './PaginationPreviousButton'\nimport { usePagination } from './usePagination'\n\nexport const PaginationItems = () => {\n const { paginationItems } = usePagination()\n\n return (\n <>\n {paginationItems.map((paginationItem) => {\n switch (paginationItem) {\n case VIEW_ALL_POPOVER:\n return <PaginationPopover key={paginationItem} />\n case GO_TO_PREVIOUS_PAGE:\n return <PaginationPreviousButton key={paginationItem} />\n case GO_TO_NEXT_PAGE:\n return <PaginationNextButton key={paginationItem} />\n default:\n return (\n <PaginationPage\n key={paginationItem}\n pageNumber={paginationItem}\n />\n )\n }\n })}\n </>\n )\n}\n"],"mappings":";;;;;;;;;AAaA,IAAa,wBAAwB;CACnC,MAAM,EAAE,oBAAoB,cAAc;CAE1C,OACE,oBAAA,UAAA,EAAA,UACG,gBAAgB,KAAK,mBAAmB;EACvC,QAAQ,gBAAR;GACE,KAAK,kBACH,OAAO,oBAAC,mBAAD,CAAyC,GAAjB,cAAiB;GAClD,KAAK,qBACH,OAAO,oBAAC,0BAAD,CAAgD,GAAjB,cAAiB;GACzD,KAAK,iBACH,OAAO,oBAAC,sBAAD,CAA4C,GAAjB,cAAiB;GACrD,SACE,OACE,oBAAC,gBAAD,EAEE,YAAY,eACb,GAFM,cAEN;EAEP;CACF,CAAC,EACD,CAAA;AAEN"}
|
|
@@ -29,7 +29,7 @@ var getPaginationElementsToRender = (currentPage, pagesCount, visibleElementsCou
|
|
|
29
29
|
if (canFitViewAllPopover) visiblePagesCount -= 1;
|
|
30
30
|
if (canFitEdgePage) visiblePagesCount -= 1;
|
|
31
31
|
const firstPage = paginationPages[0];
|
|
32
|
-
const lastPage = paginationPages
|
|
32
|
+
const lastPage = paginationPages.at(-1);
|
|
33
33
|
/**
|
|
34
34
|
* If we're truncating and current page is at the start of the page list,
|
|
35
35
|
* render the initial truncated page list, e.g.
|
|
@@ -104,14 +104,16 @@ var getPaginationElementsToRender = (currentPage, pagesCount, visibleElementsCou
|
|
|
104
104
|
};
|
|
105
105
|
var findNextAvailablePage = (startPage, disabledPages, pagesCount) => {
|
|
106
106
|
if (startPage > pagesCount) return;
|
|
107
|
+
const disabledSet = new Set(disabledPages);
|
|
107
108
|
let nextPage = startPage;
|
|
108
|
-
while (
|
|
109
|
+
while (disabledSet.has(nextPage)) nextPage++;
|
|
109
110
|
return nextPage;
|
|
110
111
|
};
|
|
111
112
|
var findPreviousAvailablePage = (startPage, disabledPages) => {
|
|
112
113
|
if (startPage < 1) return;
|
|
114
|
+
const disabledSet = new Set(disabledPages);
|
|
113
115
|
let previousPage = startPage;
|
|
114
|
-
while (
|
|
116
|
+
while (disabledSet.has(previousPage)) previousPage--;
|
|
115
117
|
return previousPage;
|
|
116
118
|
};
|
|
117
119
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.helper.js","names":[],"sources":["../../../src/components/pagination/pagination.helper.ts"],"sourcesContent":["import {\n GO_TO_NEXT_PAGE,\n GO_TO_PREVIOUS_PAGE,\n VIEW_ALL_POPOVER\n} from './pagination.constants'\nimport type { PaginationItemsToRender } from './types'\n\nexport const getPaginationElementsToRender = (\n currentPage: number,\n pagesCount: number,\n visibleElementsCount: number\n): PaginationItemsToRender => {\n const paginationPages = Array.from(\n { length: pagesCount },\n (_, index) => index + 1\n )\n\n /*\n * As we always show the `<` `>` arrows,\n * subtract 2 from `visibleElementsCount` (one for each of the GO_TO_PREVIOUS/NEXT_PAGE arrows)\n * to get the `visiblePagesCount`\n */\n let visiblePagesCount = visibleElementsCount - 2\n const withPreviousNextPageArrows = (paginationPages) => [\n GO_TO_PREVIOUS_PAGE,\n ...paginationPages,\n GO_TO_NEXT_PAGE\n ]\n\n /**\n * If fewer pages than threshold for truncating render them all.\n *\n * pagesCount: 6\n * visibleElementsCount: >=6\n * returns [GO_TO_PREVIOUS_PAGE, 1, 2, 3, 4, GO_TO_NEXT_PAGE]\n * +---+ +---+ +---+ +---+ +---+ +---+\n * | < | | 1 | | 2 | | 3 | | 4 | | > |\n * +---+ +---+ +---+ +---+ +---+ +---+\n *\n */\n if (pagesCount <= visiblePagesCount) {\n return withPreviousNextPageArrows(paginationPages)\n }\n\n /**\n * If current page is either at the very start or at the very end of the pages\n */\n const canFitEdgePage = visibleElementsCount >= 5\n const canFitViewAllPopover = visibleElementsCount >= 4\n const canFitPages = visibleElementsCount >= 3\n\n if (canFitViewAllPopover) {\n // Subtract one from visiblePagesCount to accomodate for us adding the `[…]` VIEW_ALL_POPOVER\n visiblePagesCount -= 1\n }\n\n if (canFitEdgePage) {\n // Subtract one more from visiblePagesCount to accomodate for us adding the GO_TO_PREVIOUS/NEXT_PAGE arrows\n visiblePagesCount -= 1\n }\n\n const firstPage = paginationPages[0]\n const lastPage = paginationPages
|
|
1
|
+
{"version":3,"file":"pagination.helper.js","names":[],"sources":["../../../src/components/pagination/pagination.helper.ts"],"sourcesContent":["import {\n GO_TO_NEXT_PAGE,\n GO_TO_PREVIOUS_PAGE,\n VIEW_ALL_POPOVER\n} from './pagination.constants'\nimport type { PaginationItemsToRender } from './types'\n\nexport const getPaginationElementsToRender = (\n currentPage: number,\n pagesCount: number,\n visibleElementsCount: number\n): PaginationItemsToRender => {\n const paginationPages = Array.from(\n { length: pagesCount },\n (_, index) => index + 1\n )\n\n /*\n * As we always show the `<` `>` arrows,\n * subtract 2 from `visibleElementsCount` (one for each of the GO_TO_PREVIOUS/NEXT_PAGE arrows)\n * to get the `visiblePagesCount`\n */\n let visiblePagesCount = visibleElementsCount - 2\n const withPreviousNextPageArrows = (paginationPages) => [\n GO_TO_PREVIOUS_PAGE,\n ...paginationPages,\n GO_TO_NEXT_PAGE\n ]\n\n /**\n * If fewer pages than threshold for truncating render them all.\n *\n * pagesCount: 6\n * visibleElementsCount: >=6\n * returns [GO_TO_PREVIOUS_PAGE, 1, 2, 3, 4, GO_TO_NEXT_PAGE]\n * +---+ +---+ +---+ +---+ +---+ +---+\n * | < | | 1 | | 2 | | 3 | | 4 | | > |\n * +---+ +---+ +---+ +---+ +---+ +---+\n *\n */\n if (pagesCount <= visiblePagesCount) {\n return withPreviousNextPageArrows(paginationPages)\n }\n\n /**\n * If current page is either at the very start or at the very end of the pages\n */\n const canFitEdgePage = visibleElementsCount >= 5\n const canFitViewAllPopover = visibleElementsCount >= 4\n const canFitPages = visibleElementsCount >= 3\n\n if (canFitViewAllPopover) {\n // Subtract one from visiblePagesCount to accomodate for us adding the `[…]` VIEW_ALL_POPOVER\n visiblePagesCount -= 1\n }\n\n if (canFitEdgePage) {\n // Subtract one more from visiblePagesCount to accomodate for us adding the GO_TO_PREVIOUS/NEXT_PAGE arrows\n visiblePagesCount -= 1\n }\n\n const firstPage = paginationPages[0]\n // Non-null: this line is only reached when pagesCount exceeds the visible\n // threshold, so paginationPages always has a last element. `.at()` widens to\n // `T | undefined`, which the index access it replaced did not.\n const lastPage = paginationPages.at(-1)!\n\n /**\n * If we're truncating and current page is at the start of the page list,\n * render the initial truncated page list, e.g.\n *\n * pagesCount: 8\n * currentPage: 1/2\n * visibleElementsCount: 6\n * returns [GO_TO_PREVIOUS_PAGE, 1, 2, VIEW_ALL_POPOVER, 6, GO_TO_NEXT_PAGE]\n * +---+ +---+ +---+ +---+ +---+ +---+\n * | < | | 1 | | 2 | | … | | 8 | | > |\n * +---+ +---+ +---+ +---+ +---+ +---+\n *\n */\n if (currentPage < visiblePagesCount) {\n const newPaginationItems = [] as PaginationItemsToRender\n if (canFitPages) {\n newPaginationItems.push(...paginationPages.slice(0, visiblePagesCount))\n }\n if (canFitViewAllPopover) {\n newPaginationItems.push(VIEW_ALL_POPOVER)\n }\n if (canFitEdgePage) {\n newPaginationItems.push(lastPage)\n }\n return withPreviousNextPageArrows(newPaginationItems)\n }\n\n /**\n * If we're truncating and the current page is towards the end of the\n * page list (depending on visibleElementsCount),\n * render a truncated page list from the end, e.g.\n *\n * pagesCount: 8\n * currentPage: 7/8\n * visibleElementsCount: 6\n * returns [GO_TO_PREVIOUS_PAGE, 1, VIEW_ALL_POPOVER, 7, 8, GO_TO_NEXT_PAGE]\n * +---+ +---+ +---+ +---+ +---+ +---+\n * | < | | 1 | | … | | 7 | | 8 | | > |\n * +---+ +---+ +---+ +---+ +---+ +---+\n *\n */\n if (currentPage > pagesCount - visiblePagesCount) {\n const newPaginationItems = [] as PaginationItemsToRender\n if (canFitEdgePage) {\n newPaginationItems.push(firstPage)\n }\n if (canFitViewAllPopover) {\n newPaginationItems.push(VIEW_ALL_POPOVER)\n }\n if (canFitPages) {\n newPaginationItems.push(\n ...paginationPages.slice(pagesCount - visiblePagesCount, pagesCount)\n )\n }\n return withPreviousNextPageArrows(newPaginationItems)\n }\n\n /**\n * If we're truncating and the current page doesn't meet any of the previous conditions\n * (we're in the middle)\n * render a truncated page list from a specific index relative to `currentPage`, e.g.\n *\n * currentPage: 4\n * visibleElementsCount: 6 // VisibleElementsAmount.LESS\n * returns [GO_TO_PREVIOUS_PAGE, 3, 4, VIEW_ALL_POPOVER, 6, GO_TO_NEXT_PAGE]\n * +---+ +---+ +---+ +---+ +---+ +---+\n * | < | | 3 | | 4 | | … | | 6 | | > |\n * +---+ +---+ +---+ +---+ +---+ +---+\n *\n * currentPage: 6\n * visibleElementsCount: 8 // VisibleElementsAmount.MORE\n * returns [GO_TO_PREVIOUS_PAGE, 4, 5, 6, 7, VIEW_ALL_POPOVER, 10, GO_TO_NEXT_PAGE]\n * +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+\n * | < | | 4 | | 5 | | 6 | | 7 | | … | | 10 | | > |\n * +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+\n */\n const canFitCurrentPage = canFitPages\n const canFitCurrentPageAndPreviousPage = visibleElementsCount >= 6\n const canFitCurrentPageAndPreviousPageAndNextPage = visibleElementsCount >= 7\n const canFitLastPage = canFitEdgePage\n\n const newPaginationItems = [] as PaginationItemsToRender\n if (canFitCurrentPageAndPreviousPageAndNextPage) {\n newPaginationItems.push(\n ...paginationPages.slice(\n currentPage + 1 - visiblePagesCount,\n currentPage + 1\n )\n )\n } else if (canFitCurrentPageAndPreviousPage) {\n newPaginationItems.push(\n ...paginationPages.slice(currentPage - visiblePagesCount, currentPage)\n )\n } else if (canFitCurrentPage) {\n newPaginationItems.push(\n ...paginationPages.slice(currentPage - 1, currentPage - 1 + 1)\n )\n }\n if (canFitViewAllPopover) {\n newPaginationItems.push(VIEW_ALL_POPOVER)\n }\n if (canFitLastPage) {\n newPaginationItems.push(lastPage)\n }\n return withPreviousNextPageArrows(newPaginationItems)\n}\n\nexport const findNextAvailablePage = (\n startPage: number,\n disabledPages: number[],\n pagesCount: number\n): number | undefined => {\n if (startPage > pagesCount) return\n const disabledSet = new Set(disabledPages)\n let nextPage = startPage\n while (disabledSet.has(nextPage)) {\n nextPage++\n }\n return nextPage\n}\n\nexport const findPreviousAvailablePage = (\n startPage: number,\n disabledPages: number[]\n): number | undefined => {\n if (startPage < 1) return\n const disabledSet = new Set(disabledPages)\n let previousPage = startPage\n while (disabledSet.has(previousPage)) {\n previousPage--\n }\n return previousPage\n}\n"],"mappings":";;AAOA,IAAa,iCACX,aACA,YACA,yBAC4B;CAC5B,MAAM,kBAAkB,MAAM,KAC5B,EAAE,QAAQ,WAAW,IACpB,GAAG,UAAU,QAAQ,CACxB;CAOA,IAAI,oBAAoB,uBAAuB;CAC/C,MAAM,8BAA8B,oBAAoB;EACtD;EACA,GAAG;EACH;CACF;;;;;;;;;;;;CAaA,IAAI,cAAc,mBAChB,OAAO,2BAA2B,eAAe;;;;CAMnD,MAAM,iBAAiB,wBAAwB;CAC/C,MAAM,uBAAuB,wBAAwB;CACrD,MAAM,cAAc,wBAAwB;CAE5C,IAAI,sBAEF,qBAAqB;CAGvB,IAAI,gBAEF,qBAAqB;CAGvB,MAAM,YAAY,gBAAgB;CAIlC,MAAM,WAAW,gBAAgB,GAAG,EAAE;;;;;;;;;;;;;;CAetC,IAAI,cAAc,mBAAmB;EACnC,MAAM,qBAAqB,CAAC;EAC5B,IAAI,aACF,mBAAmB,KAAK,GAAG,gBAAgB,MAAM,GAAG,iBAAiB,CAAC;EAExE,IAAI,sBACF,mBAAmB,KAAK,gBAAgB;EAE1C,IAAI,gBACF,mBAAmB,KAAK,QAAQ;EAElC,OAAO,2BAA2B,kBAAkB;CACtD;;;;;;;;;;;;;;;CAgBA,IAAI,cAAc,aAAa,mBAAmB;EAChD,MAAM,qBAAqB,CAAC;EAC5B,IAAI,gBACF,mBAAmB,KAAK,SAAS;EAEnC,IAAI,sBACF,mBAAmB,KAAK,gBAAgB;EAE1C,IAAI,aACF,mBAAmB,KACjB,GAAG,gBAAgB,MAAM,aAAa,mBAAmB,UAAU,CACrE;EAEF,OAAO,2BAA2B,kBAAkB;CACtD;;;;;;;;;;;;;;;;;;;;CAqBA,MAAM,oBAAoB;CAC1B,MAAM,mCAAmC,wBAAwB;CACjE,MAAM,8CAA8C,wBAAwB;CAC5E,MAAM,iBAAiB;CAEvB,MAAM,qBAAqB,CAAC;CAC5B,IAAI,6CACF,mBAAmB,KACjB,GAAG,gBAAgB,MACjB,cAAc,IAAI,mBAClB,cAAc,CAChB,CACF;MACK,IAAI,kCACT,mBAAmB,KACjB,GAAG,gBAAgB,MAAM,cAAc,mBAAmB,WAAW,CACvE;MACK,IAAI,mBACT,mBAAmB,KACjB,GAAG,gBAAgB,MAAM,cAAc,GAAG,cAAc,IAAI,CAAC,CAC/D;CAEF,IAAI,sBACF,mBAAmB,KAAK,gBAAgB;CAE1C,IAAI,gBACF,mBAAmB,KAAK,QAAQ;CAElC,OAAO,2BAA2B,kBAAkB;AACtD;AAEA,IAAa,yBACX,WACA,eACA,eACuB;CACvB,IAAI,YAAY,YAAY;CAC5B,MAAM,cAAc,IAAI,IAAI,aAAa;CACzC,IAAI,WAAW;CACf,OAAO,YAAY,IAAI,QAAQ,GAC7B;CAEF,OAAO;AACT;AAEA,IAAa,6BACX,WACA,kBACuB;CACvB,IAAI,YAAY,GAAG;CACnB,MAAM,cAAc,IAAI,IAAI,aAAa;CACzC,IAAI,eAAe;CACnB,OAAO,YAAY,IAAI,YAAY,GACjC;CAEF,OAAO;AACT"}
|
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import * as RadixSelect from '@radix-ui/react-select';
|
|
2
1
|
import * as React from 'react';
|
|
3
|
-
|
|
2
|
+
import * as AriaComponents from 'react-aria-components';
|
|
3
|
+
type SelectMenuProps = Omit<AriaComponents.SelectProps<object>, 'className' | 'style' | 'children'> & {
|
|
4
4
|
size?: 'sm' | 'md' | 'lg';
|
|
5
5
|
theme?: 'white' | 'grey';
|
|
6
6
|
state?: 'error';
|
|
7
|
+
className?: string;
|
|
8
|
+
children?: React.ReactNode;
|
|
7
9
|
};
|
|
8
|
-
export declare const SelectMenu: (({ size, theme, state, children, ...rest }: SelectMenuProps) => React.JSX.Element) & {
|
|
9
|
-
Trigger: ({ ref, placeholder, children, ...rest }:
|
|
10
|
+
export declare const SelectMenu: (({ size, theme, state, className, children, ...rest }: SelectMenuProps) => React.JSX.Element) & {
|
|
11
|
+
Trigger: ({ ref, placeholder, children, ...rest }: Omit<AriaComponents.ButtonProps & React.RefAttributes<HTMLButtonElement>, "aria-label" | "aria-labelledby" | "children"> & {
|
|
10
12
|
placeholder?: string;
|
|
13
|
+
children?: React.ReactNode;
|
|
11
14
|
}) => React.JSX.Element;
|
|
12
|
-
Content: ({ ref, children,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
Content: ({ ref, children, offset, ...rest }: Omit<AriaComponents.PopoverProps & React.RefAttributes<HTMLElement>, "children"> & {
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
}) => React.JSX.Element;
|
|
18
|
+
Item: ({ children, textValue, ...rest }: Omit<AriaComponents.ListBoxItemProps<object>, "children"> & {
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
}) => React.JSX.Element;
|
|
21
|
+
Group: <T>(props: AriaComponents.ListBoxSectionProps<T> & React.RefAttributes<HTMLElement>) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | null;
|
|
15
22
|
Label: {
|
|
16
|
-
({ className, ...rest }:
|
|
23
|
+
({ className, ...rest }: AriaComponents.HeaderProps & React.RefAttributes<HTMLElement>): React.JSX.Element;
|
|
17
24
|
displayName: string;
|
|
18
25
|
};
|
|
19
|
-
Separator: import("../..").StyledComponent<React.
|
|
26
|
+
Separator: import("../..").StyledComponent<(props: AriaComponents.SeparatorProps & React.RefAttributes<HTMLElement>) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | null, unknown>;
|
|
20
27
|
};
|
|
21
28
|
export {};
|