@react-md/core 6.1.0 → 6.2.1
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/RootHtml.d.ts +1 -1
- package/dist/RootHtml.js.map +1 -1
- package/dist/_base.scss +1 -0
- package/dist/autocomplete/defaults.d.ts +1 -0
- package/dist/autocomplete/defaults.js +2 -6
- package/dist/autocomplete/defaults.js.map +1 -1
- package/dist/autocomplete/types.d.ts +9 -9
- package/dist/autocomplete/types.js.map +1 -1
- package/dist/avatar/Avatar.d.ts +1 -1
- package/dist/avatar/Avatar.js +1 -1
- package/dist/avatar/Avatar.js.map +1 -1
- package/dist/avatar/styles.d.ts +29 -1
- package/dist/avatar/styles.js.map +1 -1
- package/dist/box/styles.d.ts +26 -3
- package/dist/box/styles.js.map +1 -1
- package/dist/button/AsyncButton.d.ts +2 -2
- package/dist/button/AsyncButton.js.map +1 -1
- package/dist/button/Button.d.ts +1 -1
- package/dist/button/Button.js.map +1 -1
- package/dist/card/CardHeader.d.ts +1 -1
- package/dist/card/CardHeader.js.map +1 -1
- package/dist/chip/Chip.d.ts +1 -1
- package/dist/chip/Chip.js.map +1 -1
- package/dist/dialog/Dialog.d.ts +1 -1
- package/dist/dialog/Dialog.js.map +1 -1
- package/dist/expansion-panel/ExpansionPanel.d.ts +1 -1
- package/dist/expansion-panel/ExpansionPanel.js.map +1 -1
- package/dist/expansion-panel/ExpansionPanelHeader.d.ts +1 -1
- package/dist/expansion-panel/ExpansionPanelHeader.js.map +1 -1
- package/dist/files/FileInput.d.ts +1 -1
- package/dist/files/FileInput.js.map +1 -1
- package/dist/form/FormMessageContainer.d.ts +1 -1
- package/dist/form/FormMessageContainer.js.map +1 -1
- package/dist/form/InputToggle.d.ts +2 -2
- package/dist/form/InputToggle.js.map +1 -1
- package/dist/form/NativeSelect.d.ts +1 -1
- package/dist/form/NativeSelect.js.map +1 -1
- package/dist/form/OptGroup.d.ts +1 -1
- package/dist/form/OptGroup.js.map +1 -1
- package/dist/form/Password.d.ts +1 -1
- package/dist/form/Password.js.map +1 -1
- package/dist/form/Select.d.ts +2 -2
- package/dist/form/Select.js.map +1 -1
- package/dist/form/Slider.d.ts +1 -1
- package/dist/form/Slider.js.map +1 -1
- package/dist/form/Switch.d.ts +3 -3
- package/dist/form/Switch.js.map +1 -1
- package/dist/form/SwitchTrack.d.ts +1 -1
- package/dist/form/SwitchTrack.js.map +1 -1
- package/dist/form/TextArea.d.ts +2 -2
- package/dist/form/TextArea.js.map +1 -1
- package/dist/form/TextField.d.ts +1 -1
- package/dist/form/TextField.js.map +1 -1
- package/dist/form/_select.scss +1 -1
- package/dist/form/_slider.scss +1 -1
- package/dist/form/types.d.ts +5 -5
- package/dist/form/types.js.map +1 -1
- package/dist/layout/LayoutAppBar.d.ts +1 -1
- package/dist/layout/LayoutAppBar.js.map +1 -1
- package/dist/list/ListItemLink.d.ts +1 -1
- package/dist/list/ListItemLink.js.map +1 -1
- package/dist/list/ListItemText.d.ts +1 -1
- package/dist/list/ListItemText.js.map +1 -1
- package/dist/list/ListSubheader.d.ts +1 -1
- package/dist/list/ListSubheader.js.map +1 -1
- package/dist/list/types.d.ts +2 -2
- package/dist/list/types.js.map +1 -1
- package/dist/menu/Menu.d.ts +3 -3
- package/dist/menu/Menu.js.map +1 -1
- package/dist/menu/MenuItemInputToggle.d.ts +2 -2
- package/dist/menu/MenuItemInputToggle.js.map +1 -1
- package/dist/menu/MenuItemTextField.d.ts +1 -1
- package/dist/menu/MenuItemTextField.js.map +1 -1
- package/dist/menu/MenuSheet.d.ts +1 -1
- package/dist/menu/MenuSheet.js.map +1 -1
- package/dist/navigation/CollapsibleNavGroup.d.ts +2 -2
- package/dist/navigation/CollapsibleNavGroup.js.map +1 -1
- package/dist/navigation/NavItemLink.d.ts +1 -1
- package/dist/navigation/NavItemLink.js.map +1 -1
- package/dist/progress/CircularProgress.d.ts +2 -17
- package/dist/progress/CircularProgress.js +19 -23
- package/dist/progress/CircularProgress.js.map +1 -1
- package/dist/progress/LinearProgress.d.ts +5 -1
- package/dist/progress/LinearProgress.js +13 -25
- package/dist/progress/LinearProgress.js.map +1 -1
- package/dist/progress/circularProgressStyles.d.ts +62 -0
- package/dist/progress/circularProgressStyles.js +38 -0
- package/dist/progress/circularProgressStyles.js.map +1 -0
- package/dist/progress/linearProgressStyles.d.ts +38 -0
- package/dist/progress/linearProgressStyles.js +38 -0
- package/dist/progress/linearProgressStyles.js.map +1 -0
- package/dist/searching/caseInsensitive.d.ts +20 -4
- package/dist/searching/caseInsensitive.js +5 -1
- package/dist/searching/caseInsensitive.js.map +1 -1
- package/dist/searching/fuzzy.d.ts +3 -3
- package/dist/searching/fuzzy.js +5 -1
- package/dist/searching/fuzzy.js.map +1 -1
- package/dist/searching/utils.d.ts +2 -1
- package/dist/searching/utils.js +11 -2
- package/dist/searching/utils.js.map +1 -1
- package/dist/snackbar/Toast.d.ts +1 -1
- package/dist/snackbar/Toast.js.map +1 -1
- package/dist/table/TableCell.d.ts +1 -1
- package/dist/table/TableCell.js.map +1 -1
- package/dist/table/TableCheckbox.d.ts +1 -1
- package/dist/table/TableCheckbox.js.map +1 -1
- package/dist/table/TableRadio.d.ts +1 -1
- package/dist/table/TableRadio.js.map +1 -1
- package/dist/tabs/TabListScrollButton.d.ts +1 -1
- package/dist/tabs/TabListScrollButton.js.map +1 -1
- package/dist/tree/TreeItem.d.ts +2 -2
- package/dist/tree/TreeItem.js.map +1 -1
- package/dist/tree/_tree.scss +1 -1
- package/dist/types.d.ts +29 -2
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/alphaNumericSort.d.ts +9 -9
- package/dist/utils/alphaNumericSort.js +5 -1
- package/dist/utils/alphaNumericSort.js.map +1 -1
- package/dist/window-splitter/_window-splitter.scss +1 -1
- package/package.json +6 -6
- package/src/RootHtml.tsx +1 -1
- package/src/autocomplete/defaults.ts +5 -12
- package/src/autocomplete/types.ts +9 -12
- package/src/avatar/Avatar.tsx +2 -2
- package/src/avatar/styles.ts +53 -1
- package/src/box/styles.ts +34 -13
- package/src/button/AsyncButton.tsx +2 -2
- package/src/button/Button.tsx +1 -1
- package/src/card/CardHeader.tsx +1 -1
- package/src/chip/Chip.tsx +1 -1
- package/src/dialog/Dialog.tsx +1 -4
- package/src/expansion-panel/ExpansionPanel.tsx +1 -1
- package/src/expansion-panel/ExpansionPanelHeader.tsx +1 -1
- package/src/files/FileInput.tsx +1 -4
- package/src/form/FormMessageContainer.tsx +1 -1
- package/src/form/InputToggle.tsx +2 -5
- package/src/form/NativeSelect.tsx +1 -1
- package/src/form/OptGroup.tsx +1 -4
- package/src/form/Password.tsx +1 -1
- package/src/form/Select.tsx +2 -3
- package/src/form/Slider.tsx +1 -1
- package/src/form/Switch.tsx +3 -3
- package/src/form/SwitchTrack.tsx +1 -1
- package/src/form/TextArea.tsx +2 -5
- package/src/form/TextField.tsx +1 -1
- package/src/form/types.ts +5 -15
- package/src/layout/LayoutAppBar.tsx +1 -1
- package/src/list/ListItemLink.tsx +1 -1
- package/src/list/ListItemText.tsx +1 -4
- package/src/list/ListSubheader.tsx +1 -1
- package/src/list/types.ts +2 -5
- package/src/menu/Menu.tsx +3 -4
- package/src/menu/MenuItemInputToggle.tsx +2 -2
- package/src/menu/MenuItemTextField.tsx +1 -1
- package/src/menu/MenuSheet.tsx +1 -1
- package/src/navigation/CollapsibleNavGroup.tsx +2 -2
- package/src/navigation/NavItemLink.tsx +1 -1
- package/src/progress/CircularProgress.tsx +31 -53
- package/src/progress/LinearProgress.tsx +27 -40
- package/src/progress/circularProgressStyles.ts +114 -0
- package/src/progress/linearProgressStyles.ts +90 -0
- package/src/searching/caseInsensitive.ts +29 -7
- package/src/searching/fuzzy.ts +12 -6
- package/src/searching/utils.ts +13 -2
- package/src/snackbar/Toast.tsx +1 -1
- package/src/table/TableCell.tsx +1 -4
- package/src/table/TableCheckbox.tsx +1 -1
- package/src/table/TableRadio.tsx +1 -1
- package/src/tabs/TabListScrollButton.tsx +1 -1
- package/src/tree/TreeItem.tsx +2 -2
- package/src/types.ts +44 -2
- package/src/utils/alphaNumericSort.ts +17 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/table/TableCell.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ButtonHTMLAttributes,\n type ReactNode,\n type TdHTMLAttributes,\n type ThHTMLAttributes,\n forwardRef,\n} from \"react\";\n\nimport { getIcon } from \"../icon/config.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport {\n TableCellContent,\n type TableCellContentsIconRotatorProps,\n} from \"./TableCellContent.js\";\nimport { useTableConfig } from \"./TableConfigurationProvider.js\";\nimport { tableCell } from \"./tableCellStyles.js\";\nimport { type SortOrder, type TableCellConfig } from \"./types.js\";\n\nexport type TableCellAttributes = Omit<\n | TdHTMLAttributes<HTMLTableCellElement>\n | ThHTMLAttributes<HTMLTableCellElement>,\n \"scope\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport interface TableCellOptions extends TableCellConfig {\n /**\n * This is a bit of a \"weird\" prop since all it does is apply `width: 100%` to\n * this cell. This will make this specific cell fill the remaining width of\n * the table (if there is any). If no cells have this prop enabled and the\n * `fullWidth` table configuration is enabled, all cells will have an\n * equal-sized width.\n *\n * @defaultValue `false`\n */\n grow?: boolean;\n\n /**\n * This prop is only valid when the `header` prop is enabled or the\n * `TableCell` is a child of the `TableHeader` component. This will generally\n * be used with a value of `\"row\"` if you have table headers that are at the\n * start of each row instead of at the top of the table.\n *\n * @defaultValue `\"col\"`\n */\n scope?: \"row\" | \"col\" | \"rowgroup\" | \"colgroup\";\n\n /**\n *\n * @defaultValue `false`\n * @since 6.0.0 This prop is only a boolean.\n */\n sticky?: boolean;\n\n /**\n * @internal\n * @defaultValue `false`\n */\n inputToggle?: boolean;\n}\n\n/**\n * @since 6.0.0 Removed the `colSpan=\"100%\"` support since `colSpan`\n * really only supports numbers.\n * @since 6.0.0 Removed `disablePadding` in favor of `padding`.\n */\nexport interface TableCellProps extends TableCellAttributes, TableCellOptions {\n /**\n * If you want to apply a sort icon for a header cell, set this prop to either\n * `\"ascending\"` or `\"descending\"`. When you change the sort order, this prop\n * should change as well which will cause the sort icon to rotate. The default\n * behavior is to have the icon facing upwards and not-rotated when\n * `\"ascending\"`, otherwise it will rotate downwards when `\"descending\"`.\n *\n * If this prop is set to `\"none\"`, the cell will render the clickable button\n * in the children, just without the sort icon. This is so that the sort\n * behavior can still be toggled for keyboard users and will be tab-focusable.\n *\n * @see {@link beforeChildren}\n * @see {@link afterChildren}\n */\n \"aria-sort\"?: SortOrder;\n\n /**\n * An optional sort icon to use. This will be defaulted to the configured sort\n * icon from the `@react-md/core` package. If you do not want the default\n * implementation for the sort icon behavior from `react-md`, you can set this\n * prop to `null`.\n */\n sortIcon?: ReactNode;\n\n /**\n * Boolean if the sort icon should appear after the children in the cell\n * instead of before.\n */\n sortIconAfter?: boolean;\n\n /**\n * Boolean if the sort icon should be rotated instead of the default\n * direction. When this is `undefined`, it will only be `true` when the\n * `\"aria-sort\"` prop is set to `\"descending\"`. If this is not `undefined`,\n * its boolean value will always be used.\n */\n sortIconRotated?: boolean;\n\n /**\n * @defaultValue `\"horizontal\"`\n */\n padding?: \"horizontal\" | \"vertical\" | \"none\";\n\n /**\n * This can be used to apply styling or any other props to the\n * `UnstyledButton` that surrounds the `children` when the `\"aria-sort\"` prop\n * has been provided.\n *\n * @since 6.0.0\n */\n contentProps?: PropsWithRef<\n ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >;\n\n /**\n * Any additional props to pass to the `IconRotator` when the `aria-sort` prop\n * has been provided.\n *\n * @since 6.0.0\n */\n iconRotatorProps?: TableCellContentsIconRotatorProps;\n\n /**\n * Since providing an `aria-sort` prop will wrap the `children` in an\n * `UnstyledButton`, you can use this prop to render another button within the\n * table cell before the main `children`.\n *\n * @see {@link afterChildren} for an example.\n * @since 6.0.0\n */\n beforeChildren?: ReactNode;\n\n /**\n * Since providing an `aria-sort` prop will wrap the `children` in an\n * `UnstyledButton`, you can use this prop to render another button within the\n * table cell before the main `children`.\n *\n * @example\n * ```tsx\n * import { Button } from \"@react-md/core/button/Button\";\n * import { Dialog } from \"@react-md/core/dialog/Dialog\";\n * import { TableCell } from \"@react-md/core/table/TableCell\";\n * import { type SortOrder } from \"@react-md/core/table/types\";\n * import MoreVertIcon from \"@react-md/material-icons/MoreVertIcon\";\n * import type { ReactElement } from \"react\";\n * import { useState } from \"react\";\n *\n * interface Props {\n * setSort(sort: string): void;\n * sortKey: string;\n * sortOrder: SortOrder;\n * }\n *\n * function Example({ sortKey, sortOrder, setSort }: Props): ReactElement {\n * const [visible, setVisible] = useState(false);\n *\n * return (\n * <>\n * <TableCell\n * aria-sort={sortKey === \"example\" ? sortOrder : \"none\"}\n * onClick={() => setSort(\"example\")}\n * afterChildren={\n * <Button\n * aria-label=\"Options\"\n * buttonType=\"icon\"\n * onClick={() => {\n * setVisible(true)\n * }}\n * >\n * <MoreVertIcon />\n * </Button>\n * }\n * >\n * Example content\n * </TableCell>\n * <Dialog\n * aria-label=\"Options\"\n * visible={visible}\n * onRequestClose={() => setVisible(false)}\n * >\n * Pretend Content...\n * </Dialog>\n * </>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n */\n afterChildren?: ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * Creates a `<th>` or `<td>` cell with sensible styled defaults. You can create\n * a `<th>` element by enabling the `header` prop OR having a `TableCell` as a\n * child of the `TableHeader` component.\n *\n * Note: If you have a checkbox/radio column in the `TableHeader` without any\n * labels, you will need to manually set the `header={false}` prop for that cell\n * since it is invalid to have a `<th>` without any readable content for screen\n * readers.\n *\n * @see {@link https://react-md.dev/components/table | Table Demos}\n */\nexport const TableCell = forwardRef<HTMLTableCellElement, TableCellProps>(\n function TableCell(props, ref) {\n const {\n \"aria-sort\": sortOrder,\n className,\n grow = false,\n scope: propScope,\n hAlign: propHAlign,\n vAlign: propVAlign,\n header: propHeader,\n lineWrap: propDisableLineWrap,\n inputToggle,\n children,\n beforeChildren,\n afterChildren,\n sticky,\n sortIcon: propSortIcon,\n sortIconAfter = false,\n sortIconRotated,\n iconRotatorProps,\n padding = \"horizontal\",\n contentProps,\n ...remaining\n } = props;\n\n const sortIcon = getIcon(\"sort\", propSortIcon);\n\n // Note: unlike the other usages of `useTableConfig`, the `propHeader`\n // is not provided. This is so that `TableCheckbox` components can still\n // be a sticky header without being rendered as a `<th>`. This also makes\n // it so the scope can be defaulted to `col` or `row` automatically.\n const {\n header: inheritedHeader,\n hAlign,\n vAlign,\n lineWrap,\n } = useTableConfig({\n hAlign: propHAlign,\n vAlign: propVAlign,\n lineWrap: propDisableLineWrap,\n });\n const header = propHeader ?? inheritedHeader;\n\n let scope = propScope;\n if (!scope && header) {\n scope = !inheritedHeader && propHeader ? \"row\" : \"col\";\n }\n\n const Component = header ? \"th\" : \"td\";\n return (\n <Component\n {...remaining}\n ref={ref}\n aria-sort={sortOrder === \"none\" ? undefined : sortOrder}\n className={tableCell({\n className,\n grow,\n header,\n sticky,\n inputToggle,\n hAlign,\n vAlign,\n lineWrap: !sortOrder && lineWrap,\n padding: sortIcon && sortOrder ? \"none\" : padding,\n isInTableHeader: inheritedHeader,\n })}\n scope={scope}\n >\n {beforeChildren}\n <TableCellContent\n {...contentProps}\n icon={sortIcon}\n iconAfter={sortIconAfter}\n iconRotatorProps={iconRotatorProps}\n sortOrder={sortOrder}\n hAlign={hAlign}\n rotated={sortIconRotated}\n >\n {children}\n </TableCellContent>\n {afterChildren}\n </Component>\n );\n }\n);\n"],"names":["forwardRef","getIcon","TableCellContent","useTableConfig","tableCell","TableCell","props","ref","sortOrder","className","grow","scope","propScope","hAlign","propHAlign","vAlign","propVAlign","header","propHeader","lineWrap","propDisableLineWrap","inputToggle","children","beforeChildren","afterChildren","sticky","sortIcon","propSortIcon","sortIconAfter","sortIconRotated","iconRotatorProps","padding","contentProps","remaining","inheritedHeader","Component","aria-sort","undefined","isInTableHeader","icon","iconAfter","rotated"],"mapp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ASL,YAAYlB,YAAY,SAASuB;YAC1CO,iBAAiBJ;QACnB;QACAvB,OAAOA;;YAENY;0BACD,KAACrB;gBACE,GAAG8B,YAAY;gBAChBO,MAAMb;gBACNc,WAAWZ;gBACXE,kBAAkBA;gBAClBtB,WAAWA;gBACXK,QAAQA;gBACR4B,SAASZ;0BAERP;;YAEFE;;;AAGP,GACA"}
|
|
1
|
+
{"version":3,"sources":["../../src/table/TableCell.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ButtonHTMLAttributes,\n type ReactNode,\n type TdHTMLAttributes,\n type ThHTMLAttributes,\n forwardRef,\n} from \"react\";\n\nimport { getIcon } from \"../icon/config.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport {\n TableCellContent,\n type TableCellContentsIconRotatorProps,\n} from \"./TableCellContent.js\";\nimport { useTableConfig } from \"./TableConfigurationProvider.js\";\nimport { tableCell } from \"./tableCellStyles.js\";\nimport { type SortOrder, type TableCellConfig } from \"./types.js\";\n\nexport type TableCellAttributes = Omit<\n | TdHTMLAttributes<HTMLTableCellElement>\n | ThHTMLAttributes<HTMLTableCellElement>,\n \"scope\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport interface TableCellOptions extends TableCellConfig {\n /**\n * This is a bit of a \"weird\" prop since all it does is apply `width: 100%` to\n * this cell. This will make this specific cell fill the remaining width of\n * the table (if there is any). If no cells have this prop enabled and the\n * `fullWidth` table configuration is enabled, all cells will have an\n * equal-sized width.\n *\n * @defaultValue `false`\n */\n grow?: boolean;\n\n /**\n * This prop is only valid when the `header` prop is enabled or the\n * `TableCell` is a child of the `TableHeader` component. This will generally\n * be used with a value of `\"row\"` if you have table headers that are at the\n * start of each row instead of at the top of the table.\n *\n * @defaultValue `\"col\"`\n */\n scope?: \"row\" | \"col\" | \"rowgroup\" | \"colgroup\";\n\n /**\n *\n * @defaultValue `false`\n * @since 6.0.0 This prop is only a boolean.\n */\n sticky?: boolean;\n\n /**\n * @internal\n * @defaultValue `false`\n */\n inputToggle?: boolean;\n}\n\n/**\n * @since 6.0.0 Removed the `colSpan=\"100%\"` support since `colSpan`\n * really only supports numbers.\n * @since 6.0.0 Removed `disablePadding` in favor of `padding`.\n */\nexport interface TableCellProps extends TableCellAttributes, TableCellOptions {\n /**\n * If you want to apply a sort icon for a header cell, set this prop to either\n * `\"ascending\"` or `\"descending\"`. When you change the sort order, this prop\n * should change as well which will cause the sort icon to rotate. The default\n * behavior is to have the icon facing upwards and not-rotated when\n * `\"ascending\"`, otherwise it will rotate downwards when `\"descending\"`.\n *\n * If this prop is set to `\"none\"`, the cell will render the clickable button\n * in the children, just without the sort icon. This is so that the sort\n * behavior can still be toggled for keyboard users and will be tab-focusable.\n *\n * @see {@link beforeChildren}\n * @see {@link afterChildren}\n */\n \"aria-sort\"?: SortOrder;\n\n /**\n * An optional sort icon to use. This will be defaulted to the configured sort\n * icon from the `@react-md/core` package. If you do not want the default\n * implementation for the sort icon behavior from `react-md`, you can set this\n * prop to `null`.\n */\n sortIcon?: ReactNode;\n\n /**\n * Boolean if the sort icon should appear after the children in the cell\n * instead of before.\n */\n sortIconAfter?: boolean;\n\n /**\n * Boolean if the sort icon should be rotated instead of the default\n * direction. When this is `undefined`, it will only be `true` when the\n * `\"aria-sort\"` prop is set to `\"descending\"`. If this is not `undefined`,\n * its boolean value will always be used.\n */\n sortIconRotated?: boolean;\n\n /**\n * @defaultValue `\"horizontal\"`\n */\n padding?: \"horizontal\" | \"vertical\" | \"none\";\n\n /**\n * This can be used to apply styling or any other props to the\n * `UnstyledButton` that surrounds the `children` when the `\"aria-sort\"` prop\n * has been provided.\n *\n * @since 6.0.0\n */\n contentProps?: PropsWithRef<ButtonHTMLAttributes<HTMLButtonElement>>;\n\n /**\n * Any additional props to pass to the `IconRotator` when the `aria-sort` prop\n * has been provided.\n *\n * @since 6.0.0\n */\n iconRotatorProps?: TableCellContentsIconRotatorProps;\n\n /**\n * Since providing an `aria-sort` prop will wrap the `children` in an\n * `UnstyledButton`, you can use this prop to render another button within the\n * table cell before the main `children`.\n *\n * @see {@link afterChildren} for an example.\n * @since 6.0.0\n */\n beforeChildren?: ReactNode;\n\n /**\n * Since providing an `aria-sort` prop will wrap the `children` in an\n * `UnstyledButton`, you can use this prop to render another button within the\n * table cell before the main `children`.\n *\n * @example\n * ```tsx\n * import { Button } from \"@react-md/core/button/Button\";\n * import { Dialog } from \"@react-md/core/dialog/Dialog\";\n * import { TableCell } from \"@react-md/core/table/TableCell\";\n * import { type SortOrder } from \"@react-md/core/table/types\";\n * import MoreVertIcon from \"@react-md/material-icons/MoreVertIcon\";\n * import type { ReactElement } from \"react\";\n * import { useState } from \"react\";\n *\n * interface Props {\n * setSort(sort: string): void;\n * sortKey: string;\n * sortOrder: SortOrder;\n * }\n *\n * function Example({ sortKey, sortOrder, setSort }: Props): ReactElement {\n * const [visible, setVisible] = useState(false);\n *\n * return (\n * <>\n * <TableCell\n * aria-sort={sortKey === \"example\" ? sortOrder : \"none\"}\n * onClick={() => setSort(\"example\")}\n * afterChildren={\n * <Button\n * aria-label=\"Options\"\n * buttonType=\"icon\"\n * onClick={() => {\n * setVisible(true)\n * }}\n * >\n * <MoreVertIcon />\n * </Button>\n * }\n * >\n * Example content\n * </TableCell>\n * <Dialog\n * aria-label=\"Options\"\n * visible={visible}\n * onRequestClose={() => setVisible(false)}\n * >\n * Pretend Content...\n * </Dialog>\n * </>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n */\n afterChildren?: ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * Creates a `<th>` or `<td>` cell with sensible styled defaults. You can create\n * a `<th>` element by enabling the `header` prop OR having a `TableCell` as a\n * child of the `TableHeader` component.\n *\n * Note: If you have a checkbox/radio column in the `TableHeader` without any\n * labels, you will need to manually set the `header={false}` prop for that cell\n * since it is invalid to have a `<th>` without any readable content for screen\n * readers.\n *\n * @see {@link https://react-md.dev/components/table | Table Demos}\n */\nexport const TableCell = forwardRef<HTMLTableCellElement, TableCellProps>(\n function TableCell(props, ref) {\n const {\n \"aria-sort\": sortOrder,\n className,\n grow = false,\n scope: propScope,\n hAlign: propHAlign,\n vAlign: propVAlign,\n header: propHeader,\n lineWrap: propDisableLineWrap,\n inputToggle,\n children,\n beforeChildren,\n afterChildren,\n sticky,\n sortIcon: propSortIcon,\n sortIconAfter = false,\n sortIconRotated,\n iconRotatorProps,\n padding = \"horizontal\",\n contentProps,\n ...remaining\n } = props;\n\n const sortIcon = getIcon(\"sort\", propSortIcon);\n\n // Note: unlike the other usages of `useTableConfig`, the `propHeader`\n // is not provided. This is so that `TableCheckbox` components can still\n // be a sticky header without being rendered as a `<th>`. This also makes\n // it so the scope can be defaulted to `col` or `row` automatically.\n const {\n header: inheritedHeader,\n hAlign,\n vAlign,\n lineWrap,\n } = useTableConfig({\n hAlign: propHAlign,\n vAlign: propVAlign,\n lineWrap: propDisableLineWrap,\n });\n const header = propHeader ?? inheritedHeader;\n\n let scope = propScope;\n if (!scope && header) {\n scope = !inheritedHeader && propHeader ? \"row\" : \"col\";\n }\n\n const Component = header ? \"th\" : \"td\";\n return (\n <Component\n {...remaining}\n ref={ref}\n aria-sort={sortOrder === \"none\" ? undefined : sortOrder}\n className={tableCell({\n className,\n grow,\n header,\n sticky,\n inputToggle,\n hAlign,\n vAlign,\n lineWrap: !sortOrder && lineWrap,\n padding: sortIcon && sortOrder ? \"none\" : padding,\n isInTableHeader: inheritedHeader,\n })}\n scope={scope}\n >\n {beforeChildren}\n <TableCellContent\n {...contentProps}\n icon={sortIcon}\n iconAfter={sortIconAfter}\n iconRotatorProps={iconRotatorProps}\n sortOrder={sortOrder}\n hAlign={hAlign}\n rotated={sortIconRotated}\n >\n {children}\n </TableCellContent>\n {afterChildren}\n </Component>\n );\n }\n);\n"],"names":["forwardRef","getIcon","TableCellContent","useTableConfig","tableCell","TableCell","props","ref","sortOrder","className","grow","scope","propScope","hAlign","propHAlign","vAlign","propVAlign","header","propHeader","lineWrap","propDisableLineWrap","inputToggle","children","beforeChildren","afterChildren","sticky","sortIcon","propSortIcon","sortIconAfter","sortIconRotated","iconRotatorProps","padding","contentProps","remaining","inheritedHeader","Component","aria-sort","undefined","isInTableHeader","icon","iconAfter","rotated"],"mappings":"AAAA;;AAEA,SAKEA,UAAU,QACL,QAAQ;AAEf,SAASC,OAAO,QAAQ,oBAAoB;AAE5C,SACEC,gBAAgB,QAEX,wBAAwB;AAC/B,SAASC,cAAc,QAAQ,kCAAkC;AACjE,SAASC,SAAS,QAAQ,uBAAuB;AAwLjD;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAMC,0BAAYL,WACvB,SAASK,UAAUC,KAAK,EAAEC,GAAG;IAC3B,MAAM,EACJ,aAAaC,SAAS,EACtBC,SAAS,EACTC,OAAO,KAAK,EACZC,OAAOC,SAAS,EAChBC,QAAQC,UAAU,EAClBC,QAAQC,UAAU,EAClBC,QAAQC,UAAU,EAClBC,UAAUC,mBAAmB,EAC7BC,WAAW,EACXC,QAAQ,EACRC,cAAc,EACdC,aAAa,EACbC,MAAM,EACNC,UAAUC,YAAY,EACtBC,gBAAgB,KAAK,EACrBC,eAAe,EACfC,gBAAgB,EAChBC,UAAU,YAAY,EACtBC,YAAY,EACZ,GAAGC,WACJ,GAAG3B;IAEJ,MAAMoB,WAAWzB,QAAQ,QAAQ0B;IAEjC,sEAAsE;IACtE,wEAAwE;IACxE,yEAAyE;IACzE,oEAAoE;IACpE,MAAM,EACJV,QAAQiB,eAAe,EACvBrB,MAAM,EACNE,MAAM,EACNI,QAAQ,EACT,GAAGhB,eAAe;QACjBU,QAAQC;QACRC,QAAQC;QACRG,UAAUC;IACZ;IACA,MAAMH,SAASC,cAAcgB;IAE7B,IAAIvB,QAAQC;IACZ,IAAI,CAACD,SAASM,QAAQ;QACpBN,QAAQ,CAACuB,mBAAmBhB,aAAa,QAAQ;IACnD;IAEA,MAAMiB,YAAYlB,SAAS,OAAO;IAClC,qBACE,MAACkB;QACE,GAAGF,SAAS;QACb1B,KAAKA;QACL6B,aAAW5B,cAAc,SAAS6B,YAAY7B;QAC9CC,WAAWL,UAAU;YACnBK;YACAC;YACAO;YACAQ;YACAJ;YACAR;YACAE;YACAI,UAAU,CAACX,aAAaW;YACxBY,SAASL,YAAYlB,YAAY,SAASuB;YAC1CO,iBAAiBJ;QACnB;QACAvB,OAAOA;;YAENY;0BACD,KAACrB;gBACE,GAAG8B,YAAY;gBAChBO,MAAMb;gBACNc,WAAWZ;gBACXE,kBAAkBA;gBAClBtB,WAAWA;gBACXK,QAAQA;gBACR4B,SAASZ;0BAERP;;YAEFE;;;AAGP,GACA"}
|
|
@@ -39,7 +39,7 @@ export interface TableCheckboxProps extends TableCheckboxTdHTMLAttributes, Table
|
|
|
39
39
|
* @see {@link TableCheckboxSupportedCheckboxProps}
|
|
40
40
|
* @since 6.0.0
|
|
41
41
|
*/
|
|
42
|
-
checkboxProps?: PropsWithRef<CheckboxProps
|
|
42
|
+
checkboxProps?: PropsWithRef<CheckboxProps>;
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* **Client Component**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/table/TableCheckbox.tsx"],"sourcesContent":["\"use client\";\n\nimport { type TdHTMLAttributes, forwardRef } from \"react\";\n\nimport { Checkbox } from \"../form/Checkbox.js\";\nimport { type CheckboxProps } from \"../form/InputToggle.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { TableCell } from \"./TableCell.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport type TableCheckboxTdHTMLAttributes = Omit<\n TdHTMLAttributes<HTMLTableCellElement>,\n \"aria-sort\" | \"scope\" | \"onChange\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport type TableCheckboxSupportedCheckboxProps = Pick<\n CheckboxProps,\n | \"name\"\n | \"value\"\n | \"icon\"\n | \"iconStyle\"\n | \"iconClassName\"\n | \"iconProps\"\n | \"checkedIcon\"\n | \"indeterminateIcon\"\n | \"checked\"\n | \"onChange\"\n | \"defaultChecked\"\n | \"indeterminate\"\n | \"aria-controls\"\n>;\n\n/**\n * @since 6.0.0 The `id` prop is no longer required since the checkbox's id\n * will automatically be generated as `\"checkbox\" + useId()`. Use the {@link checkboxProps}\n * to set an `id` manually for the checkbox.\n * @since 6.0.0 The `cellId` prop was removed. Use the `id` prop instead.\n * @since 6.0.0 The default `aria-label` was changed from\n * `\"Toggle Row Selection\"` to `\"Select Row\"`.\n */\nexport interface TableCheckboxProps\n extends TableCheckboxTdHTMLAttributes,\n TableCheckboxSupportedCheckboxProps {\n /**\n * @defaultValue `!props[\"aria-labelledby\"] ? \"Select Row\" : undefined`\n */\n \"aria-label\"?: string;\n\n /** @defaultValue `false` */\n sticky?: boolean;\n\n /**\n * This allows you to override any props for the checkbox that are not\n * configurable as top-level props.\n *\n * @example Simple Example\n * ```tsx\n * checkboxProps={{\n * id: \"some-custom-id\",\n * ref: checkboxRef,\n * }}\n * ```\n *\n * @see {@link TableCheckboxSupportedCheckboxProps}\n * @since 6.0.0\n */\n checkboxProps?: PropsWithRef<CheckboxProps
|
|
1
|
+
{"version":3,"sources":["../../src/table/TableCheckbox.tsx"],"sourcesContent":["\"use client\";\n\nimport { type TdHTMLAttributes, forwardRef } from \"react\";\n\nimport { Checkbox } from \"../form/Checkbox.js\";\nimport { type CheckboxProps } from \"../form/InputToggle.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { TableCell } from \"./TableCell.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport type TableCheckboxTdHTMLAttributes = Omit<\n TdHTMLAttributes<HTMLTableCellElement>,\n \"aria-sort\" | \"scope\" | \"onChange\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport type TableCheckboxSupportedCheckboxProps = Pick<\n CheckboxProps,\n | \"name\"\n | \"value\"\n | \"icon\"\n | \"iconStyle\"\n | \"iconClassName\"\n | \"iconProps\"\n | \"checkedIcon\"\n | \"indeterminateIcon\"\n | \"checked\"\n | \"onChange\"\n | \"defaultChecked\"\n | \"indeterminate\"\n | \"aria-controls\"\n>;\n\n/**\n * @since 6.0.0 The `id` prop is no longer required since the checkbox's id\n * will automatically be generated as `\"checkbox\" + useId()`. Use the {@link checkboxProps}\n * to set an `id` manually for the checkbox.\n * @since 6.0.0 The `cellId` prop was removed. Use the `id` prop instead.\n * @since 6.0.0 The default `aria-label` was changed from\n * `\"Toggle Row Selection\"` to `\"Select Row\"`.\n */\nexport interface TableCheckboxProps\n extends TableCheckboxTdHTMLAttributes,\n TableCheckboxSupportedCheckboxProps {\n /**\n * @defaultValue `!props[\"aria-labelledby\"] ? \"Select Row\" : undefined`\n */\n \"aria-label\"?: string;\n\n /** @defaultValue `false` */\n sticky?: boolean;\n\n /**\n * This allows you to override any props for the checkbox that are not\n * configurable as top-level props.\n *\n * @example Simple Example\n * ```tsx\n * checkboxProps={{\n * id: \"some-custom-id\",\n * ref: checkboxRef,\n * }}\n * ```\n *\n * @see {@link TableCheckboxSupportedCheckboxProps}\n * @since 6.0.0\n */\n checkboxProps?: PropsWithRef<CheckboxProps>;\n}\n\n/**\n * **Client Component**\n * The `TableCheckbox` is used to render a `Checkbox` within a `TableCell` by applying\n * some minimal styles.\n *\n * @example Simple Example\n * ```tsx\n * import { useCheckboxGroup } from \"@react-md/core/form/useCheckboxGroup\";\n * import { Table } from \"@react-md/core/table/Table\";\n * import { TableBody } from \"@react-md/core/table/TableBody\";\n * import { TableCell } from \"@react-md/core/table/TableCell\";\n * import { TableCheckbox } from \"@react-md/core/table/TableCheckbox\";\n * import { TableContainer } from \"@react-md/core/table/TableContainer\";\n * import { TableHeader } from \"@react-md/core/table/TableHeader\";\n * import { TableRow } from \"@react-md/core/table/TableRow\";\n * import { type ReactElement } from \"react\";\n *\n * const rows = [\n * { name: \"Frozen Yogurt\", type: \"Ice Cream\" },\n * { name: \"Ice cream sandwich\", type: \"Ice Cream\" },\n * { name: \"Eclair\", type: \"Pastry\" },\n * // ...other content\n * ] as const;\n *\n * function Example(): ReactElement {\n * const { getCheckboxProps, getIndeterminateProps } = useCheckboxGroup({\n * values: rows.map(({ name }) => name),\n * name: \"selected\",\n * });\n * return (\n * <TableContainer>\n * <Table>\n * <TableHeader>\n * <TableRow>\n * <TableCheckbox {...getIndeterminateProps()} />\n * <TableCell>Name</TableCell>\n * <TableCell>Type</TableCell>\n * </TableRow>\n * </TableHeader>\n * <TableBody>\n * {rows.map(({ name, type }) => {\n * const checkboxProps = getCheckboxProps(name);\n * const { checked, onChange } = checkboxProps;\n *\n * return (\n * <TableRow\n * key={name}\n * onClick={onChange}\n * clickable\n * selected={checked}\n * >\n * <TableCheckbox {...checkboxProps} />\n * <TableCell>{name}</TableCell>\n * <TableCell hAlign=\"right\">{type}</TableCell>\n * </TableRow>\n * );\n * })}\n * </TableBody>\n * </Table>\n * </TableContainer>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/table | Table Demos}\n * @since 6.0.0 The `id` prop is no longer required since the checkbox's id\n * will automatically be generated as `\"checkbox\" + useId()`. Use the {@link checkboxProps}\n * to set an `id` manually for the checkbox.\n * @since 6.0.0 The `cellId` prop was removed. Use the `id` prop instead.\n * @since 6.0.0 The default `aria-label` was changed from\n * `\"Toggle Row Selection\"` to `\"Select Row\"`.\n */\nexport const TableCheckbox = forwardRef<\n HTMLTableCellElement,\n TableCheckboxProps\n>(function TableCheckbox(props, ref) {\n const {\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-label\": ariaLabel = !ariaLabelledBy ? \"Select Row\" : undefined,\n \"aria-controls\": ariaControls,\n name,\n icon,\n iconProps,\n iconStyle,\n iconClassName,\n checkedIcon,\n indeterminateIcon,\n value,\n checked,\n onChange,\n defaultChecked,\n indeterminate,\n checkboxProps,\n onClick = noop,\n ...remaining\n } = props;\n\n return (\n <TableCell\n {...remaining}\n ref={ref}\n header={false}\n inputToggle\n onClick={(event) => {\n event.stopPropagation();\n onClick(event);\n }}\n >\n <Checkbox\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-controls={ariaControls}\n name={name}\n icon={icon}\n iconProps={iconProps}\n iconStyle={iconStyle}\n iconClassName={iconClassName}\n checkedIcon={checkedIcon}\n indeterminateIcon={indeterminateIcon}\n value={value}\n checked={checked}\n defaultChecked={defaultChecked}\n onChange={onChange}\n indeterminate={indeterminate}\n {...checkboxProps}\n />\n </TableCell>\n );\n});\n"],"names":["forwardRef","Checkbox","TableCell","noop","TableCheckbox","props","ref","ariaLabelledBy","ariaLabel","undefined","ariaControls","name","icon","iconProps","iconStyle","iconClassName","checkedIcon","indeterminateIcon","value","checked","onChange","defaultChecked","indeterminate","checkboxProps","onClick","remaining","header","inputToggle","event","stopPropagation","aria-label","aria-labelledby","aria-controls"],"mappings":"AAAA;;AAEA,SAAgCA,UAAU,QAAQ,QAAQ;AAE1D,SAASC,QAAQ,QAAQ,sBAAsB;AAG/C,SAASC,SAAS,QAAQ,iBAAiB;AAE3C,MAAMC,OAAO;AACX,aAAa;AACf;AAmEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuEC,GACD,OAAO,MAAMC,8BAAgBJ,WAG3B,SAASI,cAAcC,KAAK,EAAEC,GAAG;IACjC,MAAM,EACJ,mBAAmBC,cAAc,EACjC,cAAcC,YAAY,CAACD,iBAAiB,eAAeE,SAAS,EACpE,iBAAiBC,YAAY,EAC7BC,IAAI,EACJC,IAAI,EACJC,SAAS,EACTC,SAAS,EACTC,aAAa,EACbC,WAAW,EACXC,iBAAiB,EACjBC,KAAK,EACLC,OAAO,EACPC,QAAQ,EACRC,cAAc,EACdC,aAAa,EACbC,aAAa,EACbC,UAAUrB,IAAI,EACd,GAAGsB,WACJ,GAAGpB;IAEJ,qBACE,KAACH;QACE,GAAGuB,SAAS;QACbnB,KAAKA;QACLoB,QAAQ;QACRC,WAAW;QACXH,SAAS,CAACI;YACRA,MAAMC,eAAe;YACrBL,QAAQI;QACV;kBAEA,cAAA,KAAC3B;YACC6B,cAAYtB;YACZuB,mBAAiBxB;YACjByB,iBAAetB;YACfC,MAAMA;YACNC,MAAMA;YACNC,WAAWA;YACXC,WAAWA;YACXC,eAAeA;YACfC,aAAaA;YACbC,mBAAmBA;YACnBC,OAAOA;YACPC,SAASA;YACTE,gBAAgBA;YAChBD,UAAUA;YACVE,eAAeA;YACd,GAAGC,aAAa;;;AAIzB,GAAG"}
|
|
@@ -34,7 +34,7 @@ export interface TableRadioProps extends TableRadioTdHTMLAttributes, TableRadioS
|
|
|
34
34
|
* @see {@link TableRadioSupportedRadioProps}
|
|
35
35
|
* @since 6.0.0
|
|
36
36
|
*/
|
|
37
|
-
radioProps?: PropsWithRef<RadioProps
|
|
37
|
+
radioProps?: PropsWithRef<RadioProps>;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* **Client Component**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/table/TableRadio.tsx"],"sourcesContent":["\"use client\";\n\nimport { type TdHTMLAttributes, forwardRef } from \"react\";\n\nimport { type RadioProps } from \"../form/InputToggle.js\";\nimport { Radio } from \"../form/Radio.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { TableCell } from \"./TableCell.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport type TableRadioTdHTMLAttributes = Omit<\n TdHTMLAttributes<HTMLTableCellElement>,\n \"aria-sort\" | \"scope\" | \"onChange\" | \"onInvalid\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport type TableRadioSupportedRadioProps = Pick<\n RadioProps,\n | \"name\"\n | \"value\"\n | \"icon\"\n | \"iconStyle\"\n | \"iconClassName\"\n | \"iconProps\"\n | \"checkedIcon\"\n | \"checked\"\n | \"onChange\"\n | \"defaultChecked\"\n | \"error\"\n | \"required\"\n | \"onInvalid\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport interface TableRadioProps\n extends TableRadioTdHTMLAttributes,\n TableRadioSupportedRadioProps {\n /**\n * @defaultValue `!props[\"aria-labelledby\"] ? \"Select Row\" : undefined`\n */\n \"aria-label\"?: string;\n\n /** @defaultValue `false` */\n sticky?: boolean;\n\n /**\n * This allows you to override any props for the radio that are not\n * configurable as top-level props.\n *\n * @example Simple Example\n * ```tsx\n * radioProps={{\n * id: \"some-custom-id\",\n * ref: radioRef,\n * }}\n * ```\n *\n * @see {@link TableRadioSupportedRadioProps}\n * @since 6.0.0\n */\n radioProps?: PropsWithRef<RadioProps
|
|
1
|
+
{"version":3,"sources":["../../src/table/TableRadio.tsx"],"sourcesContent":["\"use client\";\n\nimport { type TdHTMLAttributes, forwardRef } from \"react\";\n\nimport { type RadioProps } from \"../form/InputToggle.js\";\nimport { Radio } from \"../form/Radio.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { TableCell } from \"./TableCell.js\";\n\nconst noop = (): void => {\n // do nothing\n};\n\n/**\n * @since 6.0.0\n */\nexport type TableRadioTdHTMLAttributes = Omit<\n TdHTMLAttributes<HTMLTableCellElement>,\n \"aria-sort\" | \"scope\" | \"onChange\" | \"onInvalid\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport type TableRadioSupportedRadioProps = Pick<\n RadioProps,\n | \"name\"\n | \"value\"\n | \"icon\"\n | \"iconStyle\"\n | \"iconClassName\"\n | \"iconProps\"\n | \"checkedIcon\"\n | \"checked\"\n | \"onChange\"\n | \"defaultChecked\"\n | \"error\"\n | \"required\"\n | \"onInvalid\"\n>;\n\n/**\n * @since 6.0.0\n */\nexport interface TableRadioProps\n extends TableRadioTdHTMLAttributes,\n TableRadioSupportedRadioProps {\n /**\n * @defaultValue `!props[\"aria-labelledby\"] ? \"Select Row\" : undefined`\n */\n \"aria-label\"?: string;\n\n /** @defaultValue `false` */\n sticky?: boolean;\n\n /**\n * This allows you to override any props for the radio that are not\n * configurable as top-level props.\n *\n * @example Simple Example\n * ```tsx\n * radioProps={{\n * id: \"some-custom-id\",\n * ref: radioRef,\n * }}\n * ```\n *\n * @see {@link TableRadioSupportedRadioProps}\n * @since 6.0.0\n */\n radioProps?: PropsWithRef<RadioProps>;\n}\n\n/**\n * **Client Component**\n * The `TableRadio` is used to render a `Radio` within a `TableCell` by applying\n * some minimal styles.\n *\n * @example Simple Example\n * ```tsx\n * import { useRadioGroup } from \"@react-md/core/form/useRadioGroup\";\n * import { Table } from \"@react-md/core/table/Table\";\n * import { TableBody } from \"@react-md/core/table/TableBody\";\n * import { TableCell } from \"@react-md/core/table/TableCell\";\n * import { TableContainer } from \"@react-md/core/table/TableContainer\";\n * import { TableHeader } from \"@react-md/core/table/TableHeader\";\n * import { TableRadio } from \"@react-md/core/table/TableRadio\";\n * import { TableRow } from \"@react-md/core/table/TableRow\";\n * import type { ReactElement } from \"react\";\n *\n * const rows = [\n * { name: \"Frozen Yogurt\", type: \"Ice Cream\" },\n * { name: \"Ice cream sandwich\", type: \"Ice Cream\" },\n * { name: \"Eclair\", type: \"Pastry\" },\n * // ...other content\n * ] as const;\n *\n * function Example(): ReactElement {\n * const { getRadioProps } = useRadioGroup({\n * name: \"selected\",\n * });\n * return (\n * <TableContainer>\n * <Table>\n * <TableHeader>\n * <TableRow>\n * <TableCell header={false} />\n * <TableCell>Name</TableCell>\n * <TableCell>Type</TableCell>\n * </TableRow>\n * </TableHeader>\n * <TableBody>\n * {rows.map(({ name, type }) => {\n * const radioProps = getRadioProps(name);\n * const { checked, onChange } = radioProps;\n *\n * return (\n * <TableRow\n * key={name}\n * onClick={onChange}\n * clickable\n * selected={checked}\n * >\n * <TableRadio {...radioProps} />\n * <TableCell>{name}</TableCell>\n * <TableCell hAlign=\"right\">{type}</TableCell>\n * </TableRow>\n * );\n * })}\n * </TableBody>\n * </Table>\n * </TableContainer>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/table | Table Demos}\n * @since 6.0.0\n */\nexport const TableRadio = forwardRef<HTMLTableCellElement, TableRadioProps>(\n function TableRadio(props, ref) {\n const {\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-label\": ariaLabel = !ariaLabelledBy ? \"Select Row\" : undefined,\n \"aria-controls\": ariaControls,\n name,\n icon,\n iconProps,\n iconStyle,\n iconClassName,\n checkedIcon,\n value,\n checked,\n onChange,\n defaultChecked,\n radioProps,\n onClick = noop,\n error,\n required,\n onInvalid,\n ...remaining\n } = props;\n\n return (\n <TableCell\n {...remaining}\n ref={ref}\n header={false}\n inputToggle\n onClick={(event) => {\n event.stopPropagation();\n onClick(event);\n }}\n >\n <Radio\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-controls={ariaControls}\n name={name}\n icon={icon}\n iconProps={iconProps}\n iconStyle={iconStyle}\n iconClassName={iconClassName}\n checkedIcon={checkedIcon}\n value={value}\n checked={checked}\n defaultChecked={defaultChecked}\n error={error}\n required={required}\n onChange={onChange}\n onInvalid={onInvalid}\n {...radioProps}\n />\n </TableCell>\n );\n }\n);\n"],"names":["forwardRef","Radio","TableCell","noop","TableRadio","props","ref","ariaLabelledBy","ariaLabel","undefined","ariaControls","name","icon","iconProps","iconStyle","iconClassName","checkedIcon","value","checked","onChange","defaultChecked","radioProps","onClick","error","required","onInvalid","remaining","header","inputToggle","event","stopPropagation","aria-label","aria-labelledby","aria-controls"],"mappings":"AAAA;;AAEA,SAAgCA,UAAU,QAAQ,QAAQ;AAG1D,SAASC,KAAK,QAAQ,mBAAmB;AAEzC,SAASC,SAAS,QAAQ,iBAAiB;AAE3C,MAAMC,OAAO;AACX,aAAa;AACf;AA8DA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiEC,GACD,OAAO,MAAMC,2BAAaJ,WACxB,SAASI,WAAWC,KAAK,EAAEC,GAAG;IAC5B,MAAM,EACJ,mBAAmBC,cAAc,EACjC,cAAcC,YAAY,CAACD,iBAAiB,eAAeE,SAAS,EACpE,iBAAiBC,YAAY,EAC7BC,IAAI,EACJC,IAAI,EACJC,SAAS,EACTC,SAAS,EACTC,aAAa,EACbC,WAAW,EACXC,KAAK,EACLC,OAAO,EACPC,QAAQ,EACRC,cAAc,EACdC,UAAU,EACVC,UAAUnB,IAAI,EACdoB,KAAK,EACLC,QAAQ,EACRC,SAAS,EACT,GAAGC,WACJ,GAAGrB;IAEJ,qBACE,KAACH;QACE,GAAGwB,SAAS;QACbpB,KAAKA;QACLqB,QAAQ;QACRC,WAAW;QACXN,SAAS,CAACO;YACRA,MAAMC,eAAe;YACrBR,QAAQO;QACV;kBAEA,cAAA,KAAC5B;YACC8B,cAAYvB;YACZwB,mBAAiBzB;YACjB0B,iBAAevB;YACfC,MAAMA;YACNC,MAAMA;YACNC,WAAWA;YACXC,WAAWA;YACXC,eAAeA;YACfC,aAAaA;YACbC,OAAOA;YACPC,SAASA;YACTE,gBAAgBA;YAChBG,OAAOA;YACPC,UAAUA;YACVL,UAAUA;YACVM,WAAWA;YACV,GAAGJ,UAAU;;;AAItB,GACA"}
|
|
@@ -8,7 +8,7 @@ import { type GetTabListScrollToOptions } from "./getTabListScrollToOptions.js";
|
|
|
8
8
|
* @since 6.0.0
|
|
9
9
|
*/
|
|
10
10
|
export interface BaseTabListScrollButtonProps extends HTMLAttributes<HTMLDivElement>, ButtonClassNameThemeOptions {
|
|
11
|
-
buttonProps?: PropsWithRef<ButtonProps
|
|
11
|
+
buttonProps?: PropsWithRef<ButtonProps>;
|
|
12
12
|
/** @defaultValue `false` */
|
|
13
13
|
disableTransition?: boolean;
|
|
14
14
|
/** @defaultValue {@link getTabListScrollToOptions} */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tabs/TabListScrollButton.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type HTMLAttributes,\n forwardRef,\n useCallback,\n useRef,\n useState,\n} from \"react\";\n\nimport { Button, type ButtonProps } from \"../button/Button.js\";\nimport { type ButtonClassNameThemeOptions } from \"../button/styles.js\";\nimport { getIcon } from \"../icon/config.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { useDir } from \"../typography/WritingDirectionProvider.js\";\nimport { useIntersectionObserver } from \"../useIntersectionObserver.js\";\nimport { applyRef } from \"../utils/applyRef.js\";\nimport {\n type GetTabListScrollToOptions,\n getTabListScrollToOptions,\n} from \"./getTabListScrollToOptions.js\";\nimport {\n tabListScrollButton,\n tabListScrollButtonContainer,\n} from \"./tabListScrollButtonStyles.js\";\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface BaseTabListScrollButtonProps\n extends HTMLAttributes<HTMLDivElement>,\n ButtonClassNameThemeOptions {\n buttonProps?: PropsWithRef<ButtonProps
|
|
1
|
+
{"version":3,"sources":["../../src/tabs/TabListScrollButton.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type HTMLAttributes,\n forwardRef,\n useCallback,\n useRef,\n useState,\n} from \"react\";\n\nimport { Button, type ButtonProps } from \"../button/Button.js\";\nimport { type ButtonClassNameThemeOptions } from \"../button/styles.js\";\nimport { getIcon } from \"../icon/config.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { useDir } from \"../typography/WritingDirectionProvider.js\";\nimport { useIntersectionObserver } from \"../useIntersectionObserver.js\";\nimport { applyRef } from \"../utils/applyRef.js\";\nimport {\n type GetTabListScrollToOptions,\n getTabListScrollToOptions,\n} from \"./getTabListScrollToOptions.js\";\nimport {\n tabListScrollButton,\n tabListScrollButtonContainer,\n} from \"./tabListScrollButtonStyles.js\";\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface BaseTabListScrollButtonProps\n extends HTMLAttributes<HTMLDivElement>,\n ButtonClassNameThemeOptions {\n buttonProps?: PropsWithRef<ButtonProps>;\n\n /** @defaultValue `false` */\n disableTransition?: boolean;\n\n /** @defaultValue {@link getTabListScrollToOptions} */\n getScrollToOptions?: GetTabListScrollToOptions;\n}\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport interface TabListScrollButtonProps extends BaseTabListScrollButtonProps {\n type: \"back\" | \"forward\";\n /** @defaultValue `false` */\n vertical?: boolean;\n}\n\n/**\n * **Client Component**\n *\n * @internal\n * @since 6.0.0\n */\nexport const TabListScrollButton = forwardRef<\n HTMLDivElement,\n TabListScrollButtonProps\n>(function TabListScrollButton(props, ref) {\n const {\n \"aria-label\": ariaLabel,\n className,\n buttonProps,\n type,\n theme,\n themeType,\n buttonType = \"icon\",\n disabled: propDisabled,\n children: propChildren,\n getScrollToOptions = getTabListScrollToOptions,\n vertical = false,\n disableTransition = false,\n ...remaining\n } = props;\n\n const forward = type === \"forward\";\n const iconButton = buttonType === \"icon\";\n const icon = getIcon(type);\n const children = propChildren || icon;\n\n const root = useRef<HTMLElement | null>(null);\n const isRTL = useDir().dir === \"rtl\";\n const [disabled, setDisabled] = useState(!forward);\n const nodeRef = useIntersectionObserver({\n root,\n rootMargin: \"1px\",\n onUpdate: useCallback(([entry]) => {\n setDisabled(entry.intersectionRatio === 1);\n }, []),\n });\n\n return (\n <>\n {!forward && <span ref={nodeRef} />}\n <div\n {...remaining}\n ref={(instance) => {\n applyRef(instance, ref);\n root.current = instance?.parentElement || null;\n }}\n className={tabListScrollButtonContainer({\n forward,\n vertical,\n className,\n })}\n >\n <Button\n aria-label={ariaLabel || (iconButton ? type : undefined)}\n theme={theme}\n themeType={themeType}\n buttonType={buttonType}\n disabled={propDisabled || disabled}\n {...buttonProps}\n className={tabListScrollButton({\n className: buttonProps?.className,\n vertical,\n })}\n onClick={(event) => {\n buttonProps?.onClick?.(event);\n const container = root.current;\n if (!container) {\n return;\n }\n\n container.scrollTo(\n getScrollToOptions({\n isRTL,\n animate: !disableTransition,\n vertical,\n container,\n increment: forward,\n })\n );\n }}\n >\n {children}\n </Button>\n </div>\n {forward && <span ref={nodeRef} />}\n </>\n );\n});\n"],"names":["forwardRef","useCallback","useRef","useState","Button","getIcon","useDir","useIntersectionObserver","applyRef","getTabListScrollToOptions","tabListScrollButton","tabListScrollButtonContainer","TabListScrollButton","props","ref","ariaLabel","className","buttonProps","type","theme","themeType","buttonType","disabled","propDisabled","children","propChildren","getScrollToOptions","vertical","disableTransition","remaining","forward","iconButton","icon","root","isRTL","dir","setDisabled","nodeRef","rootMargin","onUpdate","entry","intersectionRatio","span","div","instance","current","parentElement","aria-label","undefined","onClick","event","container","scrollTo","animate","increment"],"mappings":"AAAA;;AAEA,SAEEA,UAAU,EACVC,WAAW,EACXC,MAAM,EACNC,QAAQ,QACH,QAAQ;AAEf,SAASC,MAAM,QAA0B,sBAAsB;AAE/D,SAASC,OAAO,QAAQ,oBAAoB;AAE5C,SAASC,MAAM,QAAQ,4CAA4C;AACnE,SAASC,uBAAuB,QAAQ,gCAAgC;AACxE,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAEEC,yBAAyB,QACpB,iCAAiC;AACxC,SACEC,mBAAmB,EACnBC,4BAA4B,QACvB,iCAAiC;AA4BxC;;;;;CAKC,GACD,OAAO,MAAMC,oCAAsBZ,WAGjC,SAASY,oBAAoBC,KAAK,EAAEC,GAAG;IACvC,MAAM,EACJ,cAAcC,SAAS,EACvBC,SAAS,EACTC,WAAW,EACXC,IAAI,EACJC,KAAK,EACLC,SAAS,EACTC,aAAa,MAAM,EACnBC,UAAUC,YAAY,EACtBC,UAAUC,YAAY,EACtBC,qBAAqBjB,yBAAyB,EAC9CkB,WAAW,KAAK,EAChBC,oBAAoB,KAAK,EACzB,GAAGC,WACJ,GAAGhB;IAEJ,MAAMiB,UAAUZ,SAAS;IACzB,MAAMa,aAAaV,eAAe;IAClC,MAAMW,OAAO3B,QAAQa;IACrB,MAAMM,WAAWC,gBAAgBO;IAEjC,MAAMC,OAAO/B,OAA2B;IACxC,MAAMgC,QAAQ5B,SAAS6B,GAAG,KAAK;IAC/B,MAAM,CAACb,UAAUc,YAAY,GAAGjC,SAAS,CAAC2B;IAC1C,MAAMO,UAAU9B,wBAAwB;QACtC0B;QACAK,YAAY;QACZC,UAAUtC,YAAY,CAAC,CAACuC,MAAM;YAC5BJ,YAAYI,MAAMC,iBAAiB,KAAK;QAC1C,GAAG,EAAE;IACP;IAEA,qBACE;;YACG,CAACX,yBAAW,KAACY;gBAAK5B,KAAKuB;;0BACxB,KAACM;gBACE,GAAGd,SAAS;gBACbf,KAAK,CAAC8B;oBACJpC,SAASoC,UAAU9B;oBACnBmB,KAAKY,OAAO,GAAGD,UAAUE,iBAAiB;gBAC5C;gBACA9B,WAAWL,6BAA6B;oBACtCmB;oBACAH;oBACAX;gBACF;0BAEA,cAAA,KAACZ;oBACC2C,cAAYhC,aAAcgB,CAAAA,aAAab,OAAO8B,SAAQ;oBACtD7B,OAAOA;oBACPC,WAAWA;oBACXC,YAAYA;oBACZC,UAAUC,gBAAgBD;oBACzB,GAAGL,WAAW;oBACfD,WAAWN,oBAAoB;wBAC7BM,WAAWC,aAAaD;wBACxBW;oBACF;oBACAsB,SAAS,CAACC;wBACRjC,aAAagC,UAAUC;wBACvB,MAAMC,YAAYlB,KAAKY,OAAO;wBAC9B,IAAI,CAACM,WAAW;4BACd;wBACF;wBAEAA,UAAUC,QAAQ,CAChB1B,mBAAmB;4BACjBQ;4BACAmB,SAAS,CAACzB;4BACVD;4BACAwB;4BACAG,WAAWxB;wBACb;oBAEJ;8BAECN;;;YAGJM,yBAAW,KAACY;gBAAK5B,KAAKuB;;;;AAG7B,GAAG"}
|
package/dist/tree/TreeItem.d.ts
CHANGED
|
@@ -25,11 +25,11 @@ export interface TreeItemProps extends Omit<DefaultTreeItemNode, "parentId">, HT
|
|
|
25
25
|
* element. The top-level props are passed to the `<span>` or `<a>` element
|
|
26
26
|
* instead.
|
|
27
27
|
*/
|
|
28
|
-
liProps?: PropsWithRef<HTMLAttributes<HTMLLIElement
|
|
28
|
+
liProps?: PropsWithRef<HTMLAttributes<HTMLLIElement>>;
|
|
29
29
|
/**
|
|
30
30
|
* Any additional props to pass to the `TreeGroup` component.
|
|
31
31
|
*/
|
|
32
|
-
groupProps?: PropsWithRef<OverridableTreeGroupProps
|
|
32
|
+
groupProps?: PropsWithRef<OverridableTreeGroupProps>;
|
|
33
33
|
/**
|
|
34
34
|
* This should normally be the text/content to display within the tree item
|
|
35
35
|
* and should **not** include nested trees.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tree/TreeItem.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n type Ref,\n useEffect,\n} from \"react\";\n\nimport { type ComponentWithRippleProps } from \"../interaction/types.js\";\nimport { useElementInteraction } from \"../interaction/useElementInteraction.js\";\nimport { useHigherContrastChildren } from \"../interaction/useHigherContrastChildren.js\";\nimport { ListItemChildren } from \"../list/ListItemChildren.js\";\nimport { useKeyboardMovementContext } from \"../movement/useKeyboardMovementProvider.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { type OverridableTreeGroupProps, TreeGroup } from \"./TreeGroup.js\";\nimport { TreeItemExpander } from \"./TreeItemExpander.js\";\nimport { useTreeContext } from \"./TreeProvider.js\";\nimport { treeItem, treeItemContent, treeItemMedia } from \"./styles.js\";\nimport { type DefaultTreeItemNode } from \"./types.js\";\n\n/**\n * @since 6.0.0 Added `liProps` and `groupProps`.\n * @since 6.0.0 The `liRef`, `liStyle`, and `liClassName` props were removed in\n * favor of `liProps={{ ref, style, className }}`.\n * @since 6.0.0 The `itemIndex`, `listSize`, `renderChildItems`, `isLink`,\n * `contentComponent`, and `readOnly` props were removed.\n */\nexport interface TreeItemProps\n extends Omit<DefaultTreeItemNode, \"parentId\">,\n HTMLAttributes<HTMLLIElement>,\n ComponentWithRippleProps {\n /**\n * @defaultValue `\"tree-item-\" + useId()`\n */\n id?: string;\n\n /**\n * This is used to set the `--rmd-tree-depth` CSS variable which allows the\n * padding to increase for each nested tree.\n */\n depth: number;\n\n /**\n * Any additional props that should be passed to the surrounding `<li>`\n * element. The top-level props are passed to the `<span>` or `<a>` element\n * instead.\n */\n liProps?: PropsWithRef<HTMLAttributes<HTMLLIElement>, HTMLLIElement>;\n\n /**\n * Any additional props to pass to the `TreeGroup` component.\n */\n groupProps?: PropsWithRef<OverridableTreeGroupProps, HTMLUListElement>;\n\n /**\n * This should normally be the text/content to display within the tree item\n * and should **not** include nested trees.\n */\n children?: ReactNode;\n\n /**\n * The nested tree items to render within a `TreeGroup`.\n */\n childItems?: ReactNode;\n\n /** @defaultValue `false` */\n disableTransition?: boolean;\n\n /**\n * This ref is applied to the `<span>` or `<a>` element and can be used to\n * implement drag and drop behavior.\n */\n contentRef?: Ref<HTMLElement>;\n\n /**\n * Set this to `true` if the {@link childItems} should not be rendered while\n * collapsed.\n *\n * @defaultValue `false`\n */\n temporaryChildItems?: boolean;\n}\n\n/**\n * **Client Component**\n *\n * @see {@link https://react-md.dev/components/tree | Tree Demos}\n * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/treeview/}\n * @since 6.0.0 No longer forwards refs. The ref must be provided using\n * `contentRef` instead.\n * @since 6.0.0 The `liRef` was removed in favor of `liProps={{ ref }}`.\n * @since 6.0.0 The wrapping `<li>` element will always be `role=\"none\"` and the\n * `<span>` or `<a>` will gain the `role=\"treeitem\"` instead. This makes it\n * easier to pass event handlers because of the nested behavior of tree items.\n * @since 6.0.0 No longer provides the `aria-level`, `aria-setsize` and\n * `aria-posinset` attributes and allows the browser to compute them instead.\n */\nexport function TreeItem(props: TreeItemProps): ReactElement {\n const {\n id: propId,\n depth,\n liProps,\n disabled = false,\n disabledOpacity = false,\n groupProps,\n children: propChildren,\n className,\n itemId,\n leftAddon,\n leftAddonType: propLeftAddonType,\n leftAddonPosition,\n leftAddonClassName,\n leftAddonForceWrap,\n rightAddon,\n rightAddonType,\n rightAddonPosition,\n rightAddonClassName,\n rightAddonForceWrap,\n disableTextChildren,\n disableLeftAddonCenteredMedia: propDisableLeftAddonCenteredMedia,\n disableRightAddonCenteredMedia,\n textProps,\n textClassName,\n primaryText,\n secondaryText,\n secondaryTextProps,\n secondaryTextClassName,\n multiline,\n childItems,\n contentClassName,\n temporaryChildItems,\n disableTransition: propDisableTransition,\n onBlur,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onMouseLeave,\n onDragStart,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n contentRef,\n disableRipple,\n ...remaining\n } = props;\n\n const id = useEnsuredId(propId, \"tree-item\");\n const children = useHigherContrastChildren(propChildren);\n if (disabled) {\n // you can't really disable a link other than removing the href, so\n // unset these props\n remaining.to = undefined;\n remaining.href = undefined;\n }\n\n const {\n expandedIds,\n selectedIds,\n expanderLeft,\n expansionMode,\n metadataLookup,\n linkComponent: Link,\n toggleTreeItemSelection,\n toggleTreeItemExpansion,\n disableTransition: contextDisableTransition,\n } = useTreeContext();\n const { activeDescendantId } = useKeyboardMovementContext();\n\n const isLeafNode = !childItems;\n const focused = activeDescendantId === id;\n const expanded = expandedIds.has(itemId);\n const selected = selectedIds.has(itemId);\n const disableTransition = propDisableTransition ?? contextDisableTransition;\n\n useEffect(() => {\n const lookup = metadataLookup.current;\n lookup.expandable[itemId] = !isLeafNode;\n lookup.disabledItems[itemId] = disabled;\n lookup.elementToItem[id] = itemId;\n lookup.itemToElement[itemId] = id;\n\n return () => {\n /* eslint-disable @typescript-eslint/no-dynamic-delete */\n delete lookup.disabledItems[itemId];\n delete lookup.expandable[itemId];\n delete lookup.elementToItem[id];\n delete lookup.itemToElement[itemId];\n /* eslint-enable @typescript-eslint/no-dynamic-delete */\n };\n }, [id, metadataLookup, itemId, isLeafNode, disabled, depth]);\n\n const { pressedClassName, ripples, handlers } =\n useElementInteraction<HTMLLIElement>({\n mode: disableRipple ? \"none\" : undefined,\n onBlur,\n onClick(event) {\n onClick?.(event);\n toggleTreeItemSelection(itemId);\n if (!isLeafNode && expansionMode !== \"manual\") {\n toggleTreeItemExpansion(itemId);\n }\n },\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onMouseLeave,\n onDragStart,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n disabled,\n });\n\n const isLink = !!(remaining.to || remaining.href);\n\n // cheating a bit so there are type errors around the event handlers\n const ContentComponent = (isLink ? Link : \"span\") as \"span\";\n const leftAddonType =\n (propLeftAddonType ?? (expanderLeft && leftAddon)) ? \"media\" : undefined;\n const isMediaLeftAddon =\n typeof propLeftAddonType === \"undefined\" && leftAddonType === \"media\";\n const disableLeftAddonCenteredMedia =\n propDisableLeftAddonCenteredMedia ?? isMediaLeftAddon;\n\n return (\n <li\n {...liProps}\n role=\"none\"\n className={treeItem({\n className,\n expander: !!childItems,\n expanderLeft,\n })}\n >\n <ContentComponent\n {...remaining}\n // nodes with children should always apply the `aria-expanded` to show\n // that it is expandable while leaf nodes should remain omitted\n aria-expanded={isLeafNode ? undefined : expanded}\n aria-selected={selected}\n aria-disabled={disabled || undefined}\n id={id}\n ref={contentRef}\n role=\"treeitem\"\n tabIndex={-1}\n {...handlers}\n className={treeItemContent({\n link: isLink,\n focused,\n selected,\n disabled,\n disabledOpacity,\n className: contentClassName,\n pressedClassName,\n })}\n >\n <ListItemChildren\n multiline={multiline}\n textClassName={textClassName}\n secondaryTextClassName={secondaryTextClassName}\n disableTextChildren={disableTextChildren}\n primaryText={primaryText}\n textProps={textProps}\n secondaryText={secondaryText}\n secondaryTextProps={secondaryTextProps}\n leftAddon={\n <TreeItemExpander\n isLeft\n itemId={itemId}\n addon={leftAddon}\n expanded={expanded}\n disabled={disabled}\n isLeafNode={isLeafNode}\n />\n }\n leftAddonType={leftAddonType}\n leftAddonPosition={leftAddonPosition}\n leftAddonClassName={treeItemMedia({\n isLeafNode,\n isMediaLeftAddon,\n className: leftAddonClassName,\n })}\n leftAddonForceWrap={leftAddonForceWrap}\n rightAddon={\n <TreeItemExpander\n itemId={itemId}\n addon={rightAddon}\n expanded={expanded}\n disabled={disabled}\n isLeafNode={isLeafNode}\n />\n }\n rightAddonType={rightAddonType}\n rightAddonPosition={rightAddonPosition}\n rightAddonClassName={rightAddonClassName}\n rightAddonForceWrap={rightAddonForceWrap}\n disableLeftAddonCenteredMedia={disableLeftAddonCenteredMedia}\n disableRightAddonCenteredMedia={disableRightAddonCenteredMedia}\n >\n {children}\n </ListItemChildren>\n {ripples}\n </ContentComponent>\n <TreeGroup\n id={`${id}-group`}\n temporary={temporaryChildItems}\n disableTransition={disableTransition}\n {...groupProps}\n depth={depth + 1}\n collapsed={isLeafNode || !expanded}\n >\n {childItems}\n </TreeGroup>\n </li>\n );\n}\n"],"names":["useEffect","useElementInteraction","useHigherContrastChildren","ListItemChildren","useKeyboardMovementContext","useEnsuredId","TreeGroup","TreeItemExpander","useTreeContext","treeItem","treeItemContent","treeItemMedia","TreeItem","props","id","propId","depth","liProps","disabled","disabledOpacity","groupProps","children","propChildren","className","itemId","leftAddon","leftAddonType","propLeftAddonType","leftAddonPosition","leftAddonClassName","leftAddonForceWrap","rightAddon","rightAddonType","rightAddonPosition","rightAddonClassName","rightAddonForceWrap","disableTextChildren","disableLeftAddonCenteredMedia","propDisableLeftAddonCenteredMedia","disableRightAddonCenteredMedia","textProps","textClassName","primaryText","secondaryText","secondaryTextProps","secondaryTextClassName","multiline","childItems","contentClassName","temporaryChildItems","disableTransition","propDisableTransition","onBlur","onClick","onKeyDown","onKeyUp","onMouseDown","onMouseUp","onMouseLeave","onDragStart","onTouchStart","onTouchEnd","onTouchMove","contentRef","disableRipple","remaining","to","undefined","href","expandedIds","selectedIds","expanderLeft","expansionMode","metadataLookup","linkComponent","Link","toggleTreeItemSelection","toggleTreeItemExpansion","contextDisableTransition","activeDescendantId","isLeafNode","focused","expanded","has","selected","lookup","current","expandable","disabledItems","elementToItem","itemToElement","pressedClassName","ripples","handlers","mode","event","isLink","ContentComponent","isMediaLeftAddon","li","role","expander","aria-expanded","aria-selected","aria-disabled","ref","tabIndex","link","isLeft","addon","temporary","collapsed"],"mappings":"AAAA;;AAEA,SAKEA,SAAS,QACJ,QAAQ;AAGf,SAASC,qBAAqB,QAAQ,0CAA0C;AAChF,SAASC,yBAAyB,QAAQ,8CAA8C;AACxF,SAASC,g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BC,qBAAqBA;wBACrBC,qBAAqBA;wBACrBE,+BAA+BA;wBAC/BE,gCAAgCA;kCAE/BlB;;oBAEFuE;;;0BAEH,KAACtF;gBACCQ,IAAI,GAAGA,GAAG,MAAM,CAAC;gBACjBgG,WAAW7D;gBACXC,mBAAmBA;gBAClB,GAAG9B,UAAU;gBACdJ,OAAOA,QAAQ;gBACf+F,WAAW/B,cAAc,CAACE;0BAEzBnC;;;;AAIT"}
|
|
1
|
+
{"version":3,"sources":["../../src/tree/TreeItem.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n type Ref,\n useEffect,\n} from \"react\";\n\nimport { type ComponentWithRippleProps } from \"../interaction/types.js\";\nimport { useElementInteraction } from \"../interaction/useElementInteraction.js\";\nimport { useHigherContrastChildren } from \"../interaction/useHigherContrastChildren.js\";\nimport { ListItemChildren } from \"../list/ListItemChildren.js\";\nimport { useKeyboardMovementContext } from \"../movement/useKeyboardMovementProvider.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { type OverridableTreeGroupProps, TreeGroup } from \"./TreeGroup.js\";\nimport { TreeItemExpander } from \"./TreeItemExpander.js\";\nimport { useTreeContext } from \"./TreeProvider.js\";\nimport { treeItem, treeItemContent, treeItemMedia } from \"./styles.js\";\nimport { type DefaultTreeItemNode } from \"./types.js\";\n\n/**\n * @since 6.0.0 Added `liProps` and `groupProps`.\n * @since 6.0.0 The `liRef`, `liStyle`, and `liClassName` props were removed in\n * favor of `liProps={{ ref, style, className }}`.\n * @since 6.0.0 The `itemIndex`, `listSize`, `renderChildItems`, `isLink`,\n * `contentComponent`, and `readOnly` props were removed.\n */\nexport interface TreeItemProps\n extends Omit<DefaultTreeItemNode, \"parentId\">,\n HTMLAttributes<HTMLLIElement>,\n ComponentWithRippleProps {\n /**\n * @defaultValue `\"tree-item-\" + useId()`\n */\n id?: string;\n\n /**\n * This is used to set the `--rmd-tree-depth` CSS variable which allows the\n * padding to increase for each nested tree.\n */\n depth: number;\n\n /**\n * Any additional props that should be passed to the surrounding `<li>`\n * element. The top-level props are passed to the `<span>` or `<a>` element\n * instead.\n */\n liProps?: PropsWithRef<HTMLAttributes<HTMLLIElement>>;\n\n /**\n * Any additional props to pass to the `TreeGroup` component.\n */\n groupProps?: PropsWithRef<OverridableTreeGroupProps>;\n\n /**\n * This should normally be the text/content to display within the tree item\n * and should **not** include nested trees.\n */\n children?: ReactNode;\n\n /**\n * The nested tree items to render within a `TreeGroup`.\n */\n childItems?: ReactNode;\n\n /** @defaultValue `false` */\n disableTransition?: boolean;\n\n /**\n * This ref is applied to the `<span>` or `<a>` element and can be used to\n * implement drag and drop behavior.\n */\n contentRef?: Ref<HTMLElement>;\n\n /**\n * Set this to `true` if the {@link childItems} should not be rendered while\n * collapsed.\n *\n * @defaultValue `false`\n */\n temporaryChildItems?: boolean;\n}\n\n/**\n * **Client Component**\n *\n * @see {@link https://react-md.dev/components/tree | Tree Demos}\n * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/treeview/}\n * @since 6.0.0 No longer forwards refs. The ref must be provided using\n * `contentRef` instead.\n * @since 6.0.0 The `liRef` was removed in favor of `liProps={{ ref }}`.\n * @since 6.0.0 The wrapping `<li>` element will always be `role=\"none\"` and the\n * `<span>` or `<a>` will gain the `role=\"treeitem\"` instead. This makes it\n * easier to pass event handlers because of the nested behavior of tree items.\n * @since 6.0.0 No longer provides the `aria-level`, `aria-setsize` and\n * `aria-posinset` attributes and allows the browser to compute them instead.\n */\nexport function TreeItem(props: TreeItemProps): ReactElement {\n const {\n id: propId,\n depth,\n liProps,\n disabled = false,\n disabledOpacity = false,\n groupProps,\n children: propChildren,\n className,\n itemId,\n leftAddon,\n leftAddonType: propLeftAddonType,\n leftAddonPosition,\n leftAddonClassName,\n leftAddonForceWrap,\n rightAddon,\n rightAddonType,\n rightAddonPosition,\n rightAddonClassName,\n rightAddonForceWrap,\n disableTextChildren,\n disableLeftAddonCenteredMedia: propDisableLeftAddonCenteredMedia,\n disableRightAddonCenteredMedia,\n textProps,\n textClassName,\n primaryText,\n secondaryText,\n secondaryTextProps,\n secondaryTextClassName,\n multiline,\n childItems,\n contentClassName,\n temporaryChildItems,\n disableTransition: propDisableTransition,\n onBlur,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onMouseLeave,\n onDragStart,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n contentRef,\n disableRipple,\n ...remaining\n } = props;\n\n const id = useEnsuredId(propId, \"tree-item\");\n const children = useHigherContrastChildren(propChildren);\n if (disabled) {\n // you can't really disable a link other than removing the href, so\n // unset these props\n remaining.to = undefined;\n remaining.href = undefined;\n }\n\n const {\n expandedIds,\n selectedIds,\n expanderLeft,\n expansionMode,\n metadataLookup,\n linkComponent: Link,\n toggleTreeItemSelection,\n toggleTreeItemExpansion,\n disableTransition: contextDisableTransition,\n } = useTreeContext();\n const { activeDescendantId } = useKeyboardMovementContext();\n\n const isLeafNode = !childItems;\n const focused = activeDescendantId === id;\n const expanded = expandedIds.has(itemId);\n const selected = selectedIds.has(itemId);\n const disableTransition = propDisableTransition ?? contextDisableTransition;\n\n useEffect(() => {\n const lookup = metadataLookup.current;\n lookup.expandable[itemId] = !isLeafNode;\n lookup.disabledItems[itemId] = disabled;\n lookup.elementToItem[id] = itemId;\n lookup.itemToElement[itemId] = id;\n\n return () => {\n /* eslint-disable @typescript-eslint/no-dynamic-delete */\n delete lookup.disabledItems[itemId];\n delete lookup.expandable[itemId];\n delete lookup.elementToItem[id];\n delete lookup.itemToElement[itemId];\n /* eslint-enable @typescript-eslint/no-dynamic-delete */\n };\n }, [id, metadataLookup, itemId, isLeafNode, disabled, depth]);\n\n const { pressedClassName, ripples, handlers } =\n useElementInteraction<HTMLLIElement>({\n mode: disableRipple ? \"none\" : undefined,\n onBlur,\n onClick(event) {\n onClick?.(event);\n toggleTreeItemSelection(itemId);\n if (!isLeafNode && expansionMode !== \"manual\") {\n toggleTreeItemExpansion(itemId);\n }\n },\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onMouseLeave,\n onDragStart,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n disabled,\n });\n\n const isLink = !!(remaining.to || remaining.href);\n\n // cheating a bit so there are type errors around the event handlers\n const ContentComponent = (isLink ? Link : \"span\") as \"span\";\n const leftAddonType =\n (propLeftAddonType ?? (expanderLeft && leftAddon)) ? \"media\" : undefined;\n const isMediaLeftAddon =\n typeof propLeftAddonType === \"undefined\" && leftAddonType === \"media\";\n const disableLeftAddonCenteredMedia =\n propDisableLeftAddonCenteredMedia ?? isMediaLeftAddon;\n\n return (\n <li\n {...liProps}\n role=\"none\"\n className={treeItem({\n className,\n expander: !!childItems,\n expanderLeft,\n })}\n >\n <ContentComponent\n {...remaining}\n // nodes with children should always apply the `aria-expanded` to show\n // that it is expandable while leaf nodes should remain omitted\n aria-expanded={isLeafNode ? undefined : expanded}\n aria-selected={selected}\n aria-disabled={disabled || undefined}\n id={id}\n ref={contentRef}\n role=\"treeitem\"\n tabIndex={-1}\n {...handlers}\n className={treeItemContent({\n link: isLink,\n focused,\n selected,\n disabled,\n disabledOpacity,\n className: contentClassName,\n pressedClassName,\n })}\n >\n <ListItemChildren\n multiline={multiline}\n textClassName={textClassName}\n secondaryTextClassName={secondaryTextClassName}\n disableTextChildren={disableTextChildren}\n primaryText={primaryText}\n textProps={textProps}\n secondaryText={secondaryText}\n secondaryTextProps={secondaryTextProps}\n leftAddon={\n <TreeItemExpander\n isLeft\n itemId={itemId}\n addon={leftAddon}\n expanded={expanded}\n disabled={disabled}\n isLeafNode={isLeafNode}\n />\n }\n leftAddonType={leftAddonType}\n leftAddonPosition={leftAddonPosition}\n leftAddonClassName={treeItemMedia({\n isLeafNode,\n isMediaLeftAddon,\n className: leftAddonClassName,\n })}\n leftAddonForceWrap={leftAddonForceWrap}\n rightAddon={\n <TreeItemExpander\n itemId={itemId}\n addon={rightAddon}\n expanded={expanded}\n disabled={disabled}\n isLeafNode={isLeafNode}\n />\n }\n rightAddonType={rightAddonType}\n rightAddonPosition={rightAddonPosition}\n rightAddonClassName={rightAddonClassName}\n rightAddonForceWrap={rightAddonForceWrap}\n disableLeftAddonCenteredMedia={disableLeftAddonCenteredMedia}\n disableRightAddonCenteredMedia={disableRightAddonCenteredMedia}\n >\n {children}\n </ListItemChildren>\n {ripples}\n </ContentComponent>\n <TreeGroup\n id={`${id}-group`}\n temporary={temporaryChildItems}\n disableTransition={disableTransition}\n {...groupProps}\n depth={depth + 1}\n collapsed={isLeafNode || !expanded}\n >\n {childItems}\n </TreeGroup>\n </li>\n );\n}\n"],"names":["useEffect","useElementInteraction","useHigherContrastChildren","ListItemChildren","useKeyboardMovementContext","useEnsuredId","TreeGroup","TreeItemExpander","useTreeContext","treeItem","treeItemContent","treeItemMedia","TreeItem","props","id","propId","depth","liProps","disabled","disabledOpacity","groupProps","children","propChildren","className","itemId","leftAddon","leftAddonType","propLeftAddonType","leftAddonPosition","leftAddonClassName","leftAddonForceWrap","rightAddon","rightAddonType","rightAddonPosition","rightAddonClassName","rightAddonForceWrap","disableTextChildren","disableLeftAddonCenteredMedia","propDisableLeftAddonCenteredMedia","disableRightAddonCenteredMedia","textProps","textClassName","primaryText","secondaryText","secondaryTextProps","secondaryTextClassName","multiline","childItems","contentClassName","temporaryChildItems","disableTransition","propDisableTransition","onBlur","onClick","onKeyDown","onKeyUp","onMouseDown","onMouseUp","onMouseLeave","onDragStart","onTouchStart","onTouchEnd","onTouchMove","contentRef","disableRipple","remaining","to","undefined","href","expandedIds","selectedIds","expanderLeft","expansionMode","metadataLookup","linkComponent","Link","toggleTreeItemSelection","toggleTreeItemExpansion","contextDisableTransition","activeDescendantId","isLeafNode","focused","expanded","has","selected","lookup","current","expandable","disabledItems","elementToItem","itemToElement","pressedClassName","ripples","handlers","mode","event","isLink","ContentComponent","isMediaLeftAddon","li","role","expander","aria-expanded","aria-selected","aria-disabled","ref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b;wBACAC,oBAAoBA;wBACpBC,0BACE,KAACxB;4BACCiB,QAAQA;4BACRqF,OAAO9E;4BACPmD,UAAUA;4BACVhE,UAAUA;4BACV8D,YAAYA;;wBAGhBhD,gBAAgBA;wBAChBC,oBAAoBA;wBACpBC,qBAAqBA;wBACrBC,qBAAqBA;wBACrBE,+BAA+BA;wBAC/BE,gCAAgCA;kCAE/BlB;;oBAEFuE;;;0BAEH,KAACtF;gBACCQ,IAAI,GAAGA,GAAG,MAAM,CAAC;gBACjBgG,WAAW7D;gBACXC,mBAAmBA;gBAClB,GAAG9B,UAAU;gBACdJ,OAAOA,QAAQ;gBACf+F,WAAW/B,cAAc,CAACE;0BAEzBnC;;;;AAIT"}
|
package/dist/tree/_tree.scss
CHANGED
|
@@ -134,7 +134,7 @@ $item-padding: calc(
|
|
|
134
134
|
.rmd-tree {
|
|
135
135
|
display: block;
|
|
136
136
|
height: 100%;
|
|
137
|
-
outline
|
|
137
|
+
outline: 0;
|
|
138
138
|
overflow: auto;
|
|
139
139
|
// this is mostly for firefox. moving the mouse even 1px while clicking will
|
|
140
140
|
// select the current item and all items to the tree root
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Dispatch, type HTMLAttributes, type ReactElement, type Ref, type SetStateAction } from "react";
|
|
2
2
|
/**
|
|
3
3
|
* A helper type that allows an optional `ref` to also be applied with a props
|
|
4
4
|
* object even though a `ref` isn't a real prop.
|
|
5
|
+
*
|
|
6
|
+
* @since 6.2.0 Automatically infer the `Element` type param from the provided
|
|
7
|
+
* props.
|
|
5
8
|
*/
|
|
6
|
-
export type PropsWithRef<Props extends object, Element extends HTMLElement> = Props & {
|
|
9
|
+
export type PropsWithRef<Props extends object, Element extends HTMLElement = Props extends HTMLAttributes<infer E> ? E extends HTMLElement ? E : never : never> = Props & {
|
|
7
10
|
/**
|
|
8
11
|
* An optional ref that can be applied.
|
|
9
12
|
*/
|
|
@@ -84,6 +87,18 @@ export type HtmlTagName = keyof JSX.IntrinsicElements;
|
|
|
84
87
|
* @since 6.0.0
|
|
85
88
|
*/
|
|
86
89
|
export type TextExtractor<T> = (item: T) => string;
|
|
90
|
+
/**
|
|
91
|
+
* - `"some value"` -> `"some value"`
|
|
92
|
+
* - `{ label: "Hello, world", value: 300 }` -> `"Hello, world!"`
|
|
93
|
+
* - `{ name: "Hello, world", value: 300 }` -> `"Hello, world!"`
|
|
94
|
+
*
|
|
95
|
+
* @since 6.2.0
|
|
96
|
+
*/
|
|
97
|
+
export type AutomaticTextExtraction = string | {
|
|
98
|
+
label: string;
|
|
99
|
+
} | {
|
|
100
|
+
name: string;
|
|
101
|
+
};
|
|
87
102
|
/**
|
|
88
103
|
* @since 6.0.0
|
|
89
104
|
* @internal
|
|
@@ -167,3 +182,15 @@ export interface ElementSize {
|
|
|
167
182
|
height: number;
|
|
168
183
|
width: number;
|
|
169
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* @since 6.2.0
|
|
187
|
+
*/
|
|
188
|
+
export type OverridableStringUnion<Defaults extends string, Overrides extends Partial<Record<string, boolean>>> = Exclude<Defaults, {
|
|
189
|
+
[K in keyof Overrides]: K;
|
|
190
|
+
}[keyof Overrides]> | {
|
|
191
|
+
[K in keyof Overrides]: Overrides[K] extends false ? never : K;
|
|
192
|
+
}[keyof Overrides];
|
|
193
|
+
/**
|
|
194
|
+
* @since 6.2.0
|
|
195
|
+
*/
|
|
196
|
+
export type IsEmptyObject<T> = keyof T extends never ? true : false;
|
package/dist/types.js
CHANGED
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import {\n type Dispatch,\n type HTMLAttributes,\n type ReactElement,\n type Ref,\n type SetStateAction,\n} from \"react\";\n\n/**\n * A helper type that allows an optional `ref` to also be applied with a props\n * object even though a `ref` isn't a real prop.\n *\n * @since 6.2.0 Automatically infer the `Element` type param from the provided\n * props.\n */\nexport type PropsWithRef<\n Props extends object,\n Element extends HTMLElement = Props extends HTMLAttributes<infer E>\n ? E extends HTMLElement\n ? E\n : never\n : never,\n> = Props & {\n /**\n * An optional ref that can be applied.\n */\n ref?: Ref<Element>;\n};\n\n/**\n * A simple type that can be used for different components that clone a\n * `className` into a child component.\n */\nexport type ClassNameCloneableChild<T = object> = ReactElement<\n T & { className?: string }\n>;\n\n/**\n * This type allows you to require at least one of the provided keys. This is\n * super helpful for things like `aria-label` or `aria-labelledby` when it's\n * required for a11y.\n *\n * @see https://stackoverflow.com/questions/40510611/typescript-interface-require-one-of-two-properties-to-exist/49725198#49725198\n */\nexport type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<\n T,\n Exclude<keyof T, Keys>\n> &\n {\n [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;\n }[Keys];\n\nexport interface LabelA11y {\n \"aria-label\"?: string;\n \"aria-labelledby\"?: string;\n}\n\n/**\n * A small accessibility helper to ensure that either `aria-label` or\n * `aria-labelledby` have been provided to a component.\n *\n * @example Simple Example\n * ```ts\n * import type { HTMLAttributes, ReactElement } from \"react\";\n * import type { LabelRequiredForA11y } from \"@react-md/core/types\";\n *\n * type Props = LabelRequiredForA11y<HTMLAttributes<HTMLDivElement>>;\n *\n * function Component(props: Props): ReactElement {\n * return <div {...props} />;\n * }\n *\n * const test1 = <Component />\n * // ^ type error\n * const test2 = <Component aria-label=\"Label\" />\n * const test3 = <Component aria-labelledby=\"some-other-id\" />\n * ```\n */\nexport type LabelRequiredForA11y<Props extends LabelA11y> = RequireAtLeastOne<\n Props,\n keyof LabelA11y\n>;\n\n/**\n * @since 5.0.0\n * @internal\n */\nexport interface NonNullRef<T> {\n readonly current: T;\n}\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport interface NonNullMutableRef<T> {\n current: T;\n}\n\n/** @since 6.0.0 */\nexport type HtmlTagName = keyof JSX.IntrinsicElements;\n\n/**\n * A function to get a string from a generic item.\n *\n * @example Simple Example\n * ```ts\n * interface Item {\n * name: string;\n * }\n *\n * const items: Item[] = [{ name: 'Hello' }, { name: 'World' }];\n *\n * const extractor: TextExtractor<Item> = (item) => item.name;\n * ```\n * @since 6.0.0\n */\nexport type TextExtractor<T> = (item: T) => string;\n\n/**\n * - `\"some value\"` -> `\"some value\"`\n * - `{ label: \"Hello, world\", value: 300 }` -> `\"Hello, world!\"`\n * - `{ name: \"Hello, world\", value: 300 }` -> `\"Hello, world!\"`\n *\n * @since 6.2.0\n */\nexport type AutomaticTextExtraction =\n | string\n | { label: string }\n | { name: string };\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport type UseStateSetter<T> = Dispatch<SetStateAction<T>>;\n\n/**\n * @since 6.0.0\n * @internal\n */\nexport type UseStateInitializer<T> = T | (() => T);\n\n/**\n * @example\n * ```ts\n * type Visibility = UseStateObject<\"visible\", boolean>;\n * // type Visibility = {\n * // visible: boolean;\n * // setVisible: UseStateSetter<boolean>\n * // }\n *\n * type AnotherOne = UseStateObject<\"renderAsSheet\", RenderMenuAsSheet>;\n * // type AnotherOne = {\n * // renderAsSheet: RenderMenuAsSheet;\n * // setRenderAsSheet: UseStateSetter<RenderMenuAsSheet>;\n * // }\n * ```\n * @since 6.0.0\n * @internal\n */\nexport type UseStateObject<Name extends string, Value> = {\n [key in Name]: Value;\n} & {\n [key in `set${Capitalize<Name>}`]: UseStateSetter<Value>;\n};\n\n/**\n * @example\n * ```ts\n * interface Example {\n * value: number;\n * setValue: UseStateSetter<number>;\n * }\n *\n * type WithPrefix = RenameKeysWithPrefix<Example, \"thumb1\">;\n * // type WithPrefix = {\n * // thumb1Value: number;\n * // thumb1SetValue: UseStateSetter<number>;\n * // }\n * ```\n *\n * @since 6.0.0\n * @internal\n */\nexport type RenameKeysWithPrefix<T, Prefix extends string> = {\n [Key in keyof T & string as `${Prefix}${Capitalize<Key>}`]: T[Key];\n};\n\n/**\n * @since 6.0.0\n */\nexport type CssPosition = \"fixed\" | \"sticky\" | \"static\";\n\n/**\n * @since 6.0.0\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyFunction = (...args: any[]) => any;\n\n/**\n * @since 6.0.0\n */\nexport type CancelableFunction<F extends AnyFunction> = F & {\n cancel: () => void;\n};\n\n/**\n * @since 6.0.0\n */\nexport type DebouncedFunction<F extends AnyFunction> = CancelableFunction<\n (...args: Parameters<F>) => void\n>;\n\n/**\n * @since 6.0.0\n */\nexport type ThrottledFunction<F extends AnyFunction> = CancelableFunction<\n (...args: Parameters<F>) => ReturnType<F>\n>;\n\n/**\n * @since 6.0.0\n */\nexport interface ElementSize {\n height: number;\n width: number;\n}\n\n/**\n * @since 6.2.0\n */\nexport type OverridableStringUnion<\n Defaults extends string,\n Overrides extends Partial<Record<string, boolean>>,\n> =\n | Exclude<Defaults, { [K in keyof Overrides]: K }[keyof Overrides]>\n | {\n [K in keyof Overrides]: Overrides[K] extends false ? never : K;\n }[keyof Overrides];\n\n/**\n * @since 6.2.0\n */\nexport type IsEmptyObject<T> = keyof T extends never ? true : false;\n"],"names":[],"mappings":"AAiPA;;CAEC,GACD,WAAoE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TextExtractor } from "../types.js";
|
|
1
|
+
import { type AutomaticTextExtraction, type TextExtractor } from "../types.js";
|
|
2
2
|
/** @since 6.0.0 */
|
|
3
3
|
export declare const DEFAULT_COLLATOR_OPTIONS: {
|
|
4
4
|
readonly numeric: true;
|
|
@@ -19,13 +19,13 @@ export interface AlphaNumericSortOptions<T> {
|
|
|
19
19
|
* @example Simple Example
|
|
20
20
|
* ```ts
|
|
21
21
|
* interface Item {
|
|
22
|
-
*
|
|
22
|
+
* nameField: string;
|
|
23
23
|
* }
|
|
24
24
|
*
|
|
25
|
-
* const items: Item[] = [{
|
|
25
|
+
* const items: Item[] = [{ nameField: 'Hello' }, { nameField: 'World' }];
|
|
26
26
|
*
|
|
27
27
|
* alphaNumericSort(items, {
|
|
28
|
-
* extractor: (item) => item.
|
|
28
|
+
* extractor: (item) => item.nameField,
|
|
29
29
|
* });
|
|
30
30
|
* ```
|
|
31
31
|
*
|
|
@@ -77,20 +77,20 @@ export interface AlphaNumericSortOptions<T> {
|
|
|
77
77
|
* @param list - The list of strings to sort
|
|
78
78
|
* @returns a new sorted list
|
|
79
79
|
*/
|
|
80
|
-
export declare function alphaNumericSort<T extends
|
|
80
|
+
export declare function alphaNumericSort<T extends AutomaticTextExtraction>(list: readonly T[], options?: AlphaNumericSortOptions<T>): readonly T[];
|
|
81
81
|
/**
|
|
82
82
|
* @example Simple Example
|
|
83
83
|
* ```ts
|
|
84
84
|
* interface Item {
|
|
85
|
-
*
|
|
85
|
+
* nameField: string;
|
|
86
86
|
* }
|
|
87
87
|
*
|
|
88
|
-
* const items: Item[] = [{
|
|
88
|
+
* const items: Item[] = [{ nameField: "World" }, { nameField: "Hello" }];
|
|
89
89
|
*
|
|
90
90
|
* const sorted = alphaNumericSort(items, {
|
|
91
|
-
* extractor: (item) => item.
|
|
91
|
+
* extractor: (item) => item.nameField,
|
|
92
92
|
* });
|
|
93
|
-
* // sorted == [{
|
|
93
|
+
* // sorted == [{ nameField: "Hello" }, { nameField: "World" }]
|
|
94
94
|
* ```
|
|
95
95
|
*
|
|
96
96
|
* @param list - The list of items to sort
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { defaultExtractor } from "../searching/utils.js";
|
|
2
|
+
/**
|
|
3
|
+
* @since 6.2.0
|
|
4
|
+
* @internal
|
|
5
|
+
*/ const DEFAULT_EXTRACTOR = defaultExtractor("alphaNumericSort");
|
|
2
6
|
/** @since 6.0.0 */ export const DEFAULT_COLLATOR_OPTIONS = {
|
|
3
7
|
numeric: true,
|
|
4
8
|
caseFirst: "upper"
|
|
@@ -10,7 +14,7 @@ import { defaultExtractor } from "../searching/utils.js";
|
|
|
10
14
|
* @since 6.0.0
|
|
11
15
|
*/ export const DEFAULT_COLLATOR = new Intl.Collator("en-US", DEFAULT_COLLATOR_OPTIONS);
|
|
12
16
|
export function alphaNumericSort(list, options = {}) {
|
|
13
|
-
const { compare = DEFAULT_COLLATOR.compare, extractor =
|
|
17
|
+
const { compare = DEFAULT_COLLATOR.compare, extractor = DEFAULT_EXTRACTOR, descending = false } = options;
|
|
14
18
|
const sorted = list.slice();
|
|
15
19
|
sorted.sort((a, b)=>{
|
|
16
20
|
const aValue = extractor(a);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/alphaNumericSort.ts"],"sourcesContent":["import { defaultExtractor } from \"../searching/utils.js\";\nimport { type TextExtractor } from \"../types.js\";\n\n/** @since 6.0.0 */\nexport const DEFAULT_COLLATOR_OPTIONS = {\n numeric: true,\n caseFirst: \"upper\",\n} as const satisfies Intl.CollatorOptions;\n\n/**\n * The default `Intl.Collator` that should be used for sorting large lists.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare#performance\n * @since 6.0.0\n */\nexport const DEFAULT_COLLATOR = new Intl.Collator(\n \"en-US\",\n DEFAULT_COLLATOR_OPTIONS\n);\n\n/** @since 6.0.0 */\nexport interface AlphaNumericSortOptions<T> {\n /**\n * The extractor is only required when the list of items are not strings.\n *\n * @example Simple Example\n * ```ts\n * interface Item {\n *
|
|
1
|
+
{"version":3,"sources":["../../src/utils/alphaNumericSort.ts"],"sourcesContent":["import { defaultExtractor } from \"../searching/utils.js\";\nimport { type AutomaticTextExtraction, type TextExtractor } from \"../types.js\";\n\n/**\n * @since 6.2.0\n * @internal\n */\nconst DEFAULT_EXTRACTOR = defaultExtractor(\"alphaNumericSort\");\n\n/** @since 6.0.0 */\nexport const DEFAULT_COLLATOR_OPTIONS = {\n numeric: true,\n caseFirst: \"upper\",\n} as const satisfies Intl.CollatorOptions;\n\n/**\n * The default `Intl.Collator` that should be used for sorting large lists.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare#performance\n * @since 6.0.0\n */\nexport const DEFAULT_COLLATOR = new Intl.Collator(\n \"en-US\",\n DEFAULT_COLLATOR_OPTIONS\n);\n\n/** @since 6.0.0 */\nexport interface AlphaNumericSortOptions<T> {\n /**\n * The extractor is only required when the list of items are not strings.\n *\n * @example Simple Example\n * ```ts\n * interface Item {\n * nameField: string;\n * }\n *\n * const items: Item[] = [{ nameField: 'Hello' }, { nameField: 'World' }];\n *\n * alphaNumericSort(items, {\n * extractor: (item) => item.nameField,\n * });\n * ```\n *\n * For javascript developers, this will throw an error in dev mode if an\n * extractor is not provided for non-string lists.\n *\n * @defaultValue `typeof item === \"string\" ? item : \"\"`\n */\n extractor?: TextExtractor<T>;\n\n /**\n * A custom compare function for sorting the list. This should really only be\n * provided if the language for your app is not `\"en-US\"` or you'd like to\n * provide some custom sorting options.\n *\n * @example Custom Compare using Intl.Collator\n * ```ts\n * const collator = new Intl.Collator(\"en-US\", {\n * numeric: false,\n * caseFirst: \"lower\",\n * usage: \"search\",\n * });\n *\n * alphaNumericSort(items, {\n * compare: collator.compare,\n * })\n * ```\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/Collator\n * @defaultValue `new Intl.Collator(\"en-US\", { numeric: true, caseFirst: \"upper\" }).compare`\n */\n compare?: (a: string, b: string) => number;\n\n /**\n * Setting this to `true` will return the list in descending order instead of\n * ascending.\n *\n * @defaultValue `false`\n */\n descending?: boolean;\n}\n\n/**\n * @example Simple Example\n * ```ts\n * const items = [\"World\", \"Hello\"];\n *\n * const sorted = alphaNumericSort(items);\n * // sorted == [\"Hello\", \"World\"]\n * ```\n *\n * @param list - The list of strings to sort\n * @returns a new sorted list\n */\nexport function alphaNumericSort<T extends AutomaticTextExtraction>(\n list: readonly T[],\n options?: AlphaNumericSortOptions<T>\n): readonly T[];\n/**\n * @example Simple Example\n * ```ts\n * interface Item {\n * nameField: string;\n * }\n *\n * const items: Item[] = [{ nameField: \"World\" }, { nameField: \"Hello\" }];\n *\n * const sorted = alphaNumericSort(items, {\n * extractor: (item) => item.nameField,\n * });\n * // sorted == [{ nameField: \"Hello\" }, { nameField: \"World\" }]\n * ```\n *\n * @param list - The list of items to sort\n * @returns a new sorted list\n */\nexport function alphaNumericSort<T>(\n list: readonly T[],\n options: AlphaNumericSortOptions<T> & { extractor: TextExtractor<T> }\n): readonly T[];\nexport function alphaNumericSort<T>(\n list: readonly T[],\n options: AlphaNumericSortOptions<T> = {}\n): readonly T[] {\n const {\n compare = DEFAULT_COLLATOR.compare,\n extractor = DEFAULT_EXTRACTOR,\n descending = false,\n } = options;\n\n const sorted = list.slice();\n sorted.sort((a, b) => {\n const aValue = extractor(a);\n const bValue = extractor(b);\n\n const value1 = descending ? bValue : aValue;\n const value2 = descending ? aValue : bValue;\n\n return compare(value1, value2);\n });\n\n return sorted;\n}\n"],"names":["defaultExtractor","DEFAULT_EXTRACTOR","DEFAULT_COLLATOR_OPTIONS","numeric","caseFirst","DEFAULT_COLLATOR","Intl","Collator","alphaNumericSort","list","options","compare","extractor","descending","sorted","slice","sort","a","b","aValue","bValue","value1","value2"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,wBAAwB;AAGzD;;;CAGC,GACD,MAAMC,oBAAoBD,iBAAiB;AAE3C,iBAAiB,GACjB,OAAO,MAAME,2BAA2B;IACtCC,SAAS;IACTC,WAAW;AACb,EAA0C;AAE1C;;;;;CAKC,GACD,OAAO,MAAMC,mBAAmB,IAAIC,KAAKC,QAAQ,CAC/C,SACAL,0BACA;AAiGF,OAAO,SAASM,iBACdC,IAAkB,EAClBC,UAAsC,CAAC,CAAC;IAExC,MAAM,EACJC,UAAUN,iBAAiBM,OAAO,EAClCC,YAAYX,iBAAiB,EAC7BY,aAAa,KAAK,EACnB,GAAGH;IAEJ,MAAMI,SAASL,KAAKM,KAAK;IACzBD,OAAOE,IAAI,CAAC,CAACC,GAAGC;QACd,MAAMC,SAASP,UAAUK;QACzB,MAAMG,SAASR,UAAUM;QAEzB,MAAMG,SAASR,aAAaO,SAASD;QACrC,MAAMG,SAAST,aAAaM,SAASC;QAErC,OAAOT,QAAQU,QAAQC;IACzB;IAEA,OAAOR;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-md/core",
|
|
3
|
-
"version": "6.1
|
|
3
|
+
"version": "6.2.1",
|
|
4
4
|
"description": "The core components and functionality for react-md.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sass": "./dist/_core.scss",
|
|
@@ -96,9 +96,9 @@
|
|
|
96
96
|
"@types/react": "^18.3.12",
|
|
97
97
|
"@types/react-dom": "^18.3.1",
|
|
98
98
|
"chokidar": "^4.0.3",
|
|
99
|
-
"eslint": "^9.
|
|
99
|
+
"eslint": "^9.29.0",
|
|
100
100
|
"filesize": "^10.1.6",
|
|
101
|
-
"glob": "11.0.
|
|
101
|
+
"glob": "11.0.3",
|
|
102
102
|
"jest": "^29.7.0",
|
|
103
103
|
"jest-environment-jsdom": "^29.7.0",
|
|
104
104
|
"jest-watch-typeahead": "^2.2.2",
|
|
@@ -110,12 +110,12 @@
|
|
|
110
110
|
"stylelint-config-prettier-scss": "^1.0.0",
|
|
111
111
|
"stylelint-config-recommended-scss": "^15.0.1",
|
|
112
112
|
"stylelint-order": "^7.0.0",
|
|
113
|
-
"stylelint-scss": "^6.12.
|
|
113
|
+
"stylelint-scss": "^6.12.1",
|
|
114
114
|
"ts-morph": "^26.0.0",
|
|
115
115
|
"ts-node": "^10.9.2",
|
|
116
|
-
"tsx": "^4.
|
|
116
|
+
"tsx": "^4.20.3",
|
|
117
117
|
"typescript": "^5.8.3",
|
|
118
|
-
"vitest": "^3.
|
|
118
|
+
"vitest": "^3.2.3"
|
|
119
119
|
},
|
|
120
120
|
"peerDependencies": {
|
|
121
121
|
"@jest/globals": "^29.7.0",
|
package/src/RootHtml.tsx
CHANGED
|
@@ -22,7 +22,7 @@ export interface RootHtmlProps extends HtmlHTMLAttributes<HTMLHtmlElement> {
|
|
|
22
22
|
* `ref` if that is required for some reason. Using a `ref` would make your
|
|
23
23
|
* root layout a client component though.
|
|
24
24
|
*/
|
|
25
|
-
bodyProps?: PropsWithRef<HTMLAttributes<HTMLBodyElement
|
|
25
|
+
bodyProps?: PropsWithRef<HTMLAttributes<HTMLBodyElement>>;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Convenience prop to replace `bodyProps={{ className: "custom-class-name" }}`.
|
|
@@ -9,20 +9,13 @@ import {
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @since 6.0.0
|
|
12
|
+
* @since 6.2.0 Added support for `item.name` and provide better error messaging.
|
|
12
13
|
* @internal
|
|
13
14
|
*/
|
|
14
|
-
export const defaultAutocompleteExtractor = (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"label" in item &&
|
|
19
|
-
typeof item.label === "string"
|
|
20
|
-
) {
|
|
21
|
-
return item.label;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return defaultExtractor("Autocomplete")(item);
|
|
25
|
-
};
|
|
15
|
+
export const defaultAutocompleteExtractor = defaultExtractor(
|
|
16
|
+
"Autocomplete",
|
|
17
|
+
"getOptionLabel"
|
|
18
|
+
);
|
|
26
19
|
|
|
27
20
|
/**
|
|
28
21
|
* @since 6.0.0
|