@hitachivantara/uikit-react-lab 3.48.1 → 3.49.2
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/AppSwitcherPanel/Action/Action.js.map +1 -1
- package/dist/AppSwitcherPanel/AppSwitcherPanel.js.map +1 -1
- package/dist/AppSwitcherPanel/TitleWithTooltip.js.map +1 -1
- package/dist/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/ColorPicker/Fields/Fields.js.map +1 -1
- package/dist/ColorPicker/Fields/styles.js.map +1 -1
- package/dist/ColorPicker/Picker/Picker.js.map +1 -1
- package/dist/ColorPicker/Picker/styles.js.map +1 -1
- package/dist/ColorPicker/PresetColors/PresetColors.js.map +1 -1
- package/dist/ColorPicker/PresetColors/styles.js.map +1 -1
- package/dist/Controls/Controls.js.map +1 -1
- package/dist/Controls/LeftControl/LeftControl.js.map +1 -1
- package/dist/Controls/RightControl/RightControl.js.map +1 -1
- package/dist/Controls/context/ControlsContext.js.map +1 -1
- package/dist/DotPagination/DotPagination.js.map +1 -1
- package/dist/Drawer/Drawer.js.map +1 -1
- package/dist/Drawer/styles.js.map +1 -1
- package/dist/FormComposer/FormComposer.js.map +1 -1
- package/dist/InlineEditor/InlineEditor.js.map +1 -1
- package/dist/NavigationAnchors/NavigationAnchors.js.map +1 -1
- package/dist/NavigationAnchors/NavigationOption.js.map +1 -1
- package/dist/NotificationPanel/EmptyStatePanel/EmptyStatePanel.js.map +1 -1
- package/dist/NotificationPanel/Notification/Notification.js.map +1 -1
- package/dist/NotificationPanel/NotificationPanel.js.map +1 -1
- package/dist/NotificationPanel/NotificationsIndicator/NotificationsIndicator.js.map +1 -1
- package/dist/ProgressBar/ProgressBar.js.map +1 -1
- package/dist/ProgressBar/ProgressBarSimulator.js.map +1 -1
- package/dist/QueryBuilder/ConfirmationDialog/ConfirmationDialog.js.map +1 -1
- package/dist/QueryBuilder/ConfirmationDialog/styles.js.map +1 -1
- package/dist/QueryBuilder/Context.js.map +1 -1
- package/dist/QueryBuilder/QueryBuilder.js.map +1 -1
- package/dist/QueryBuilder/Rule/Attribute/Attribute.js.map +1 -1
- package/dist/QueryBuilder/Rule/Operator/Operator.js.map +1 -1
- package/dist/QueryBuilder/Rule/Rule.js +0 -2
- package/dist/QueryBuilder/Rule/Rule.js.map +1 -1
- package/dist/QueryBuilder/Rule/Value/BooleanValue/BooleanValue.js.map +1 -1
- package/dist/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.js.map +1 -1
- package/dist/QueryBuilder/Rule/Value/DateTimeValue/styles.js.map +1 -1
- package/dist/QueryBuilder/Rule/Value/DateTimeValue/utils.js.map +1 -1
- package/dist/QueryBuilder/Rule/Value/NumericValue/NumericValue.js.map +1 -1
- package/dist/QueryBuilder/Rule/Value/NumericValue/styles.js.map +1 -1
- package/dist/QueryBuilder/Rule/Value/TextValue/TextValue.js.map +1 -1
- package/dist/QueryBuilder/Rule/Value/TextValue/styles.js.map +1 -1
- package/dist/QueryBuilder/Rule/Value/Value.js.map +1 -1
- package/dist/QueryBuilder/Rule/styles.js.map +1 -1
- package/dist/QueryBuilder/RuleGroup/RuleGroup.js +6 -2
- package/dist/QueryBuilder/RuleGroup/RuleGroup.js.map +1 -1
- package/dist/QueryBuilder/{types.ts → types.d.ts} +1 -1
- package/dist/QueryBuilder/utils/date.js.map +1 -1
- package/dist/QueryBuilder/utils/reducer.js.map +1 -1
- package/dist/Slider/KnobRing/KnobRing.js.map +1 -1
- package/dist/Slider/KnobRing/index.js.map +1 -1
- package/dist/Slider/Slider.js.map +1 -1
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableBody/TableBody.js.map +1 -1
- package/dist/Table/TableCell/TableCell.js.map +1 -1
- package/dist/Table/TableCell/styles.js.map +1 -1
- package/dist/Table/TableContainer/TableContainer.js.map +1 -1
- package/dist/Table/TableContext.js.map +1 -1
- package/dist/Table/TableHead/TableHead.js.map +1 -1
- package/dist/Table/TableHeader/TableHeader.js.map +1 -1
- package/dist/Table/TableHeader/styles.js.map +1 -1
- package/dist/Table/TableRow/TableRow.js.map +1 -1
- package/dist/Table/TableRow/styles.js.map +1 -1
- package/dist/Table/TableSectionContext.js.map +1 -1
- package/dist/Table/hooks/useBulkActions.js.map +1 -1
- package/dist/Table/hooks/usePagination.js.map +1 -1
- package/dist/Table/hooks/useResizeColumns.js.map +1 -1
- package/dist/Table/hooks/useRowExpand.js.map +1 -1
- package/dist/Table/hooks/useRowSelection.js.map +1 -1
- package/dist/Table/hooks/useSortBy.js.map +1 -1
- package/dist/Table/hooks/useSticky.js.map +1 -1
- package/dist/Table/hooks/useTable.js.map +1 -1
- package/dist/Table/hooks/useTableStyles.js.map +1 -1
- package/dist/Table/renderers/DateColumnCell/DateColumnCell.js.map +1 -1
- package/dist/Table/renderers/DropdownColumnCell/DropdownColumnCell.js.map +1 -1
- package/dist/Table/renderers/ProgressColumnCell/ProgressColumnCell.js.map +1 -1
- package/dist/Table/renderers/ProgressColumnCell/styles.js.map +1 -1
- package/dist/Table/renderers/SwitchColumnCell/SwitchColumnCell.js.map +1 -1
- package/dist/Table/renderers/SwitchColumnCell/styles.js.map +1 -1
- package/dist/Table/renderers/renderers.js.map +1 -1
- package/dist/Tag/Tag.js.map +1 -1
- package/dist/TimeAgo/TimeAgo.js.map +1 -1
- package/dist/TimeAgo/formatUtils.js.map +1 -1
- package/dist/TimeAgo/useTimeAgo.js.map +1 -1
- package/dist/TimeAgo/useTimeout.js.map +1 -1
- package/dist/TimePicker/PeriodPicker/PeriodPicker.js.map +1 -1
- package/dist/TimePicker/PeriodPicker/index.js.map +1 -1
- package/dist/TimePicker/TimePicker.js.map +1 -1
- package/dist/TimePicker/UnitTimePicker/UnitTimePicker.js.map +1 -1
- package/dist/TimePicker/UnitTimePicker/index.js.map +1 -1
- package/dist/TimePicker/timePickerConverter.js.map +1 -1
- package/dist/TimePicker/timePickerFormatter.js.map +1 -1
- package/dist/TimePicker/timePickerUtils.js.map +1 -1
- package/dist/legacy/QueryBuilder/Rule/Rule.js +0 -2
- package/dist/legacy/QueryBuilder/Rule/Rule.js.map +1 -1
- package/dist/legacy/QueryBuilder/RuleGroup/RuleGroup.js +6 -2
- package/dist/legacy/QueryBuilder/RuleGroup/RuleGroup.js.map +1 -1
- package/dist/legacy/QueryBuilder/{types.ts → types.d.ts} +1 -1
- package/dist/modern/QueryBuilder/Rule/Rule.js +0 -2
- package/dist/modern/QueryBuilder/Rule/Rule.js.map +1 -1
- package/dist/modern/QueryBuilder/RuleGroup/RuleGroup.js +6 -2
- package/dist/modern/QueryBuilder/RuleGroup/RuleGroup.js.map +1 -1
- package/dist/modern/QueryBuilder/{types.ts → types.d.ts} +1 -1
- package/dist/withStyleProps/WithStyleProps.js.map +1 -1
- package/package.json +22 -28
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSticky.js","names":["isSticky","value","test","getStickyValue","sticky","parent","columns","length","find","col","undefined","updateColumnAndParent","column","props","visibleColumnsHook","instance","toTheLeft","toTheRight","others","forEach","toLowerCase","push","firstNotSticky","isFirstNotSticky","lastNotSticky","isLastNotSticky","hasLeftSticky","lastLeftSticky","isLastLeftSticky","hasRightSticky","firstRightSticky","isFirstRightSticky","hasStickyColumns","calculateHeaderWidthsToTheRight","headers","right","i","header","totalRight","subHeaders","isVisible","totalWidth","useInstanceHook","getInstance","getTableHeadProps","getHooks","getRowProps","style","display","flex","getCellProps","isHeaderCell","totalMinWidth","alignItems","justifyContent","align","width","minWidth","stickyColumn","margin","totalLeft","stickyColumnMostLeft","stickyColumnLeastRight","borderLeft","borderRight","getTablePropsHook","nextProps","stickyHeader","stickyColumns","getTableHeadPropsHook","getHeaderGroupPropsHook","getHeaderPropsHook","getRowPropsHook","getCellPropsHook","cell","useSticky","hooks","visibleColumns","useInstance","getTableProps","getHeaderGroupProps","getHeaderProps","pluginName"],"sources":["../../../src/Table/hooks/useSticky.js"],"sourcesContent":["/* eslint-disable no-param-reassign */\n\nimport { makePropGetter, useGetLatest } from \"react-table\";\n\nconst isSticky = (value) => /left|right/i.test(value);\n\nconst getStickyValue = ({ sticky, parent }) => {\n if (isSticky(sticky)) {\n return sticky;\n }\n\n if (parent != null) {\n // check if parent is sticky\n sticky = getStickyValue(parent);\n if (isSticky(sticky)) {\n return sticky;\n }\n\n const { columns } = parent;\n // check if any column in the same group is sticky\n if (columns?.length > 0) {\n sticky = columns?.find((col) => col.sticky != null)?.sticky;\n if (isSticky(sticky)) {\n return sticky;\n }\n }\n }\n\n return undefined;\n};\n\nconst updateColumnAndParent = (column, props) => {\n Object.assign(column, props);\n\n if (column.parent != null) {\n updateColumnAndParent(column.parent, props);\n }\n};\n\nexport const visibleColumnsHook = (columns, { instance }) => {\n const toTheLeft = [];\n const toTheRight = [];\n const others = [];\n\n columns.forEach((column) => {\n const sticky = getStickyValue(column)?.toLowerCase();\n\n updateColumnAndParent(column, { sticky });\n\n if (sticky === \"left\") {\n toTheLeft.push(column);\n } else if (sticky === \"right\") {\n toTheRight.push(column);\n } else {\n others.push(column);\n }\n });\n\n if (others.length > 0) {\n const [firstNotSticky] = others;\n updateColumnAndParent(firstNotSticky, { isFirstNotSticky: true });\n\n const lastNotSticky = others[others.length - 1];\n updateColumnAndParent(lastNotSticky, { isLastNotSticky: true });\n }\n\n const hasLeftSticky = toTheLeft.length > 0;\n if (hasLeftSticky) {\n const lastLeftSticky = toTheLeft[toTheLeft.length - 1];\n\n updateColumnAndParent(lastLeftSticky, { isLastLeftSticky: true });\n }\n\n const hasRightSticky = toTheRight.length > 0;\n if (hasRightSticky) {\n const [firstRightSticky] = toTheRight;\n\n updateColumnAndParent(firstRightSticky, { isFirstRightSticky: true });\n }\n\n instance.hasStickyColumns = hasLeftSticky || hasRightSticky;\n\n return [...toTheLeft, ...others, ...toTheRight];\n};\n\nconst calculateHeaderWidthsToTheRight = (headers, right = 0) => {\n if (!headers?.length) {\n return;\n }\n\n for (let i = headers.length - 1; i !== -1; i -= 1) {\n const header = headers[i];\n\n header.totalRight = right;\n\n const { headers: subHeaders } = header;\n if (subHeaders?.length > 0) {\n calculateHeaderWidthsToTheRight(subHeaders, right);\n }\n\n if (header.isVisible) {\n right += header.totalWidth;\n }\n }\n};\n\nexport const useInstanceHook = (instance) => {\n calculateHeaderWidthsToTheRight(instance.headers);\n\n const getInstance = useGetLatest(instance);\n instance.getTableHeadProps = makePropGetter(instance.getHooks().getTableHeadProps, {\n instance: getInstance(),\n });\n};\n\nconst getRowProps = () => ({\n style: {\n display: \"flex\",\n flex: \"1 0 auto\",\n },\n});\n\nconst getCellProps = (header, isHeaderCell) => {\n const props = {\n style: {\n display: \"inline-flex\",\n flex: `${header.totalWidth} ${header.totalMinWidth} auto`,\n alignItems: isHeaderCell ? \"start\" : \"center\",\n justifyContent: header.align,\n\n width: `${header.totalWidth}px`,\n minWidth: `${header.totalMinWidth}px`,\n },\n };\n\n if (header.sticky != null) {\n props.stickyColumn = true;\n\n const margin = header.sticky === \"left\" ? header.totalLeft : header.totalRight;\n\n props.style[header.sticky] = `${margin}px`;\n\n if (header.isLastLeftSticky) {\n props.stickyColumnMostLeft = true;\n }\n\n if (header.isFirstRightSticky) {\n props.stickyColumnLeastRight = true;\n }\n } else {\n if (header.isFirstNotSticky) {\n props.style.borderLeft = 0;\n }\n\n if (header.isLastNotSticky) {\n props.style.borderRight = 0;\n }\n }\n\n return props;\n};\n\n/*\n * STICKY POSITION MANAGEMENT\n * <thead>: sticky if stickyHeader: true\n * <tr>: never sticky\n * <th>: sticky only if that particular column is sticky (left or right)\n */\n\n/*\n * We need to hide the last non sticky column right border, to avoid issues with double borders.\n *\n * This could be done with css, using the `:has()` selector:\n * - \".not-sticky:has(+ .first-right-sticky)\": { border-right: 0 }\n *\n * Until the `:has()` selector is supported by modern browsers,\n * that at the moment is just a proposal https://developer.mozilla.org/en-US/docs/Web/CSS/:has,\n * we need to override the last not sticky column \"borderRight\" here.\n */\n\n// props target: <table>\nexport const getTablePropsHook = (props, { instance }) => {\n const nextProps = {\n stickyHeader: instance.stickyHeader,\n stickyColumns: instance.hasStickyColumns,\n };\n\n return [props, nextProps];\n};\n\n// props target: <table><thead>\nexport const getTableHeadPropsHook = (props, { instance }) => {\n const nextProps = {\n stickyHeader: instance.stickyHeader,\n };\n\n return [props, nextProps];\n};\n\n// props target: <table><thead><tr>\nexport const getHeaderGroupPropsHook = (props, { instance }) => {\n const nextProps = instance.hasStickyColumns ? getRowProps() : {};\n\n return [props, nextProps];\n};\n\n// props target: <table><thead><tr><th>\nexport const getHeaderPropsHook = (props, { instance, column }) => {\n const nextProps = instance.hasStickyColumns ? getCellProps(column, true) : {};\n\n return [props, nextProps];\n};\n\n// props target: <table><tbody><tr>\nexport const getRowPropsHook = (props, { instance }) => {\n const nextProps = instance.hasStickyColumns ? getRowProps() : {};\n\n return [props, nextProps];\n};\n\n// props target: <table><tbody><tr><td>\nexport const getCellPropsHook = (props, { instance, cell }) => {\n const nextProps = instance.hasStickyColumns ? getCellProps(cell.column, false) : {};\n\n return [props, nextProps];\n};\n\nconst useSticky = (hooks) => {\n hooks.visibleColumns.push(visibleColumnsHook);\n hooks.useInstance.push(useInstanceHook);\n\n // props target: <table>\n hooks.getTableProps.push(getTablePropsHook);\n // props target: <table><thead>\n hooks.getTableHeadProps = [getTableHeadPropsHook];\n // props target: <table><thead><tr>\n hooks.getHeaderGroupProps.push(getHeaderGroupPropsHook);\n // props target: <table><thead><tr><th>\n hooks.getHeaderProps.push(getHeaderPropsHook);\n // props target: <table><tbody><tr>\n hooks.getRowProps.push(getRowPropsHook);\n // props target: <table><tbody><tr><td>\n hooks.getCellProps.push(getCellPropsHook);\n};\n\nuseSticky.pluginName = \"useHvTableSticky\";\n\nexport default useSticky;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAEA;;AAFA;AAIA,IAAMA,QAAQ,GAAG,SAAXA,QAAW,CAACC,KAAD;EAAA,OAAW,cAAcC,IAAd,CAAmBD,KAAnB,CAAX;AAAA,CAAjB;;AAEA,IAAME,cAAc,GAAG,SA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ickyValue","sticky","parent","columns","length","find","col","undefined","updateColumnAndParent","column","props","visibleColumnsHook","instance","toTheLeft","toTheRight","others","forEach","toLowerCase","push","firstNotSticky","isFirstNotSticky","lastNotSticky","isLastNotSticky","hasLeftSticky","lastLeftSticky","isLastLeftSticky","hasRightSticky","firstRightSticky","isFirstRightSticky","hasStickyColumns","calculateHeaderWidthsToTheRight","headers","right","i","header","totalRight","subHeaders","isVisible","totalWidth","useInstanceHook","getInstance","useGetLatest","getTableHeadProps","makePropGetter","getHooks","getRowProps","style","display","flex","getCellProps","isHeaderCell","totalMinWidth","alignItems","justifyContent","align","width","minWidth","stickyColumn","margin","totalLeft","stickyColumnMostLeft","stickyColumnLeastRight","borderLeft","borderRight","getTablePropsHook","nextProps","stickyHeader","stickyColumns","getTableHeadPropsHook","getHeaderGroupPropsHook","getHeaderPropsHook","getRowPropsHook","getCellPropsHook","cell","useSticky","hooks","visibleColumns","useInstance","getTableProps","getHeaderGroupProps","getHeaderProps","pluginName"],"sources":["../../../src/Table/hooks/useSticky.js"],"sourcesContent":["/* eslint-disable no-param-reassign */\n\nimport { makePropGetter, useGetLatest } from \"react-table\";\n\nconst isSticky = (value) => /left|right/i.test(value);\n\nconst getStickyValue = ({ sticky, parent }) => {\n if (isSticky(sticky)) {\n return sticky;\n }\n\n if (parent != null) {\n // check if parent is sticky\n sticky = getStickyValue(parent);\n if (isSticky(sticky)) {\n return sticky;\n }\n\n const { columns } = parent;\n // check if any column in the same group is sticky\n if (columns?.length > 0) {\n sticky = columns?.find((col) => col.sticky != null)?.sticky;\n if (isSticky(sticky)) {\n return sticky;\n }\n }\n }\n\n return undefined;\n};\n\nconst updateColumnAndParent = (column, props) => {\n Object.assign(column, props);\n\n if (column.parent != null) {\n updateColumnAndParent(column.parent, props);\n }\n};\n\nexport const visibleColumnsHook = (columns, { instance }) => {\n const toTheLeft = [];\n const toTheRight = [];\n const others = [];\n\n columns.forEach((column) => {\n const sticky = getStickyValue(column)?.toLowerCase();\n\n updateColumnAndParent(column, { sticky });\n\n if (sticky === \"left\") {\n toTheLeft.push(column);\n } else if (sticky === \"right\") {\n toTheRight.push(column);\n } else {\n others.push(column);\n }\n });\n\n if (others.length > 0) {\n const [firstNotSticky] = others;\n updateColumnAndParent(firstNotSticky, { isFirstNotSticky: true });\n\n const lastNotSticky = others[others.length - 1];\n updateColumnAndParent(lastNotSticky, { isLastNotSticky: true });\n }\n\n const hasLeftSticky = toTheLeft.length > 0;\n if (hasLeftSticky) {\n const lastLeftSticky = toTheLeft[toTheLeft.length - 1];\n\n updateColumnAndParent(lastLeftSticky, { isLastLeftSticky: true });\n }\n\n const hasRightSticky = toTheRight.length > 0;\n if (hasRightSticky) {\n const [firstRightSticky] = toTheRight;\n\n updateColumnAndParent(firstRightSticky, { isFirstRightSticky: true });\n }\n\n instance.hasStickyColumns = hasLeftSticky || hasRightSticky;\n\n return [...toTheLeft, ...others, ...toTheRight];\n};\n\nconst calculateHeaderWidthsToTheRight = (headers, right = 0) => {\n if (!headers?.length) {\n return;\n }\n\n for (let i = headers.length - 1; i !== -1; i -= 1) {\n const header = headers[i];\n\n header.totalRight = right;\n\n const { headers: subHeaders } = header;\n if (subHeaders?.length > 0) {\n calculateHeaderWidthsToTheRight(subHeaders, right);\n }\n\n if (header.isVisible) {\n right += header.totalWidth;\n }\n }\n};\n\nexport const useInstanceHook = (instance) => {\n calculateHeaderWidthsToTheRight(instance.headers);\n\n const getInstance = useGetLatest(instance);\n instance.getTableHeadProps = makePropGetter(instance.getHooks().getTableHeadProps, {\n instance: getInstance(),\n });\n};\n\nconst getRowProps = () => ({\n style: {\n display: \"flex\",\n flex: \"1 0 auto\",\n },\n});\n\nconst getCellProps = (header, isHeaderCell) => {\n const props = {\n style: {\n display: \"inline-flex\",\n flex: `${header.totalWidth} ${header.totalMinWidth} auto`,\n alignItems: isHeaderCell ? \"start\" : \"center\",\n justifyContent: header.align,\n\n width: `${header.totalWidth}px`,\n minWidth: `${header.totalMinWidth}px`,\n },\n };\n\n if (header.sticky != null) {\n props.stickyColumn = true;\n\n const margin = header.sticky === \"left\" ? header.totalLeft : header.totalRight;\n\n props.style[header.sticky] = `${margin}px`;\n\n if (header.isLastLeftSticky) {\n props.stickyColumnMostLeft = true;\n }\n\n if (header.isFirstRightSticky) {\n props.stickyColumnLeastRight = true;\n }\n } else {\n if (header.isFirstNotSticky) {\n props.style.borderLeft = 0;\n }\n\n if (header.isLastNotSticky) {\n props.style.borderRight = 0;\n }\n }\n\n return props;\n};\n\n/*\n * STICKY POSITION MANAGEMENT\n * <thead>: sticky if stickyHeader: true\n * <tr>: never sticky\n * <th>: sticky only if that particular column is sticky (left or right)\n */\n\n/*\n * We need to hide the last non sticky column right border, to avoid issues with double borders.\n *\n * This could be done with css, using the `:has()` selector:\n * - \".not-sticky:has(+ .first-right-sticky)\": { border-right: 0 }\n *\n * Until the `:has()` selector is supported by modern browsers,\n * that at the moment is just a proposal https://developer.mozilla.org/en-US/docs/Web/CSS/:has,\n * we need to override the last not sticky column \"borderRight\" here.\n */\n\n// props target: <table>\nexport const getTablePropsHook = (props, { instance }) => {\n const nextProps = {\n stickyHeader: instance.stickyHeader,\n stickyColumns: instance.hasStickyColumns,\n };\n\n return [props, nextProps];\n};\n\n// props target: <table><thead>\nexport const getTableHeadPropsHook = (props, { instance }) => {\n const nextProps = {\n stickyHeader: instance.stickyHeader,\n };\n\n return [props, nextProps];\n};\n\n// props target: <table><thead><tr>\nexport const getHeaderGroupPropsHook = (props, { instance }) => {\n const nextProps = instance.hasStickyColumns ? getRowProps() : {};\n\n return [props, nextProps];\n};\n\n// props target: <table><thead><tr><th>\nexport const getHeaderPropsHook = (props, { instance, column }) => {\n const nextProps = instance.hasStickyColumns ? getCellProps(column, true) : {};\n\n return [props, nextProps];\n};\n\n// props target: <table><tbody><tr>\nexport const getRowPropsHook = (props, { instance }) => {\n const nextProps = instance.hasStickyColumns ? getRowProps() : {};\n\n return [props, nextProps];\n};\n\n// props target: <table><tbody><tr><td>\nexport const getCellPropsHook = (props, { instance, cell }) => {\n const nextProps = instance.hasStickyColumns ? getCellProps(cell.column, false) : {};\n\n return [props, nextProps];\n};\n\nconst useSticky = (hooks) => {\n hooks.visibleColumns.push(visibleColumnsHook);\n hooks.useInstance.push(useInstanceHook);\n\n // props target: <table>\n hooks.getTableProps.push(getTablePropsHook);\n // props target: <table><thead>\n hooks.getTableHeadProps = [getTableHeadPropsHook];\n // props target: <table><thead><tr>\n hooks.getHeaderGroupProps.push(getHeaderGroupPropsHook);\n // props target: <table><thead><tr><th>\n hooks.getHeaderProps.push(getHeaderPropsHook);\n // props target: <table><tbody><tr>\n hooks.getRowProps.push(getRowPropsHook);\n // props target: <table><tbody><tr><td>\n hooks.getCellProps.push(getCellPropsHook);\n};\n\nuseSticky.pluginName = \"useHvTableSticky\";\n\nexport default useSticky;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAEA;;AAFA;AAIA,IAAMA,QAAQ,GAAG,SAAXA,QAAW,CAACC,KAAD;EAAA,OAAW,cAAcC,IAAd,CAAmBD,KAAnB,CAAX;AAAA,CAAjB;;AAEA,IAAME,cAAc,GAAG,SAAjBA,cAAiB,OAAwB;EAAA,IAArBC,MAAqB,QAArBA,MAAqB;EAAA,IAAbC,MAAa,QAAbA,MAAa;;EAC7C,IAAIL,QAAQ,CAACI,MAAD,CAAZ,EAAsB;IACpB,OAAOA,MAAP;EACD;;EAED,IAAIC,MAAM,IAAI,IAAd,EAAoB;IAClB;IACAD,MAAM,GAAGD,cAAc,CAACE,MAAD,CAAvB;;IACA,IAAIL,QAAQ,CAACI,MAAD,CAAZ,EAAsB;MACpB,OAAOA,MAAP;IACD;;IAED,IAAQE,OAAR,GAAoBD,MAApB,CAAQC,OAAR,CAPkB,CAQlB;;IACA,IAAI,CAAAA,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEC,MAAT,IAAkB,CAAtB,EAAyB;MAAA;;MACvBH,MAAM,GAAGE,OAAH,aAAGA,OAAH,wCAAG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AMS,SAAS,GAAG,SAAZA,SAAY,CAACC,KAAD,EAAW;EAC3BA,KAAK,CAACC,cAAN,CAAqB1D,IAArB,CAA0BP,kBAA1B;EACAgE,KAAK,CAACE,WAAN,CAAkB3D,IAAlB,CAAuBqB,eAAvB,EAF2B,CAI3B;;EACAoC,KAAK,CAACG,aAAN,CAAoB5D,IAApB,CAAyB8C,iBAAzB,EAL2B,CAM3B;;EACAW,KAAK,CAACjC,iBAAN,GAA0B,CAAC0B,qBAAD,CAA1B,CAP2B,CAQ3B;;EACAO,KAAK,CAACI,mBAAN,CAA0B7D,IAA1B,CAA+BmD,uBAA/B,EAT2B,CAU3B;;EACAM,KAAK,CAACK,cAAN,CAAqB9D,IAArB,CAA0BoD,kBAA1B,EAX2B,CAY3B;;EACAK,KAAK,CAAC9B,WAAN,CAAkB3B,IAAlB,CAAuBqD,eAAvB,EAb2B,CAc3B;;EACAI,KAAK,CAAC1B,YAAN,CAAmB/B,IAAnB,CAAwBsD,gBAAxB;AACD,CAhBD;;AAkBAE,SAAS,CAACO,UAAV,GAAuB,kBAAvB;eAEeP,S"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTable.js","names":["toTitleCase","str","replace","toLowerCase","m","toUpperCase","trim","useDefaultData","data","useDefaultColumns","columns","uniqueKeys","Object","keys","filter","key","includes","map","accessor","Header","ensureCorePluginInstallation","plugins","hvPluginName","corePluginToInstall","indexOfCorePlugin","findIndex","plugin","pluginName","indexOfHvPlugin","splice","useInstanceHook","instance","rowsById","initialRowsById","useHvTableSetup","hooks","useInstance","push","useHvTable","props","dataProp","columnsProp","others","usePagination","useExpanded","useSortBy","useResizeColumns","indexOfHvTableStylesPlugin","useHvTableStyles","useTable"],"sources":["../../../src/Table/hooks/useTable.js"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useTable, usePagination, useExpanded, useSortBy, useResizeColumns } from \"react-table\";\n\nimport useHvTableStyles from \"./useTableStyles\";\n\nconst toTitleCase = (str) => {\n return str\n .replace(/([^A-Z])([A-Z])/g, \"$1 $2\") // split cameCase\n .replace(/[_-]+/g, \" \") // split snake_case and lisp-case\n .toLowerCase()\n .replace(/(^\\w|\\b\\w)/g, (m) => m.toUpperCase()) // title case words\n .replace(/\\s+/g, \" \") // collapse repeated whitespace\n .trim(); // remove leading/trailing whitespace\n};\n\nconst useDefaultData = (data) =>\n useMemo(() => {\n return data || [];\n }, [data]);\n\nconst useDefaultColumns = (columns, data) =>\n useMemo(() => {\n if (columns != null) {\n return columns;\n }\n\n const uniqueKeys = Object.keys(Object.assign({}, ...data));\n return uniqueKeys\n .filter((key) => ![\"subRows\", \"subComponent\"].includes(key))\n .map((key) => ({\n accessor: key,\n Header: toTitleCase(key),\n }));\n }, [columns, data]);\n\nconst ensureCorePluginInstallation = (plugins, hvPluginName, corePluginToInstall) => {\n const indexOfCorePlugin = plugins.findIndex(\n (plugin) => plugin.pluginName === corePluginToInstall.pluginName\n );\n const indexOfHvPlugin = plugins.findIndex((plugin) => plugin.pluginName === hvPluginName);\n\n if (indexOfHvPlugin !== -1 && (indexOfCorePlugin === -1 || indexOfCorePlugin > indexOfHvPlugin)) {\n if (indexOfCorePlugin > -1) {\n plugins.splice(indexOfCorePlugin, 1);\n }\n\n plugins.splice(indexOfHvPlugin, 0, corePluginToInstall);\n }\n};\n\nconst useInstanceHook = (instance) => {\n const { rowsById } = instance;\n\n Object.assign(instance, {\n initialRowsById: rowsById,\n });\n};\n\nconst useHvTableSetup = (hooks) => {\n hooks.useInstance.push(useInstanceHook);\n};\n\nuseHvTableSetup.pluginName = \"useHvTableSetup\";\n\nconst useHvTable = (props, ...plugins) => {\n const { data: dataProp, columns: columnsProp, ...others } = props;\n\n const data = useDefaultData(dataProp);\n const columns = useDefaultColumns(columnsProp, data);\n\n ensureCorePluginInstallation(plugins, \"useHvPagination\", usePagination);\n ensureCorePluginInstallation(plugins, \"useHvRowExpand\", useExpanded);\n ensureCorePluginInstallation(plugins, \"useHvSortBy\", useSortBy);\n ensureCorePluginInstallation(plugins, \"useHvResizeColumns\", useResizeColumns);\n\n const indexOfHvTableStylesPlugin = plugins.findIndex(\n (plugin) => plugin.pluginName === \"useHvTableStyles\"\n );\n if (indexOfHvTableStylesPlugin === -1) {\n plugins.push(useHvTableStyles);\n }\n\n // main hook call\n return useTable(\n {\n data,\n columns,\n ...others,\n },\n useHvTableSetup,\n ...plugins\n );\n};\n\nexport default useHvTable;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;;;;;;;AAEA,IAAMA,WAAW,GAAG,SAAdA,WAAc,CAACC,GAAD,EAAS;EAC3B,OAAOA,GAAG,CACPC,OADI,CACI,kBADJ,EACwB,OADxB,EACiC;EADjC,CAEJA,OAFI,CAEI,QAFJ,EAEc,GAFd,EAEmB;EAFnB,CAGJC,WAHI,GAIJD,OAJI,CAII,aAJJ,EAImB,UAACE,CAAD;IAAA,OAAOA,CAAC,CAACC,WAAF,EAAP;EAAA,CAJnB,EAI2C;EAJ3C,CAKJH,OALI,CAKI,MALJ,EAKY,GALZ,EAKiB;EALjB,CAMJI,IANI,EAAP,CAD2B,CAOhB;AACZ,CARD;;AAUA,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAACC,IAAD;EAAA,OACrB,
|
|
1
|
+
{"version":3,"file":"useTable.js","names":["toTitleCase","str","replace","toLowerCase","m","toUpperCase","trim","useDefaultData","data","useMemo","useDefaultColumns","columns","uniqueKeys","Object","keys","filter","key","includes","map","accessor","Header","ensureCorePluginInstallation","plugins","hvPluginName","corePluginToInstall","indexOfCorePlugin","findIndex","plugin","pluginName","indexOfHvPlugin","splice","useInstanceHook","instance","rowsById","initialRowsById","useHvTableSetup","hooks","useInstance","push","useHvTable","props","dataProp","columnsProp","others","usePagination","useExpanded","useSortBy","useResizeColumns","indexOfHvTableStylesPlugin","useHvTableStyles","useTable"],"sources":["../../../src/Table/hooks/useTable.js"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useTable, usePagination, useExpanded, useSortBy, useResizeColumns } from \"react-table\";\n\nimport useHvTableStyles from \"./useTableStyles\";\n\nconst toTitleCase = (str) => {\n return str\n .replace(/([^A-Z])([A-Z])/g, \"$1 $2\") // split cameCase\n .replace(/[_-]+/g, \" \") // split snake_case and lisp-case\n .toLowerCase()\n .replace(/(^\\w|\\b\\w)/g, (m) => m.toUpperCase()) // title case words\n .replace(/\\s+/g, \" \") // collapse repeated whitespace\n .trim(); // remove leading/trailing whitespace\n};\n\nconst useDefaultData = (data) =>\n useMemo(() => {\n return data || [];\n }, [data]);\n\nconst useDefaultColumns = (columns, data) =>\n useMemo(() => {\n if (columns != null) {\n return columns;\n }\n\n const uniqueKeys = Object.keys(Object.assign({}, ...data));\n return uniqueKeys\n .filter((key) => ![\"subRows\", \"subComponent\"].includes(key))\n .map((key) => ({\n accessor: key,\n Header: toTitleCase(key),\n }));\n }, [columns, data]);\n\nconst ensureCorePluginInstallation = (plugins, hvPluginName, corePluginToInstall) => {\n const indexOfCorePlugin = plugins.findIndex(\n (plugin) => plugin.pluginName === corePluginToInstall.pluginName\n );\n const indexOfHvPlugin = plugins.findIndex((plugin) => plugin.pluginName === hvPluginName);\n\n if (indexOfHvPlugin !== -1 && (indexOfCorePlugin === -1 || indexOfCorePlugin > indexOfHvPlugin)) {\n if (indexOfCorePlugin > -1) {\n plugins.splice(indexOfCorePlugin, 1);\n }\n\n plugins.splice(indexOfHvPlugin, 0, corePluginToInstall);\n }\n};\n\nconst useInstanceHook = (instance) => {\n const { rowsById } = instance;\n\n Object.assign(instance, {\n initialRowsById: rowsById,\n });\n};\n\nconst useHvTableSetup = (hooks) => {\n hooks.useInstance.push(useInstanceHook);\n};\n\nuseHvTableSetup.pluginName = \"useHvTableSetup\";\n\nconst useHvTable = (props, ...plugins) => {\n const { data: dataProp, columns: columnsProp, ...others } = props;\n\n const data = useDefaultData(dataProp);\n const columns = useDefaultColumns(columnsProp, data);\n\n ensureCorePluginInstallation(plugins, \"useHvPagination\", usePagination);\n ensureCorePluginInstallation(plugins, \"useHvRowExpand\", useExpanded);\n ensureCorePluginInstallation(plugins, \"useHvSortBy\", useSortBy);\n ensureCorePluginInstallation(plugins, \"useHvResizeColumns\", useResizeColumns);\n\n const indexOfHvTableStylesPlugin = plugins.findIndex(\n (plugin) => plugin.pluginName === \"useHvTableStyles\"\n );\n if (indexOfHvTableStylesPlugin === -1) {\n plugins.push(useHvTableStyles);\n }\n\n // main hook call\n return useTable(\n {\n data,\n columns,\n ...others,\n },\n useHvTableSetup,\n ...plugins\n );\n};\n\nexport default useHvTable;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;;;;;;;AAEA,IAAMA,WAAW,GAAG,SAAdA,WAAc,CAACC,GAAD,EAAS;EAC3B,OAAOA,GAAG,CACPC,OADI,CACI,kBADJ,EACwB,OADxB,EACiC;EADjC,CAEJA,OAFI,CAEI,QAFJ,EAEc,GAFd,EAEmB;EAFnB,CAGJC,WAHI,GAIJD,OAJI,CAII,aAJJ,EAImB,UAACE,CAAD;IAAA,OAAOA,CAAC,CAACC,WAAF,EAAP;EAAA,CAJnB,EAI2C;EAJ3C,CAKJH,OALI,CAKI,MALJ,EAKY,GALZ,EAKiB;EALjB,CAMJI,IANI,EAAP,CAD2B,CAOhB;AACZ,CARD;;AAUA,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAACC,IAAD;EAAA,OACrB,IAAAC,cAAA,EAAQ,YAAM;IACZ,OAAOD,IAAI,IAAI,EAAf;EACD,CAFD,EAEG,CAACA,IAAD,CAFH,CADqB;AAAA,CAAvB;;AAKA,IAAME,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,OAAD,EAAUH,IAAV;EAAA,OACxB,IAAAC,cAAA,EAAQ,YAAM;IACZ,IAAIE,OAAO,IAAI,IAAf,EAAqB;MACnB,OAAOA,OAAP;IACD;;IAED,IAAMC,UAA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ASD,CA5BD;;eA8BeiB,U"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTableStyles.js","names":["getTablePropsHook","props","instance","nextProps","component","tableComponent","style","className","classes","getHeaderFooterPropsHook","column","variant","align","headerStyle","headerClassName","headerClasses","getRowPropsHook","hover","getCellPropsHook","cell","cellStyle","cellClassName","cellClasses","useTableStyles","hooks","getTableProps","push","getHeaderProps","getFooterProps","getRowProps","getCellProps","pluginName"],"sources":["../../../src/Table/hooks/useTableStyles.js"],"sourcesContent":["import clsx from \"clsx\";\n\n// props target: <table>\nexport const getTablePropsHook = (props, { instance }) => {\n const nextProps = { component: instance.tableComponent };\n\n if (instance.style != null) {\n nextProps.style = instance.style;\n }\n\n if (instance.className != null) {\n nextProps.className = instance.className;\n }\n\n if (instance.classes != null) {\n nextProps.classes = instance.classes;\n }\n\n return [props, nextProps];\n};\n\n// props target: <table><thead><tr><th>\nexport const getHeaderFooterPropsHook = (props, { column }) => {\n const nextProps = {\n variant: column.variant,\n align: column.align,\n };\n\n if (column.style != null || column.headerStyle != null) {\n nextProps.style = { ...props.style, ...column.style, ...column.headerStyle };\n }\n\n if (column.className != null || column.headerClassName != null) {\n nextProps.className = clsx(props.className, column.className, column.headerClassName);\n }\n\n if (column.classes != null || column.headerClasses) {\n nextProps.classes = { ...props.classes, ...column.classes, ...column.headerClasses };\n }\n\n return [props, nextProps];\n};\n\n// props target: <table><tbody><tr>\nexport const getRowPropsHook = (props) => {\n const nextProps = {\n hover: true,\n };\n\n return [props, nextProps];\n};\n\n// props target: <table><tbody><tr><td>\nexport const getCellPropsHook = (props, { cell }) => {\n const nextProps = {\n variant: cell.column.variant,\n align: cell.column.align,\n };\n\n if (cell.column.style != null || cell.column.cellStyle != null) {\n nextProps.style = { ...props.style, ...cell.column.style, ...cell.column.cellStyle };\n }\n\n if (cell.column.className != null || cell.column.cellClassName != null) {\n nextProps.className = clsx(props.className, cell.column.className, cell.column.cellClassName);\n }\n\n if (cell.column.classes != null || cell.column.cellClasses) {\n nextProps.classes = { ...props.classes, ...cell.column.classes, ...cell.column.cellClasses };\n }\n\n return [props, nextProps];\n};\n\nconst useTableStyles = (hooks) => {\n // props target: <table>\n hooks.getTableProps.push(getTablePropsHook);\n // props target: <table><thead><tr><th>\n hooks.getHeaderProps.push(getHeaderFooterPropsHook);\n // props target: <table><tfoot><tr><td>\n hooks.getFooterProps.push(getHeaderFooterPropsHook);\n // props target: <table><tbody><tr>\n hooks.getRowProps.push(getRowPropsHook);\n // props target: <table><tbody><tr><td>\n hooks.getCellProps.push(getCellPropsHook);\n};\n\nuseTableStyles.pluginName = \"useHvTableStyles\";\n\nexport default useTableStyles;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;AAEA;AACO,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,KAAD,QAAyB;EAAA,IAAfC,QAAe,QAAfA,QAAe;EACxD,IAAMC,SAAS,GAAG;IAAEC,SAAS,EAAEF,QAAQ,CAACG;EAAtB,CAAlB;;EAEA,IAAIH,QAAQ,CAACI,KAAT,IAAkB,IAAtB,EAA4B;IAC1BH,SAAS,CAACG,KAAV,GAAkBJ,QAAQ,CAACI,KAA3B;EACD;;EAED,IAAIJ,QAAQ,CAACK,SAAT,IAAsB,IAA1B,EAAgC;IAC9BJ,SAAS,CAACI,SAAV,GAAsBL,QAAQ,CAACK,SAA/B;EACD;;EAED,IAAIL,QAAQ,CAACM,OAAT,IAAoB,IAAxB,EAA8B;IAC5BL,SAAS,CAACK,OAAV,GAAoBN,QAAQ,CAACM,OAA7B;EACD;;EAED,OAAO,CAACP,KAAD,EAAQE,SAAR,CAAP;AACD,CAhBM,C,CAkBP;;;;;AACO,IAAMM,wBAAwB,GAAG,SAA3BA,wBAA2B,CAACR,KAAD,SAAuB;EAAA,IAAbS,MAAa,SAAbA,MAAa;EAC7D,IAAMP,SAAS,GAAG;IAChBQ,OAAO,EAAED,MAAM,CAACC,OADA;IAEhBC,KAAK,EAAEF,MAAM,CAACE;EAFE,CAAlB;;EAKA,IAAIF,MAAM,CAACJ,KAAP,IAAgB,IAAhB,IAAwBI,MAAM,CAACG,WAAP,IAAsB,IAAlD,EAAwD;IACtDV,SAAS,CAACG,KAAV,iDAAuBL,KAAK,CAACK,KAA7B,GAAuCI,MAAM,CAACJ,KAA9C,GAAwDI,MAAM,CAACG,WAA/D;EACD;;EAED,IAAIH,MAAM,CAACH,SAAP,IAAoB,IAApB,IAA4BG,MAAM,CAACI,eAAP,IAA0B,IAA1D,EAAgE;IAC9DX,SAAS,CAACI,SAAV,GAAsB,
|
|
1
|
+
{"version":3,"file":"useTableStyles.js","names":["getTablePropsHook","props","instance","nextProps","component","tableComponent","style","className","classes","getHeaderFooterPropsHook","column","variant","align","headerStyle","headerClassName","clsx","headerClasses","getRowPropsHook","hover","getCellPropsHook","cell","cellStyle","cellClassName","cellClasses","useTableStyles","hooks","getTableProps","push","getHeaderProps","getFooterProps","getRowProps","getCellProps","pluginName"],"sources":["../../../src/Table/hooks/useTableStyles.js"],"sourcesContent":["import clsx from \"clsx\";\n\n// props target: <table>\nexport const getTablePropsHook = (props, { instance }) => {\n const nextProps = { component: instance.tableComponent };\n\n if (instance.style != null) {\n nextProps.style = instance.style;\n }\n\n if (instance.className != null) {\n nextProps.className = instance.className;\n }\n\n if (instance.classes != null) {\n nextProps.classes = instance.classes;\n }\n\n return [props, nextProps];\n};\n\n// props target: <table><thead><tr><th>\nexport const getHeaderFooterPropsHook = (props, { column }) => {\n const nextProps = {\n variant: column.variant,\n align: column.align,\n };\n\n if (column.style != null || column.headerStyle != null) {\n nextProps.style = { ...props.style, ...column.style, ...column.headerStyle };\n }\n\n if (column.className != null || column.headerClassName != null) {\n nextProps.className = clsx(props.className, column.className, column.headerClassName);\n }\n\n if (column.classes != null || column.headerClasses) {\n nextProps.classes = { ...props.classes, ...column.classes, ...column.headerClasses };\n }\n\n return [props, nextProps];\n};\n\n// props target: <table><tbody><tr>\nexport const getRowPropsHook = (props) => {\n const nextProps = {\n hover: true,\n };\n\n return [props, nextProps];\n};\n\n// props target: <table><tbody><tr><td>\nexport const getCellPropsHook = (props, { cell }) => {\n const nextProps = {\n variant: cell.column.variant,\n align: cell.column.align,\n };\n\n if (cell.column.style != null || cell.column.cellStyle != null) {\n nextProps.style = { ...props.style, ...cell.column.style, ...cell.column.cellStyle };\n }\n\n if (cell.column.className != null || cell.column.cellClassName != null) {\n nextProps.className = clsx(props.className, cell.column.className, cell.column.cellClassName);\n }\n\n if (cell.column.classes != null || cell.column.cellClasses) {\n nextProps.classes = { ...props.classes, ...cell.column.classes, ...cell.column.cellClasses };\n }\n\n return [props, nextProps];\n};\n\nconst useTableStyles = (hooks) => {\n // props target: <table>\n hooks.getTableProps.push(getTablePropsHook);\n // props target: <table><thead><tr><th>\n hooks.getHeaderProps.push(getHeaderFooterPropsHook);\n // props target: <table><tfoot><tr><td>\n hooks.getFooterProps.push(getHeaderFooterPropsHook);\n // props target: <table><tbody><tr>\n hooks.getRowProps.push(getRowPropsHook);\n // props target: <table><tbody><tr><td>\n hooks.getCellProps.push(getCellPropsHook);\n};\n\nuseTableStyles.pluginName = \"useHvTableStyles\";\n\nexport default useTableStyles;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;AAEA;AACO,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,KAAD,QAAyB;EAAA,IAAfC,QAAe,QAAfA,QAAe;EACxD,IAAMC,SAAS,GAAG;IAAEC,SAAS,EAAEF,QAAQ,CAACG;EAAtB,CAAlB;;EAEA,IAAIH,QAAQ,CAACI,KAAT,IAAkB,IAAtB,EAA4B;IAC1BH,SAAS,CAACG,KAAV,GAAkBJ,QAAQ,CAACI,KAA3B;EACD;;EAED,IAAIJ,QAAQ,CAACK,SAAT,IAAsB,IAA1B,EAAgC;IAC9BJ,SAAS,CAACI,SAAV,GAAsBL,QAAQ,CAACK,SAA/B;EACD;;EAED,IAAIL,QAAQ,CAACM,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IAApB,CAAyB3B,iBAAzB,EAFgC,CAGhC;;EACAyB,KAAK,CAACG,cAAN,CAAqBD,IAArB,CAA0BlB,wBAA1B,EAJgC,CAKhC;;EACAgB,KAAK,CAACI,cAAN,CAAqBF,IAArB,CAA0BlB,wBAA1B,EANgC,CAOhC;;EACAgB,KAAK,CAACK,WAAN,CAAkBH,IAAlB,CAAuBV,eAAvB,EARgC,CAShC;;EACAQ,KAAK,CAACM,YAAN,CAAmBJ,IAAnB,CAAwBR,gBAAxB;AACD,CAXD;;AAaAK,cAAc,CAACQ,UAAf,GAA4B,kBAA5B;eAEeR,c"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateColumnCell.js","names":["HvDateColumnCell","date","dateFormat","formattedDate","format","undefined","propTypes","PropTypes","string"],"sources":["../../../../src/Table/renderers/DateColumnCell/DateColumnCell.js"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport PropTypes from \"prop-types\";\nimport dayjs from \"dayjs\";\nimport { HvOverflowTooltip } from \"@hitachivantara/uikit-react-core\";\n\nconst HvDateColumnCell = ({ date, dateFormat }) => {\n const formattedDate = useMemo(() => {\n if (date) return dayjs(date).format(dateFormat !== \"ISO8601\" ? dateFormat : undefined);\n return \"—\";\n }, [date, dateFormat]);\n\n return <HvOverflowTooltip data={formattedDate} />;\n};\n\nHvDateColumnCell.propTypes = {\n /**\n * Date to render.\n */\n date: PropTypes.string,\n /**\n * The date's text representation format.\n */\n dateFormat: PropTypes.string,\n};\n\nexport default HvDateColumnCell;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAmB,OAA0B;EAAA,IAAvBC,IAAuB,QAAvBA,IAAuB;EAAA,IAAjBC,UAAiB,QAAjBA,UAAiB;EACjD,IAAMC,aAAa,GAAG,
|
|
1
|
+
{"version":3,"file":"DateColumnCell.js","names":["HvDateColumnCell","date","dateFormat","formattedDate","useMemo","dayjs","format","undefined","propTypes","PropTypes","string"],"sources":["../../../../src/Table/renderers/DateColumnCell/DateColumnCell.js"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport PropTypes from \"prop-types\";\nimport dayjs from \"dayjs\";\nimport { HvOverflowTooltip } from \"@hitachivantara/uikit-react-core\";\n\nconst HvDateColumnCell = ({ date, dateFormat }) => {\n const formattedDate = useMemo(() => {\n if (date) return dayjs(date).format(dateFormat !== \"ISO8601\" ? dateFormat : undefined);\n return \"—\";\n }, [date, dateFormat]);\n\n return <HvOverflowTooltip data={formattedDate} />;\n};\n\nHvDateColumnCell.propTypes = {\n /**\n * Date to render.\n */\n date: PropTypes.string,\n /**\n * The date's text representation format.\n */\n dateFormat: PropTypes.string,\n};\n\nexport default HvDateColumnCell;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAmB,OAA0B;EAAA,IAAvBC,IAAuB,QAAvBA,IAAuB;EAAA,IAAjBC,UAAiB,QAAjBA,UAAiB;EACjD,IAAMC,aAAa,GAAG,IAAAC,cAAA,EAAQ,YAAM;IAClC,IAAIH,IAAJ,EAAU,OAAO,IAAAI,cAAA,EAAMJ,IAAN,EAAYK,MAAZ,CAAmBJ,UAAU,KAAK,SAAf,GAA2BA,UAA3B,GAAwCK,SAA3D,CAAP;IACV,OAAO,GAAP;EACD,CAHqB,EAGnB,CAACN,IAAD,EAAOC,UAAP,CAHmB,CAAtB;EAKA,oBAAO,6BAAC,iCAAD;IAAmB,IAAI,EAAEC;EAAzB,EAAP;AACD,CAPD;;AASA,wCAAAH,gBAAgB,CAACQ,SAAjB,GAA6B;EAC3B;AACF;AACA;EACEP,IAAI,EAAEQ,kBAAA,CAAUC,MAJW;;EAK3B;AACF;AACA;EACER,UAAU,EAAEO,kBAAA,CAAUC;AARK,CAA7B;eAWeV,gB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownColumnCell.js","names":["HvDropdownColumnCell","values","disabled","onChange","placeholder","dropdownProps","item","propTypes","PropTypes","arrayOf","shape","id","string","label","node","isRequired","searchValue","value","any","selected","bool","func","instanceOf","Object"],"sources":["../../../../src/Table/renderers/DropdownColumnCell/DropdownColumnCell.js"],"sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { HvDropdown } from \"@hitachivantara/uikit-react-core\";\n\nconst HvDropdownColumnCell = ({ values, disabled, onChange, placeholder, dropdownProps }) => {\n return (\n <HvDropdown\n onChange={(item) => {\n onChange?.(item);\n }}\n placeholder={placeholder}\n disabled={disabled}\n values={values}\n disablePortal\n {...dropdownProps}\n />\n );\n};\n\nHvDropdownColumnCell.propTypes = {\n /**\n * values to render in the dropdown.\n */\n values: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.string,\n label: PropTypes.node.isRequired,\n searchValue: PropTypes.string,\n value: PropTypes.any,\n selected: PropTypes.bool,\n })\n ),\n /**\n * The whether the dropdown is disabled.\n */\n disabled: PropTypes.bool,\n /**\n * Function called when there is change on the dropdown.\n */\n onChange: PropTypes.func,\n /**\n * Placeholder text for when the dropdown is empty.\n */\n placeholder: PropTypes.string,\n /**\n * Extra props to be passed onto the dropdown.\n */\n dropdownProps: PropTypes.instanceOf(Object),\n};\n\nexport default HvDropdownColumnCell;\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA,IAAMA,oBAAoB,GAAG,SAAvBA,oBAAuB,OAAgE;EAAA,IAA7DC,MAA6D,QAA7DA,MAA6D;EAAA,IAArDC,QAAqD,QAArDA,QAAqD;EAAA,IAA3CC,SAA2C,QAA3CA,QAA2C;EAAA,IAAjCC,WAAiC,QAAjCA,WAAiC;EAAA,IAApBC,aAAoB,QAApBA,aAAoB;EAC3F,oBACE,6BAAC,0BAAD;IACE,QAAQ,EAAE,kBAACC,IAAD,EAAU;MAClBH,SAAQ,SAAR,IAAAA,SAAQ,WAAR,YAAAA,SAAQ,CAAGG,IAAH,CAAR;IACD,CAHH;IAIE,WAAW,EAAEF,WAJf;IAKE,QAAQ,EAAEF,QALZ;IAME,MAAM,EAAED,MANV;IAOE,aAAa;EAPf,GAQMI,aARN,EADF;AAYD,CAbD;;AAeA,wCAAAL,oBAAoB,CAACO,SAArB,GAAiC;EAC/B;AACF;AACA;EACEN,MAAM,EAAEO,
|
|
1
|
+
{"version":3,"file":"DropdownColumnCell.js","names":["HvDropdownColumnCell","values","disabled","onChange","placeholder","dropdownProps","item","propTypes","PropTypes","arrayOf","shape","id","string","label","node","isRequired","searchValue","value","any","selected","bool","func","instanceOf","Object"],"sources":["../../../../src/Table/renderers/DropdownColumnCell/DropdownColumnCell.js"],"sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { HvDropdown } from \"@hitachivantara/uikit-react-core\";\n\nconst HvDropdownColumnCell = ({ values, disabled, onChange, placeholder, dropdownProps }) => {\n return (\n <HvDropdown\n onChange={(item) => {\n onChange?.(item);\n }}\n placeholder={placeholder}\n disabled={disabled}\n values={values}\n disablePortal\n {...dropdownProps}\n />\n );\n};\n\nHvDropdownColumnCell.propTypes = {\n /**\n * values to render in the dropdown.\n */\n values: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.string,\n label: PropTypes.node.isRequired,\n searchValue: PropTypes.string,\n value: PropTypes.any,\n selected: PropTypes.bool,\n })\n ),\n /**\n * The whether the dropdown is disabled.\n */\n disabled: PropTypes.bool,\n /**\n * Function called when there is change on the dropdown.\n */\n onChange: PropTypes.func,\n /**\n * Placeholder text for when the dropdown is empty.\n */\n placeholder: PropTypes.string,\n /**\n * Extra props to be passed onto the dropdown.\n */\n dropdownProps: PropTypes.instanceOf(Object),\n};\n\nexport default HvDropdownColumnCell;\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA,IAAMA,oBAAoB,GAAG,SAAvBA,oBAAuB,OAAgE;EAAA,IAA7DC,MAA6D,QAA7DA,MAA6D;EAAA,IAArDC,QAAqD,QAArDA,QAAqD;EAAA,IAA3CC,SAA2C,QAA3CA,QAA2C;EAAA,IAAjCC,WAAiC,QAAjCA,WAAiC;EAAA,IAApBC,aAAoB,QAApBA,aAAoB;EAC3F,oBACE,6BAAC,0BAAD;IACE,QAAQ,EAAE,kBAACC,IAAD,EAAU;MAClBH,SAAQ,SAAR,IAAAA,SAAQ,WAAR,YAAAA,SAAQ,CAAGG,IAAH,CAAR;IACD,CAHH;IAIE,WAAW,EAAEF,WAJf;IAKE,QAAQ,EAAEF,QALZ;IAME,MAAM,EAAED,MANV;IAOE,aAAa;EAPf,GAQMI,aARN,EADF;AAYD,CAbD;;AAeA,wCAAAL,oBAAoB,CAACO,SAArB,GAAiC;EAC/B;AACF;AACA;EACEN,MAAM,EAAEO,kBAAA,CAAUC,OAAV,CACND,kBAAA,CAAUE,KAAV,CAAgB;IACdC,EAAE,EAAEH,kBAAA,CAAUI,MADA;IAEdC,KAAK,EAAEL,kBAAA,CAAUM,IAAV,CAAeC,UAFR;IAGdC,WAAW,EAAER,kBAAA,CAAUI,MAHT;IAIdK,KAAK,EAAET,kBAAA,CAAUU,GAJH;IAKdC,QAAQ,EAAEX,kBAAA,CAAUY;EALN,CAAhB,CADM,CAJuB;;EAa/B;AACF;AACA;EACElB,QAAQ,EAAEM,kBAAA,CAAUY,IAhBW;;EAiB/B;AACF;AACA;EACEjB,QAAQ,EAAEK,kBAAA,CAAUa,IApBW;;EAqB/B;AACF;AACA;EACEjB,WAAW,EAAEI,kBAAA,CAAUI,MAxBQ;;EAyB/B;AACF;AACA;EACEP,aAAa,EAAEG,kBAAA,CAAUc,UAAV,CAAqBC,MAArB;AA5BgB,CAAjC;eA+BevB,oB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressColumnCell.js","names":["normalizeProgressBar","value","max","Math","floor","HvProgressColumnCell","partial","total","color","classes","percentage","root","linearProgressContainer","linearProgress","colorPrimary","linearProgressColorPrimary","barColorPrimary","linearProgressBarColorPrimary","barColorSecondary","linearProgressBarColorSecondary","propTypes","PropTypes","number","oneOf"],"sources":["../../../../src/Table/renderers/ProgressColumnCell/ProgressColumnCell.js"],"sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { LinearProgress } from \"@material-ui/core\";\n\nimport useStyles from \"./styles\";\n\nexport const normalizeProgressBar = (value, max) => {\n return max > 0 ? Math.floor((value * 100) / max) : 0;\n};\n\nconst HvProgressColumnCell = ({ partial, total, color = \"primary\" }) => {\n const classes = useStyles();\n const percentage = normalizeProgressBar(partial, total);\n\n return (\n <div className={classes.root}>\n <div className={classes.linearProgressContainer}>\n <LinearProgress\n className={classes.linearProgress}\n classes={{\n colorPrimary: classes.linearProgressColorPrimary,\n barColorPrimary: classes.linearProgressBarColorPrimary,\n barColorSecondary: classes.linearProgressBarColorSecondary,\n }}\n color={color}\n variant=\"determinate\"\n value={percentage}\n />\n </div>\n </div>\n );\n};\n\nHvProgressColumnCell.propTypes = {\n /**\n * Current value of the bar.\n */\n partial: PropTypes.number,\n /**\n * Maximum value of the bar.\n */\n total: PropTypes.number,\n /**\n * The color of the bar.\n */\n color: PropTypes.oneOf([\"primary\", \"secondary\"]),\n};\n\nexport default HvProgressColumnCell;\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAEO,IAAMA,oBAAoB,GAAG,SAAvBA,oBAAuB,CAACC,KAAD,EAAQC,GAAR,EAAgB;EAClD,OAAOA,GAAG,GAAG,CAAN,GAAUC,IAAI,CAACC,KAAL,CAAYH,KAAK,GAAG,GAAT,GAAgBC,GAA3B,CAAV,GAA4C,CAAnD;AACD,CAFM;;;;AAIP,IAAMG,oBAAoB,GAAG,SAAvBA,oBAAuB,OAA2C;EAAA,IAAxCC,OAAwC,QAAxCA,OAAwC;EAAA,IAA/BC,KAA+B,QAA/BA,KAA+B;EAAA,sBAAxBC,KAAwB;EAAA,IAAxBA,KAAwB,2BAAhB,SAAgB;EACtE,IAAMC,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"ProgressColumnCell.js","names":["normalizeProgressBar","value","max","Math","floor","HvProgressColumnCell","partial","total","color","classes","useStyles","percentage","root","linearProgressContainer","linearProgress","colorPrimary","linearProgressColorPrimary","barColorPrimary","linearProgressBarColorPrimary","barColorSecondary","linearProgressBarColorSecondary","propTypes","PropTypes","number","oneOf"],"sources":["../../../../src/Table/renderers/ProgressColumnCell/ProgressColumnCell.js"],"sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { LinearProgress } from \"@material-ui/core\";\n\nimport useStyles from \"./styles\";\n\nexport const normalizeProgressBar = (value, max) => {\n return max > 0 ? Math.floor((value * 100) / max) : 0;\n};\n\nconst HvProgressColumnCell = ({ partial, total, color = \"primary\" }) => {\n const classes = useStyles();\n const percentage = normalizeProgressBar(partial, total);\n\n return (\n <div className={classes.root}>\n <div className={classes.linearProgressContainer}>\n <LinearProgress\n className={classes.linearProgress}\n classes={{\n colorPrimary: classes.linearProgressColorPrimary,\n barColorPrimary: classes.linearProgressBarColorPrimary,\n barColorSecondary: classes.linearProgressBarColorSecondary,\n }}\n color={color}\n variant=\"determinate\"\n value={percentage}\n />\n </div>\n </div>\n );\n};\n\nHvProgressColumnCell.propTypes = {\n /**\n * Current value of the bar.\n */\n partial: PropTypes.number,\n /**\n * Maximum value of the bar.\n */\n total: PropTypes.number,\n /**\n * The color of the bar.\n */\n color: PropTypes.oneOf([\"primary\", \"secondary\"]),\n};\n\nexport default HvProgressColumnCell;\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAEO,IAAMA,oBAAoB,GAAG,SAAvBA,oBAAuB,CAACC,KAAD,EAAQC,GAAR,EAAgB;EAClD,OAAOA,GAAG,GAAG,CAAN,GAAUC,IAAI,CAACC,KAAL,CAAYH,KAAK,GAAG,GAAT,GAAgBC,GAA3B,CAAV,GAA4C,CAAnD;AACD,CAFM;;;;AAIP,IAAMG,oBAAoB,GAAG,SAAvBA,oBAAuB,OAA2C;EAAA,IAAxCC,OAAwC,QAAxCA,OAAwC;EAAA,IAA/BC,KAA+B,QAA/BA,KAA+B;EAAA,sBAAxBC,KAAwB;EAAA,IAAxBA,KAAwB,2BAAhB,SAAgB;EACtE,IAAMC,OAAO,GAAG,IAAAC,eAAA,GAAhB;EACA,IAAMC,UAAU,GAAGX,oBAAoB,CAACM,OAAD,EAAUC,KAAV,CAAvC;EAEA,oBACE;IAAK,SAAS,EAAEE,OAAO,CAACG;EAAxB,gBACE;IAAK,SAAS,EAAEH,OAAO,CAACI;EAAxB,gBACE,6BAAC,oBAAD;IACE,SAAS,EAAEJ,OAAO,CAACK,cADrB;IAEE,OAAO,EAAE;MACPC,YAAY,EAAEN,OAAO,CAACO,0BADf;MAEPC,eAAe,EAAER,OAAO,CAACS,6BAFlB;MAGPC,iBAAiB,EAAEV,OAAO,CAACW;IAHpB,CAFX;IAOE,KAAK,EAAEZ,KAPT;IAQE,OAAO,EAAC,aARV;IASE,KAAK,EAAEG;EATT,EADF,CADF,CADF;AAiBD,CArBD;;AAuBA,wCAAAN,oBAAoB,CAACgB,SAArB,GAAiC;EAC/B;AACF;AACA;EACEf,OAAO,EAAEgB,kBAAA,CAAUC,MAJY;;EAK/B;AACF;AACA;EACEhB,KAAK,EAAEe,kBAAA,CAAUC,MARc;;EAS/B;AACF;AACA;EACEf,KAAK,EAAEc,kBAAA,CAAUE,KAAV,CAAgB,CAAC,SAAD,EAAY,WAAZ,CAAhB;AAZwB,CAAjC;eAeenB,oB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","names":["useStyles","theme","root","display","width","linearProgressContainer","margin","linearProgress","height","linearProgressColorPrimary","backgroundColor","hv","palette","atmosphere","atmo4","linearProgressBarColorPrimary","semantic","sema1","linearProgressBarColorSecondary","accent","acce1"],"sources":["../../../../src/Table/renderers/ProgressColumnCell/styles.js"],"sourcesContent":["import { makeStyles } from \"@material-ui/core\";\n\nconst useStyles = makeStyles((theme) => ({\n root: {\n display: \"flex\",\n width: \"100%\",\n },\n linearProgressContainer: {\n width: \"100%\",\n margin: \"auto\",\n },\n linearProgress: {\n height: 8,\n },\n linearProgressColorPrimary: {\n backgroundColor: theme.hv.palette.atmosphere.atmo4,\n },\n linearProgressBarColorPrimary: {\n backgroundColor: theme.hv.palette.semantic.sema1,\n },\n linearProgressBarColorSecondary: {\n backgroundColor: theme.hv.palette.accent.acce1,\n },\n}));\n\nexport default useStyles;\n"],"mappings":";;;;;;;AAAA;;AAEA,IAAMA,SAAS,GAAG,
|
|
1
|
+
{"version":3,"file":"styles.js","names":["useStyles","makeStyles","theme","root","display","width","linearProgressContainer","margin","linearProgress","height","linearProgressColorPrimary","backgroundColor","hv","palette","atmosphere","atmo4","linearProgressBarColorPrimary","semantic","sema1","linearProgressBarColorSecondary","accent","acce1"],"sources":["../../../../src/Table/renderers/ProgressColumnCell/styles.js"],"sourcesContent":["import { makeStyles } from \"@material-ui/core\";\n\nconst useStyles = makeStyles((theme) => ({\n root: {\n display: \"flex\",\n width: \"100%\",\n },\n linearProgressContainer: {\n width: \"100%\",\n margin: \"auto\",\n },\n linearProgress: {\n height: 8,\n },\n linearProgressColorPrimary: {\n backgroundColor: theme.hv.palette.atmosphere.atmo4,\n },\n linearProgressBarColorPrimary: {\n backgroundColor: theme.hv.palette.semantic.sema1,\n },\n linearProgressBarColorSecondary: {\n backgroundColor: theme.hv.palette.accent.acce1,\n },\n}));\n\nexport default useStyles;\n"],"mappings":";;;;;;;AAAA;;AAEA,IAAMA,SAAS,GAAG,IAAAC,gBAAA,EAAW,UAACC,KAAD;EAAA,OAAY;IACvCC,IAAI,EAAE;MACJC,OAAO,EAAE,MADL;MAEJC,KAAK,EAAE;IAFH,CADiC;IAKvCC,uBAAuB,EAAE;MACvBD,KAAK,EAAE,MADgB;MAEvBE,MAAM,EAAE;IAFe,CALc;IASvCC,cAAc,EAAE;MACdC,MAAM,EAAE;IADM,CATuB;IAYvCC,0BAA0B,EAAE;MAC1BC,eAAe,EAAET,KAAK,CAACU,EAAN,CAASC,OAAT,CAAiBC,UAAjB,CAA4BC;IADnB,CAZW;IAevCC,6BAA6B,EAAE;MAC7BL,eAAe,EAAET,KAAK,CAACU,EAAN,CAASC,OAAT,CAAiBI,QAAjB,CAA0BC;IADd,CAfQ;IAkBvCC,+BAA+B,EAAE;MAC/BR,eAAe,EAAET,KAAK,CAACU,EAAN,CAASC,OAAT,CAAiBO,MAAjB,CAAwBC;IADV;EAlBM,CAAZ;AAAA,CAAX,CAAlB;eAuBerB,S"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwitchColumnCell.js","names":["HvSwitchColumnCell","checked","value","switchLabel","falseLabel","trueLabel","switchProps","classes","switchProperties","switchNo","switchYes","propTypes","PropTypes","bool","oneOfType","number","string","instanceOf","Object","color","oneOf"],"sources":["../../../../src/Table/renderers/SwitchColumnCell/SwitchColumnCell.js"],"sourcesContent":["import React from \"react\";\nimport clsx from \"clsx\";\nimport PropTypes from \"prop-types\";\n\nimport { HvBaseSwitch, HvTypography } from \"@hitachivantara/uikit-react-core\";\n\nimport useStyles from \"./styles\";\n\nconst HvSwitchColumnCell = ({\n checked,\n value,\n switchLabel,\n falseLabel,\n trueLabel,\n switchProps,\n}) => {\n const classes = useStyles();\n\n return (\n <>\n {falseLabel != null && (\n <HvTypography\n aria-hidden=\"true\"\n variant=\"normalText\"\n className={clsx(classes.switchProperties, classes.switchNo)}\n >\n {falseLabel}\n </HvTypography>\n )}\n <HvBaseSwitch aria-label={switchLabel} checked={checked} value={value} {...switchProps} />\n {trueLabel != null && (\n <HvTypography\n aria-hidden=\"true\"\n variant=\"normalText\"\n className={clsx(classes.switchProperties, classes.switchYes)}\n >\n {trueLabel}\n </HvTypography>\n )}\n </>\n );\n};\n\nHvSwitchColumnCell.propTypes = {\n /**\n * Whether the switch is checked or not.\n */\n checked: PropTypes.bool,\n /**\n * The value of the switch.\n */\n value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n /**\n * The switch label.\n */\n switchLabel: PropTypes.string,\n /**\n * The right switch label.\n */\n falseLabel: PropTypes.string,\n /**\n * The left switch label.\n */\n trueLabel: PropTypes.string,\n /**\n * Extra props to be passed to the switch.\n */\n switchProps: PropTypes.instanceOf(Object),\n /**\n * The timezone used to format the date.\n */\n color: PropTypes.oneOf([\"primary\", \"secondary\"]),\n};\n\nexport default HvSwitchColumnCell;\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAEA;;AAEA,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB,OAOrB;EAAA,IANJC,OAMI,QANJA,OAMI;EAAA,IALJC,KAKI,QALJA,KAKI;EAAA,IAJJC,WAII,QAJJA,WAII;EAAA,IAHJC,UAGI,QAHJA,UAGI;EAAA,IAFJC,SAEI,QAFJA,SAEI;EAAA,IADJC,WACI,QADJA,WACI;EACJ,IAAMC,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"SwitchColumnCell.js","names":["HvSwitchColumnCell","checked","value","switchLabel","falseLabel","trueLabel","switchProps","classes","useStyles","clsx","switchProperties","switchNo","switchYes","propTypes","PropTypes","bool","oneOfType","number","string","instanceOf","Object","color","oneOf"],"sources":["../../../../src/Table/renderers/SwitchColumnCell/SwitchColumnCell.js"],"sourcesContent":["import React from \"react\";\nimport clsx from \"clsx\";\nimport PropTypes from \"prop-types\";\n\nimport { HvBaseSwitch, HvTypography } from \"@hitachivantara/uikit-react-core\";\n\nimport useStyles from \"./styles\";\n\nconst HvSwitchColumnCell = ({\n checked,\n value,\n switchLabel,\n falseLabel,\n trueLabel,\n switchProps,\n}) => {\n const classes = useStyles();\n\n return (\n <>\n {falseLabel != null && (\n <HvTypography\n aria-hidden=\"true\"\n variant=\"normalText\"\n className={clsx(classes.switchProperties, classes.switchNo)}\n >\n {falseLabel}\n </HvTypography>\n )}\n <HvBaseSwitch aria-label={switchLabel} checked={checked} value={value} {...switchProps} />\n {trueLabel != null && (\n <HvTypography\n aria-hidden=\"true\"\n variant=\"normalText\"\n className={clsx(classes.switchProperties, classes.switchYes)}\n >\n {trueLabel}\n </HvTypography>\n )}\n </>\n );\n};\n\nHvSwitchColumnCell.propTypes = {\n /**\n * Whether the switch is checked or not.\n */\n checked: PropTypes.bool,\n /**\n * The value of the switch.\n */\n value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n /**\n * The switch label.\n */\n switchLabel: PropTypes.string,\n /**\n * The right switch label.\n */\n falseLabel: PropTypes.string,\n /**\n * The left switch label.\n */\n trueLabel: PropTypes.string,\n /**\n * Extra props to be passed to the switch.\n */\n switchProps: PropTypes.instanceOf(Object),\n /**\n * The timezone used to format the date.\n */\n color: PropTypes.oneOf([\"primary\", \"secondary\"]),\n};\n\nexport default HvSwitchColumnCell;\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAEA;;AAEA,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB,OAOrB;EAAA,IANJC,OAMI,QANJA,OAMI;EAAA,IALJC,KAKI,QALJA,KAKI;EAAA,IAJJC,WAII,QAJJA,WAII;EAAA,IAHJC,UAGI,QAHJA,UAGI;EAAA,IAFJC,SAEI,QAFJA,SAEI;EAAA,IADJC,WACI,QADJA,WACI;EACJ,IAAMC,OAAO,GAAG,IAAAC,eAAA,GAAhB;EAEA,oBACE,4DACGJ,UAAU,IAAI,IAAd,iBACC,6BAAC,4BAAD;IACE,eAAY,MADd;IAEE,OAAO,EAAC,YAFV;IAGE,SAAS,EAAE,IAAAK,aAAA,EAAKF,OAAO,CAACG,gBAAb,EAA+BH,OAAO,CAACI,QAAvC;EAHb,GAKGP,UALH,CAFJ,eAUE,6BAAC,4BAAD;IAAc,cAAYD,WAA1B;IAAuC,OAAO,EAAEF,OAAhD;IAAyD,KAAK,EAAEC;EAAhE,GAA2EI,WAA3E,EAVF,EAWGD,SAAS,IAAI,IAAb,iBACC,6BAAC,4BAAD;IACE,eAAY,MADd;IAEE,OAAO,EAAC,YAFV;IAGE,SAAS,EAAE,IAAAI,aAAA,EAAKF,OAAO,CAACG,gBAAb,EAA+BH,OAAO,CAACK,SAAvC;EAHb,GAKGP,SALH,CAZJ,CADF;AAuBD,CAjCD;;AAmCA,wCAAAL,kBAAkB,CAACa,SAAnB,GAA+B;EAC7B;AACF;AACA;EACEZ,OAAO,EAAEa,kBAAA,CAAUC,IAJU;;EAK7B;AACF;AACA;EACEb,KAAK,EAAEY,kBAAA,CAAUE,SAAV,CAAoB,CAACF,kBAAA,CAAUG,MAAX,EAAmBH,kBAAA,CAAUI,MAA7B,CAApB,CARsB;;EAS7B;AACF;AACA;EACEf,WAAW,EAAEW,kBAAA,CAAUI,MAZM;;EAa7B;AACF;AACA;EACEd,UAAU,EAAEU,kBAAA,CAAUI,MAhBO;;EAiB7B;AACF;AACA;EACEb,SAAS,EAAES,kBAAA,CAAUI,MApBQ;;EAqB7B;AACF;AACA;EACEZ,WAAW,EAAEQ,kBAAA,CAAUK,UAAV,CAAqBC,MAArB,CAxBgB;;EAyB7B;AACF;AACA;EACEC,KAAK,EAAEP,kBAAA,CAAUQ,KAAV,CAAgB,CAAC,SAAD,EAAY,WAAZ,CAAhB;AA5BsB,CAA/B;eA+BetB,kB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","names":["useStyles","switchProperties","cursor","display","switchYes","marginLeft","switchNo","marginRight"],"sources":["../../../../src/Table/renderers/SwitchColumnCell/styles.js"],"sourcesContent":["import { makeStyles } from \"@material-ui/core\";\n\nconst useStyles = makeStyles(() => ({\n switchProperties: {\n cursor: \"pointer\",\n display: \"inline-flex\",\n },\n switchYes: {\n marginLeft: \"10px\",\n },\n switchNo: {\n marginRight: \"10px\",\n },\n}));\n\nexport default useStyles;\n"],"mappings":";;;;;;;AAAA;;AAEA,IAAMA,SAAS,GAAG,
|
|
1
|
+
{"version":3,"file":"styles.js","names":["useStyles","makeStyles","switchProperties","cursor","display","switchYes","marginLeft","switchNo","marginRight"],"sources":["../../../../src/Table/renderers/SwitchColumnCell/styles.js"],"sourcesContent":["import { makeStyles } from \"@material-ui/core\";\n\nconst useStyles = makeStyles(() => ({\n switchProperties: {\n cursor: \"pointer\",\n display: \"inline-flex\",\n },\n switchYes: {\n marginLeft: \"10px\",\n },\n switchNo: {\n marginRight: \"10px\",\n },\n}));\n\nexport default useStyles;\n"],"mappings":";;;;;;;AAAA;;AAEA,IAAMA,SAAS,GAAG,IAAAC,gBAAA,EAAW;EAAA,OAAO;IAClCC,gBAAgB,EAAE;MAChBC,MAAM,EAAE,SADQ;MAEhBC,OAAO,EAAE;IAFO,CADgB;IAKlCC,SAAS,EAAE;MACTC,UAAU,EAAE;IADH,CALuB;IAQlCC,QAAQ,EAAE;MACRC,WAAW,EAAE;IADL;EARwB,CAAP;AAAA,CAAX,CAAlB;eAaeR,S"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderers.js","names":["hvTextColumn","col","Cell","cellProps","value","sortType","hvNumberColumn","align","hvDateColumn","dateFormat","sortDescFirst","hvExpandColumn","expandRowButtonAriaLabel","collapseRowButtonAriaLabel","getCanRowExpand","row","getToggleRowExpandedProps","onClick","hasContent","isExpanded","position","left","top","cellStyle","hvTagColumn","valueDataKey","colorDataKey","textColorDataKey","fromRowData","tagProps","original","name","color","textColor","paddingTop","paddingBottom","hvSwitchColumn","switchLabel","falseLabel","trueLabel","switchProps","id","hvDropdownColumn","placeholder","disabledPlaceholder","onChange","column","dsbld","length","val","hvProgressColumn","getPartial","getTotal","partial","total"],"sources":["../../../src/Table/renderers/renderers.js"],"sourcesContent":["import React from \"react\";\n\nimport {\n HvButton,\n HvTag,\n HvTypography,\n HvOverflowTooltip,\n setId,\n} from \"@hitachivantara/uikit-react-core\";\nimport { DropDownXS, DropRightXS } from \"@hitachivantara/uikit-react-icons\";\nimport DateColumnCell from \"./DateColumnCell\";\nimport SwitchColumnCell from \"./SwitchColumnCell\";\nimport ProgressColumnCell from \"./ProgressColumnCell\";\nimport DropdownColumnCell from \"./DropdownColumnCell\";\nimport { hvStringFallback, hvNumberFallback } from \"../utils\";\n\nexport const hvTextColumn = (col) => {\n return {\n Cell: (cellProps) => <HvOverflowTooltip data={hvStringFallback(cellProps?.value)} />,\n sortType: \"alphanumeric\",\n ...col,\n };\n};\n\nexport const hvNumberColumn = (col) => {\n return {\n Cell: ({ value }) => hvNumberFallback(value),\n align: \"right\",\n sortType: \"number\",\n ...col,\n };\n};\n\nexport const hvDateColumn = (col, dateFormat) => {\n return {\n Cell: (cellProps) => <DateColumnCell date={cellProps?.value} dateFormat={dateFormat} />,\n sortType: \"alphanumeric\",\n sortDescFirst: true,\n ...col,\n };\n};\n\nexport function hvExpandColumn(\n col,\n expandRowButtonAriaLabel,\n collapseRowButtonAriaLabel,\n getCanRowExpand\n) {\n return {\n Cell: (cellProps) => {\n const { value, row } = cellProps;\n const { onClick } = row.getToggleRowExpandedProps();\n\n const hasContent = getCanRowExpand?.(row) ?? true;\n\n return (\n <>\n {hasContent && (\n <HvButton\n icon\n category=\"ghost\"\n aria-label={row.isExpanded ? collapseRowButtonAriaLabel : expandRowButtonAriaLabel}\n aria-expanded={row.isExpanded}\n onClick={onClick}\n style={{ position: \"absolute\", left: 0, top: 0 }}\n >\n {row.isExpanded ? <DropDownXS /> : <DropRightXS />}\n </HvButton>\n )}\n\n <HvOverflowTooltip data={hvStringFallback(value)} />\n </>\n );\n },\n sortType: \"alphanumeric\",\n cellStyle: {\n position: \"relative\",\n },\n ...col,\n };\n}\n\nexport function hvTagColumn(\n col,\n valueDataKey,\n colorDataKey,\n textColorDataKey,\n fromRowData = false,\n tagProps\n) {\n return {\n Cell: (cellProps) => {\n const { value, row } = cellProps;\n if (!value) {\n return \"—\";\n }\n\n const {\n [valueDataKey]: name,\n [colorDataKey]: color,\n [textColorDataKey]: textColor,\n } = fromRowData ? row.original : value;\n\n return (\n <HvTag\n label={<HvTypography variant=\"normalText\">{name}</HvTypography>}\n type=\"semantic\"\n color={color}\n style={textColor != null ? { color: textColor } : {}}\n tabIndex={-1}\n {...tagProps}\n />\n );\n },\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n\nexport function hvSwitchColumn(col, switchLabel, falseLabel, trueLabel, switchProps) {\n return {\n Cell: (cellProps) => {\n const { value, row } = cellProps;\n return (\n <SwitchColumnCell\n checked={value}\n value={row.id}\n switchLabel={switchLabel}\n falseLabel={falseLabel}\n trueLabel={trueLabel}\n switchProps={switchProps}\n />\n );\n },\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n\nexport function hvDropdownColumn(col, id, placeholder, disabledPlaceholder, onChange) {\n return {\n Cell: (cellProps) => {\n const { value, row, column } = cellProps;\n const dsbld = value.length < 1;\n return (\n <DropdownColumnCell\n values={value}\n placeholder={dsbld ? disabledPlaceholder : placeholder}\n onChange={(val) => onChange?.(row.id, val)}\n disabled={dsbld}\n dropdownProps={{\n \"aria-labelledby\": setId(id, column.id),\n }}\n />\n );\n },\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n\nexport function hvProgressColumn(col, getPartial, getTotal, color) {\n return {\n Cell: (cellProps) => {\n const { row } = cellProps;\n const partial = getPartial?.(row);\n const total = getTotal?.(row);\n\n if (total) {\n return <ProgressColumnCell partial={partial} total={total} color={color} />;\n }\n\n return \"—\";\n },\n\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEO,IAAMA,YAAY,GAAG,SAAfA,YAAe,CAACC,GAAD,EAAS;EACnC;IACEC,IAAI,EAAE,cAACC,SAAD;MAAA,oBAAe,6BAAC,iCAAD;QAAmB,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"renderers.js","names":["hvTextColumn","col","Cell","cellProps","hvStringFallback","value","sortType","hvNumberColumn","hvNumberFallback","align","hvDateColumn","dateFormat","sortDescFirst","hvExpandColumn","expandRowButtonAriaLabel","collapseRowButtonAriaLabel","getCanRowExpand","row","getToggleRowExpandedProps","onClick","hasContent","isExpanded","position","left","top","cellStyle","hvTagColumn","valueDataKey","colorDataKey","textColorDataKey","fromRowData","tagProps","original","name","color","textColor","paddingTop","paddingBottom","hvSwitchColumn","switchLabel","falseLabel","trueLabel","switchProps","id","hvDropdownColumn","placeholder","disabledPlaceholder","onChange","column","dsbld","length","val","setId","hvProgressColumn","getPartial","getTotal","partial","total"],"sources":["../../../src/Table/renderers/renderers.js"],"sourcesContent":["import React from \"react\";\n\nimport {\n HvButton,\n HvTag,\n HvTypography,\n HvOverflowTooltip,\n setId,\n} from \"@hitachivantara/uikit-react-core\";\nimport { DropDownXS, DropRightXS } from \"@hitachivantara/uikit-react-icons\";\nimport DateColumnCell from \"./DateColumnCell\";\nimport SwitchColumnCell from \"./SwitchColumnCell\";\nimport ProgressColumnCell from \"./ProgressColumnCell\";\nimport DropdownColumnCell from \"./DropdownColumnCell\";\nimport { hvStringFallback, hvNumberFallback } from \"../utils\";\n\nexport const hvTextColumn = (col) => {\n return {\n Cell: (cellProps) => <HvOverflowTooltip data={hvStringFallback(cellProps?.value)} />,\n sortType: \"alphanumeric\",\n ...col,\n };\n};\n\nexport const hvNumberColumn = (col) => {\n return {\n Cell: ({ value }) => hvNumberFallback(value),\n align: \"right\",\n sortType: \"number\",\n ...col,\n };\n};\n\nexport const hvDateColumn = (col, dateFormat) => {\n return {\n Cell: (cellProps) => <DateColumnCell date={cellProps?.value} dateFormat={dateFormat} />,\n sortType: \"alphanumeric\",\n sortDescFirst: true,\n ...col,\n };\n};\n\nexport function hvExpandColumn(\n col,\n expandRowButtonAriaLabel,\n collapseRowButtonAriaLabel,\n getCanRowExpand\n) {\n return {\n Cell: (cellProps) => {\n const { value, row } = cellProps;\n const { onClick } = row.getToggleRowExpandedProps();\n\n const hasContent = getCanRowExpand?.(row) ?? true;\n\n return (\n <>\n {hasContent && (\n <HvButton\n icon\n category=\"ghost\"\n aria-label={row.isExpanded ? collapseRowButtonAriaLabel : expandRowButtonAriaLabel}\n aria-expanded={row.isExpanded}\n onClick={onClick}\n style={{ position: \"absolute\", left: 0, top: 0 }}\n >\n {row.isExpanded ? <DropDownXS /> : <DropRightXS />}\n </HvButton>\n )}\n\n <HvOverflowTooltip data={hvStringFallback(value)} />\n </>\n );\n },\n sortType: \"alphanumeric\",\n cellStyle: {\n position: \"relative\",\n },\n ...col,\n };\n}\n\nexport function hvTagColumn(\n col,\n valueDataKey,\n colorDataKey,\n textColorDataKey,\n fromRowData = false,\n tagProps\n) {\n return {\n Cell: (cellProps) => {\n const { value, row } = cellProps;\n if (!value) {\n return \"—\";\n }\n\n const {\n [valueDataKey]: name,\n [colorDataKey]: color,\n [textColorDataKey]: textColor,\n } = fromRowData ? row.original : value;\n\n return (\n <HvTag\n label={<HvTypography variant=\"normalText\">{name}</HvTypography>}\n type=\"semantic\"\n color={color}\n style={textColor != null ? { color: textColor } : {}}\n tabIndex={-1}\n {...tagProps}\n />\n );\n },\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n\nexport function hvSwitchColumn(col, switchLabel, falseLabel, trueLabel, switchProps) {\n return {\n Cell: (cellProps) => {\n const { value, row } = cellProps;\n return (\n <SwitchColumnCell\n checked={value}\n value={row.id}\n switchLabel={switchLabel}\n falseLabel={falseLabel}\n trueLabel={trueLabel}\n switchProps={switchProps}\n />\n );\n },\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n\nexport function hvDropdownColumn(col, id, placeholder, disabledPlaceholder, onChange) {\n return {\n Cell: (cellProps) => {\n const { value, row, column } = cellProps;\n const dsbld = value.length < 1;\n return (\n <DropdownColumnCell\n values={value}\n placeholder={dsbld ? disabledPlaceholder : placeholder}\n onChange={(val) => onChange?.(row.id, val)}\n disabled={dsbld}\n dropdownProps={{\n \"aria-labelledby\": setId(id, column.id),\n }}\n />\n );\n },\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n\nexport function hvProgressColumn(col, getPartial, getTotal, color) {\n return {\n Cell: (cellProps) => {\n const { row } = cellProps;\n const partial = getPartial?.(row);\n const total = getTotal?.(row);\n\n if (total) {\n return <ProgressColumnCell partial={partial} total={total} color={color} />;\n }\n\n return \"—\";\n },\n\n cellStyle: {\n paddingTop: 0,\n paddingBottom: 0,\n },\n ...col,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEO,IAAMA,YAAY,GAAG,SAAfA,YAAe,CAACC,GAAD,EAAS;EACnC;IACEC,IAAI,EAAE,cAACC,SAAD;MAAA,oBAAe,6BAAC,iCAAD;QAAmB,IAAI,EAAE,IAAAC,uBAAA,EAAiBD,SAAjB,aAAiBA,SAAjB,uBAAiBA,SAAS,CAAEE,KAA5B;MAAzB,EAAf;IAAA,CADR;IAEEC,QAAQ,EAAE;EAFZ,GAGKL,GAHL;AAKD,CANM;;;;AAQA,IAAMM,cAAc,GAAG,SAAjBA,cAAiB,CAACN,GAAD,EAAS;EACrC;IACEC,IAAI,EAAE;MAAA,IAAGG,KAAH,QAAGA,KAAH;MAAA,OAAe,IAAAG,uBAAA,EAAiBH,KAAjB,CAAf;IAAA,CADR;IAEEI,KAAK,EAAE,OAFT;IAGEH,QAAQ,EAAE;EAHZ,GAIKL,GAJL;AAMD,CAPM;;;;AASA,IAAMS,YAAY,GAAG,SAAfA,YAAe,CAACT,GAAD,EAAMU,UAAN,EAAqB;EAC/C;IACET,IAAI,EAAE,cAACC,SAAD;MAAA,oBAAe,6BAAC,uBAAD;QAAgB,IAAI,EAAEA,SAAF,aAAEA,SAAF,uBAAEA,SAAS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rC,GAAH,CAA1B;MACA,IAAMwC,KAAK,GAAGF,QAAH,aAAGA,QAAH,uBAAGA,QAAQ,CAAGtC,GAAH,CAAtB;;MAEA,IAAIwC,KAAJ,EAAW;QACT,oBAAO,6BAAC,2BAAD;UAAoB,OAAO,EAAED,OAA7B;UAAsC,KAAK,EAAEC,KAA7C;UAAoD,KAAK,EAAEvB;QAA3D,EAAP;MACD;;MAED,OAAO,GAAP;IACD,CAXH;IAaET,SAAS,EAAE;MACTW,UAAU,EAAE,CADH;MAETC,aAAa,EAAE;IAFN;EAbb,GAiBKpC,GAjBL;AAmBD"}
|
package/dist/Tag/Tag.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.js","names":["useStyles","styles","name","getColor","theme","color","defaultColor","palette","HvTag","props","id","semantic","children","disabled","variant","shape","showcancelicon","others","classes","isDisabled","Tagshape","square","inlineStyle","backgroundColor","hv","accent","acce1","root","label","deleteIcon","propTypes","PropTypes","string","round","focusVisible","oneOf","oneOfType","arrayOf","node","isRequired","bool"],"sources":["../../src/Tag/Tag.js"],"sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\n\nimport { Close } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useDeprecated } from \"@hitachivantara/uikit-react-core\";\n\nimport clsx from \"clsx\";\nimport { withStyles, makeStyles, useTheme } from \"@material-ui/core\";\nimport styles from \"./styles\";\n\n/**\n * The tag is a component used to notify the user about the labelled ,categorised, or organised item , in the app context.\n */\nconst useStyles = makeStyles(styles, { name: \"HvTag\" });\n\nconst getColor = (theme, color, defaultColor) => theme.palette[color] || color || defaultColor;\nexport const HvTag = (props) => {\n const {\n id,\n semantic,\n children,\n disabled,\n variant,\n color,\n shape,\n showcancelicon = false,\n ...others\n } = props;\n\n useDeprecated(\"Tag\", \"Please use the Tag component in Core\");\n const classes = useStyles();\n const isDisabled = disabled || false;\n const Tagshape = shape || classes.square;\n const theme = useTheme();\n const inlineStyle = {};\n\n if (semantic) {\n inlineStyle.backgroundColor = getColor(\n theme,\n theme.palette?.[semantic],\n theme.hv.palette.accent.acce1\n );\n }\n\n /**\n * Renders the content for the tag elements.\n */\n return (\n <div\n id={id}\n role=\"button\"\n className={clsx(\n classes.root,\n classes[variant],\n { ...others },\n {\n [classes.disabled]: isDisabled,\n [classes[`${shape}`]]: Tagshape,\n }\n )}\n style={inlineStyle}\n disabled={isDisabled}\n {...others}\n >\n <span className={classes.label}>{children}</span>\n {showcancelicon && (\n <Close\n className={clsx(classes.deleteIcon, {\n [classes.disabled]: isDisabled,\n })}\n color=\"atmo5\"\n />\n )}\n </div>\n );\n};\n\nHvTag.propTypes = {\n /**\n * Id to be applied to the root node.\n */\n id: PropTypes.string,\n /**\n * A Jss Object used to override or extend the styles applied to the tag.\n */\n classes: PropTypes.shape({\n /**\n * Styles applied to the component root class.\n */\n root: PropTypes.string,\n /**\n * Styles applied to the component label.\n */\n label: PropTypes.string,\n /**\n * Styles applied to the component when it is tag.\n */\n square: PropTypes.string,\n /**\n * Styles applied to the component when it is chip.\n */\n round: PropTypes.string,\n\n /**\n * Styles applied to the component when shows label.\n */\n deleteIcon: PropTypes.string,\n /**\n * Styles applied to the component when disabled.\n */\n disabled: PropTypes.string,\n /**\n * Styles applied to the button if keyboard focused.\n */\n focusVisible: PropTypes.string,\n }),\n /**\n * A String representing the background color of the tag.\n * You can use either an HEX or color name from the palette.\n */\n backgroundColor: PropTypes.string,\n /**\n * Category of tag to use\n */\n variant: PropTypes.oneOf([\"informational\", \"success\", \"warning\", \"error\", \"categorical\"]),\n /**\n * A String or Array of strings representing the colors to override in the icon.\n * Each element inside the array will override a diferent color.\n * You can use either an HEX or color name from the palette.\n */\n color: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),\n /**\n * Sets one of the standard semantic palette colors of the icon\n */\n semantic: PropTypes.oneOf([\n \"sema1\",\n \"sema2\",\n \"sema3\",\n \"sema4\",\n \"sema5\",\n \"sema6\",\n \"sema7\",\n \"sema8\",\n \"sema9\",\n \"sema10\",\n \"sema11\",\n \"sema12\",\n \"sema13\",\n \"sema14\",\n \"sema15\",\n \"sema16\",\n \"sema17\",\n \"sema18\",\n \"sema19\",\n \"sema20\",\n ]),\n shape: PropTypes.string,\n /**\n * The content of the Tag.\n */\n children: PropTypes.node.isRequired,\n /**\n * The disabled property of the Tag.\n */\n disabled: PropTypes.string,\n /**\n * The cancel icon is shown based on this property\n */\n showcancelicon: PropTypes.bool,\n};\n\nexport default withStyles(styles, { name: \"HvTag\" })(HvTag);\n"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AAEA;;AAEA;;AACA;;AACA;;;;AAEA;AACA;AACA;AACA,IAAMA,SAAS,GAAG,
|
|
1
|
+
{"version":3,"file":"Tag.js","names":["useStyles","makeStyles","styles","name","getColor","theme","color","defaultColor","palette","HvTag","props","id","semantic","children","disabled","variant","shape","showcancelicon","others","useDeprecated","classes","isDisabled","Tagshape","square","useTheme","inlineStyle","backgroundColor","hv","accent","acce1","clsx","root","label","deleteIcon","propTypes","PropTypes","string","round","focusVisible","oneOf","oneOfType","arrayOf","node","isRequired","bool","withStyles"],"sources":["../../src/Tag/Tag.js"],"sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\n\nimport { Close } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useDeprecated } from \"@hitachivantara/uikit-react-core\";\n\nimport clsx from \"clsx\";\nimport { withStyles, makeStyles, useTheme } from \"@material-ui/core\";\nimport styles from \"./styles\";\n\n/**\n * The tag is a component used to notify the user about the labelled ,categorised, or organised item , in the app context.\n */\nconst useStyles = makeStyles(styles, { name: \"HvTag\" });\n\nconst getColor = (theme, color, defaultColor) => theme.palette[color] || color || defaultColor;\nexport const HvTag = (props) => {\n const {\n id,\n semantic,\n children,\n disabled,\n variant,\n color,\n shape,\n showcancelicon = false,\n ...others\n } = props;\n\n useDeprecated(\"Tag\", \"Please use the Tag component in Core\");\n const classes = useStyles();\n const isDisabled = disabled || false;\n const Tagshape = shape || classes.square;\n const theme = useTheme();\n const inlineStyle = {};\n\n if (semantic) {\n inlineStyle.backgroundColor = getColor(\n theme,\n theme.palette?.[semantic],\n theme.hv.palette.accent.acce1\n );\n }\n\n /**\n * Renders the content for the tag elements.\n */\n return (\n <div\n id={id}\n role=\"button\"\n className={clsx(\n classes.root,\n classes[variant],\n { ...others },\n {\n [classes.disabled]: isDisabled,\n [classes[`${shape}`]]: Tagshape,\n }\n )}\n style={inlineStyle}\n disabled={isDisabled}\n {...others}\n >\n <span className={classes.label}>{children}</span>\n {showcancelicon && (\n <Close\n className={clsx(classes.deleteIcon, {\n [classes.disabled]: isDisabled,\n })}\n color=\"atmo5\"\n />\n )}\n </div>\n );\n};\n\nHvTag.propTypes = {\n /**\n * Id to be applied to the root node.\n */\n id: PropTypes.string,\n /**\n * A Jss Object used to override or extend the styles applied to the tag.\n */\n classes: PropTypes.shape({\n /**\n * Styles applied to the component root class.\n */\n root: PropTypes.string,\n /**\n * Styles applied to the component label.\n */\n label: PropTypes.string,\n /**\n * Styles applied to the component when it is tag.\n */\n square: PropTypes.string,\n /**\n * Styles applied to the component when it is chip.\n */\n round: PropTypes.string,\n\n /**\n * Styles applied to the component when shows label.\n */\n deleteIcon: PropTypes.string,\n /**\n * Styles applied to the component when disabled.\n */\n disabled: PropTypes.string,\n /**\n * Styles applied to the button if keyboard focused.\n */\n focusVisible: PropTypes.string,\n }),\n /**\n * A String representing the background color of the tag.\n * You can use either an HEX or color name from the palette.\n */\n backgroundColor: PropTypes.string,\n /**\n * Category of tag to use\n */\n variant: PropTypes.oneOf([\"informational\", \"success\", \"warning\", \"error\", \"categorical\"]),\n /**\n * A String or Array of strings representing the colors to override in the icon.\n * Each element inside the array will override a diferent color.\n * You can use either an HEX or color name from the palette.\n */\n color: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),\n /**\n * Sets one of the standard semantic palette colors of the icon\n */\n semantic: PropTypes.oneOf([\n \"sema1\",\n \"sema2\",\n \"sema3\",\n \"sema4\",\n \"sema5\",\n \"sema6\",\n \"sema7\",\n \"sema8\",\n \"sema9\",\n \"sema10\",\n \"sema11\",\n \"sema12\",\n \"sema13\",\n \"sema14\",\n \"sema15\",\n \"sema16\",\n \"sema17\",\n \"sema18\",\n \"sema19\",\n \"sema20\",\n ]),\n shape: PropTypes.string,\n /**\n * The content of the Tag.\n */\n children: PropTypes.node.isRequired,\n /**\n * The disabled property of the Tag.\n */\n disabled: PropTypes.string,\n /**\n * The cancel icon is shown based on this property\n */\n showcancelicon: PropTypes.bool,\n};\n\nexport default withStyles(styles, { name: \"HvTag\" })(HvTag);\n"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AAEA;;AAEA;;AACA;;AACA;;;;AAEA;AACA;AACA;AACA,IAAMA,SAAS,GAAG,IAAAC,gBAAA,EAAWC,eAAX,EAAmB;EAAEC,IAAI,EAAE;AAAR,CAAnB,CAAlB;;AAEA,IAAMC,QAAQ,GAAG,SAAXA,QAAW,CAACC,KAAD,EAAQC,KAAR,EAAeC,YAAf;EAAA,OAAgCF,KAAK,CAACG,OAAN,CAAcF,KAAd,KAAwBA,KAAxB,IAAiCC,YAAjE;AAAA,CAAjB;;AACO,IAAME,KAAK,GAAG,SAARA,KAAQ,CAACC,KAAD,EAAW;EAC9B,IACEC,EADF,GAUID,KAVJ,CACEC,EADF;EAAA,IAEEC,QAFF,GAUIF,KAVJ,CAEEE,QAFF;EAAA,IAGEC,QAHF,GAUIH,KAVJ,CAGEG,QAHF;EAAA,IAIEC,QAJF,GAUIJ,KAVJ,CAIEI,QAJF;EAAA,IAKEC,OALF,GAUIL,KAVJ,CAKEK,OALF;EAAA,IAMET,KANF,GAUII,KAVJ,CAMEJ,KANF;EAAA,IAOEU,KAPF,GAUIN,KAVJ,CAOEM,KAPF;EAAA,4BAUIN,KAVJ,CAQEO,cARF;EAAA,IAQEA,cARF,sCAQmB,KARnB;EAAA,IASKC,MATL,0C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DM;EA+EhBvB,KAAK,EAAEmB,kBAAA,CAAUC,MA/ED;;EAgFhB;AACF;AACA;EACEvB,QAAQ,EAAEsB,kBAAA,CAAUO,IAAV,CAAeC,UAnFT;;EAoFhB;AACF;AACA;EACE7B,QAAQ,EAAEqB,kBAAA,CAAUC,MAvFJ;;EAwFhB;AACF;AACA;EACEnB,cAAc,EAAEkB,kBAAA,CAAUS;AA3FV,CAAlB;;eA8Fe,IAAAC,gBAAA,EAAW3C,eAAX,EAAmB;EAAEC,IAAI,EAAE;AAAR,CAAnB,EAAsCM,KAAtC,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeAgo.js","names":["HvTimeAgo","classes","timestamp","localeProp","locale","component","Component","HvTypography","emptyElement","disableRefresh","showSeconds","justText","others","contextLocale","timeAgo","root","propTypes","PropTypes","shape","string","number","elementType","node","bool","styles","name"],"sources":["../../src/TimeAgo/TimeAgo.js"],"sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { withStyles } from \"@material-ui/core\";\nimport { HvTypography, useLocale } from \"@hitachivantara/uikit-react-core\";\nimport useTimeAgo from \"./useTimeAgo\";\nimport styles from \"./styles\";\n\n/**\n * The HvTimeAgo component implements the Design System relative time format guidelines.\n */\nconst HvTimeAgo = ({\n classes,\n timestamp,\n locale: localeProp,\n component: Component = HvTypography,\n emptyElement = \"—\",\n disableRefresh = false,\n showSeconds = false,\n justText = false,\n ...others\n}) => {\n const contextLocale = useLocale();\n const locale = localeProp || contextLocale;\n const timeAgo = useTimeAgo(timestamp, { locale, disableRefresh, showSeconds });\n\n if (justText && timestamp) return timeAgo;\n\n return (\n <Component className={classes.root} {...others}>\n {!timestamp ? emptyElement : timeAgo}\n </Component>\n );\n};\n\nHvTimeAgo.propTypes = {\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes: PropTypes.shape({\n /**\n * Styles applied to the component root class.\n */\n root: PropTypes.string,\n }),\n /**\n * The timestamp to format, in seconds\n */\n timestamp: PropTypes.number,\n /**\n * The locale to be used. Should be on of the dayjs supported locales\n * @see https://day.js.org/docs/en/i18n/i18n\n */\n locale: PropTypes.string,\n /**\n * The component used for the root node. Either a string to use a HTML element or a component.\n * Defaults to `div`.\n */\n component: PropTypes.elementType,\n /**\n * The element to render when the timestamp is null or 0\n * Defaults to `—` (Em Dash)\n */\n emptyElement: PropTypes.node,\n /**\n * Disables periodic date refreshes\n */\n disableRefresh: PropTypes.bool,\n /**\n * Whether to show seconds in the rendered time\n */\n showSeconds: PropTypes.bool,\n /**\n * Whether the component should render just the string\n * Consider using `useTimeAgo` instead\n */\n justText: PropTypes.bool,\n};\n\nexport default withStyles(styles, { name: \"HvTimeAgo\" })(HvTimeAgo);\n"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEA;AACA;AACA;AACA,IAAMA,SAAS,GAAG,SAAZA,SAAY,OAUZ;EAAA,IATJC,OASI,QATJA,OASI;EAAA,IARJC,SAQI,QARJA,SAQI;EAAA,IAPIC,UAOJ,QAPJC,MAOI;EAAA,0BANJC,SAMI;EAAA,IANOC,SAMP,+BANmBC,4BAMnB;EAAA,6BALJC,YAKI;EAAA,IALJA,YAKI,kCALW,GAKX;EAAA,+BAJJC,cAII;EAAA,IAJJA,cAII,oCAJa,KAIb;EAAA,4BAHJC,WAGI;EAAA,IAHJA,WAGI,iCAHU,KAGV;EAAA,yBAFJC,QAEI;EAAA,IAFJA,QAEI,8BAFO,KAEP;EAAA,IADDC,MACC;EACJ,IAAMC,aAAa,GAAG,
|
|
1
|
+
{"version":3,"file":"TimeAgo.js","names":["HvTimeAgo","classes","timestamp","localeProp","locale","component","Component","HvTypography","emptyElement","disableRefresh","showSeconds","justText","others","contextLocale","useLocale","timeAgo","useTimeAgo","root","propTypes","PropTypes","shape","string","number","elementType","node","bool","withStyles","styles","name"],"sources":["../../src/TimeAgo/TimeAgo.js"],"sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { withStyles } from \"@material-ui/core\";\nimport { HvTypography, useLocale } from \"@hitachivantara/uikit-react-core\";\nimport useTimeAgo from \"./useTimeAgo\";\nimport styles from \"./styles\";\n\n/**\n * The HvTimeAgo component implements the Design System relative time format guidelines.\n */\nconst HvTimeAgo = ({\n classes,\n timestamp,\n locale: localeProp,\n component: Component = HvTypography,\n emptyElement = \"—\",\n disableRefresh = false,\n showSeconds = false,\n justText = false,\n ...others\n}) => {\n const contextLocale = useLocale();\n const locale = localeProp || contextLocale;\n const timeAgo = useTimeAgo(timestamp, { locale, disableRefresh, showSeconds });\n\n if (justText && timestamp) return timeAgo;\n\n return (\n <Component className={classes.root} {...others}>\n {!timestamp ? emptyElement : timeAgo}\n </Component>\n );\n};\n\nHvTimeAgo.propTypes = {\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes: PropTypes.shape({\n /**\n * Styles applied to the component root class.\n */\n root: PropTypes.string,\n }),\n /**\n * The timestamp to format, in seconds\n */\n timestamp: PropTypes.number,\n /**\n * The locale to be used. Should be on of the dayjs supported locales\n * @see https://day.js.org/docs/en/i18n/i18n\n */\n locale: PropTypes.string,\n /**\n * The component used for the root node. Either a string to use a HTML element or a component.\n * Defaults to `div`.\n */\n component: PropTypes.elementType,\n /**\n * The element to render when the timestamp is null or 0\n * Defaults to `—` (Em Dash)\n */\n emptyElement: PropTypes.node,\n /**\n * Disables periodic date refreshes\n */\n disableRefresh: PropTypes.bool,\n /**\n * Whether to show seconds in the rendered time\n */\n showSeconds: PropTypes.bool,\n /**\n * Whether the component should render just the string\n * Consider using `useTimeAgo` instead\n */\n justText: PropTypes.bool,\n};\n\nexport default withStyles(styles, { name: \"HvTimeAgo\" })(HvTimeAgo);\n"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEA;AACA;AACA;AACA,IAAMA,SAAS,GAAG,SAAZA,SAAY,OAUZ;EAAA,IATJC,OASI,QATJA,OASI;EAAA,IARJC,SAQ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AAc,EAAEU,kBAAA,CAAUM,IAhCN;;EAiCpB;AACF;AACA;EACEf,WAAW,EAAES,kBAAA,CAAUM,IApCH;;EAqCpB;AACF;AACA;AACA;EACEd,QAAQ,EAAEQ,kBAAA,CAAUM;AAzCA,CAAtB;;eA4Ce,IAAAC,gBAAA,EAAWC,eAAX,EAAmB;EAAEC,IAAI,EAAE;AAAR,CAAnB,EAA0C5B,SAA1C,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatUtils.js","names":["thresholds","l","r","d","dayjs","extend","localeData","duration","calendar","localizedFormat","relativeTime","updateLocale","secondsUntilNextDay","date","Date","midnight","getTime","setDate","getDate","setHours","setMinutes","setSeconds","setMilliseconds","secondsUntilNextWeek","firstMonthDayOfWeek","getDay","firstMonthDayOfNextWeek","firstDayNextWeek","formatTimeAgo","locale","showSeconds","referenceDate","dayReferenceDate","dayDate","dayDiffSeconds","diff","formatUseSeconds","timeAgo","format","delay","humanize","dayDiffMinutes","isSame","subtract"],"sources":["../../src/TimeAgo/formatUtils.js"],"sourcesContent":["import dayjs from \"dayjs\";\nimport calendar from \"dayjs/plugin/calendar\";\nimport duration from \"dayjs/plugin/duration\";\nimport localeData from \"dayjs/plugin/localeData\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat\";\nimport relativeTime from \"dayjs/plugin/relativeTime\";\nimport updateLocale from \"dayjs/plugin/updateLocale\";\n\n/**\n * Relative time thresholds defined by\n * {@link https://xd.adobe.com/view/1b7df235-5cf8-4b51-a2f0-0be1bb591c55-4e2e/ Design System}\n *\n * Implementation using day.js {@link https://day.js.org/docs/en/customization/relative-time relativeTime}\n */\nconst thresholds = [\n { l: \"s\", r: 119, d: \"second\" },\n { l: \"m\", r: 1 },\n { l: \"mm\", r: 59, d: \"minute\" },\n { l: \"h\", r: 1 },\n { l: \"hh\", r: 23, d: \"hour\" },\n { l: \"d\", r: 1 },\n { l: \"dd\", r: 29, d: \"day\" },\n { l: \"M\", r: 1 },\n { l: \"MM\", r: 11, d: \"month\" },\n { l: \"y\", r: 17 },\n { l: \"yy\", d: \"year\" },\n];\n\ndayjs.extend(localeData);\ndayjs.extend(duration);\ndayjs.extend(calendar);\ndayjs.extend(localizedFormat);\ndayjs.extend(relativeTime, { thresholds });\ndayjs.extend(updateLocale);\n\nexport const secondsUntilNextDay = (date = new Date()) => {\n const midnight = new Date(date.getTime());\n\n midnight.setDate(midnight.getDate() + 1);\n midnight.setHours(0);\n midnight.setMinutes(0);\n midnight.setSeconds(0);\n midnight.setMilliseconds(0);\n\n return (midnight.getTime() - date.getTime()) / 1000;\n};\n\nconst secondsUntilNextWeek = (date = new Date()) => {\n const firstMonthDayOfWeek = date.getDate() - date.getDay();\n const firstMonthDayOfNextWeek = firstMonthDayOfWeek + 7; // auto roll over to next month if needed\n\n const firstDayNextWeek = new Date(date.getTime());\n\n firstDayNextWeek.setDate(firstMonthDayOfNextWeek);\n firstDayNextWeek.setHours(0);\n firstDayNextWeek.setMinutes(0);\n firstDayNextWeek.setSeconds(0);\n firstDayNextWeek.setMilliseconds(0);\n\n return (firstDayNextWeek.getTime() - date.getTime()) / 1000;\n};\n\n/**\n * @typedef {Object} TimeAgo\n * @property {string} timeAgo - the formatted date using the \"time ago format\"\n * @property {number} delay - the time until the date needs to be updated\n */\n\n/**\n * Formats a date to the a relative time format using dayjs.\n *\n * @param {Date} date - date to format.\n * @param {String} locale - locale to use.\n * @param {Boolean} [showSeconds=false] - if seconds should be part of the result.\n * @param {Date} referenceDate - reference date to use when formatting (defaults to current date).\n *\n * @return {TimeAgo} the formatted date using the \"time ago format\" and the time until it needs to be updated\n */\nexport const formatTimeAgo = (date, locale, showSeconds = false, referenceDate = new Date()) => {\n const dayReferenceDate = dayjs(referenceDate);\n const dayDate = dayjs(date).locale(locale);\n\n const dayDiffSeconds = dayReferenceDate.diff(dayDate, \"second\");\n\n const formatUseSeconds = showSeconds ? \"LTS\" : \"LT\";\n\n // check if the date is after the reference date\n if (date.getTime() > referenceDate.getTime()) {\n return {\n timeAgo: dayDate.format(`L ${formatUseSeconds}`),\n delay: (date.getTime() - referenceDate.getTime()) / 1000,\n };\n }\n\n // just now, until the 2 minutes\n if (dayDiffSeconds < 120) {\n return {\n timeAgo: dayjs.duration(dayDiffSeconds, \"second\").locale(locale).humanize(),\n delay: 120 - dayDiffSeconds,\n };\n }\n\n // ago in minutes, until the 1 hour mark\n const dayDiffMinutes = dayReferenceDate.diff(dayDate, \"minute\");\n\n if (dayDiffMinutes < 60) {\n return {\n timeAgo: dayjs.duration(-dayDiffMinutes, \"minute\").locale(locale).humanize(true),\n delay: 60 * (dayDiffMinutes + 1) - dayDiffSeconds,\n };\n }\n\n // formatted date with text description for today\n if (dayReferenceDate.isSame(dayDate, \"day\")) {\n return {\n timeAgo: `${dayDate.calendar(dayReferenceDate)}`,\n delay: secondsUntilNextDay(referenceDate),\n };\n }\n\n // formatted date with text description for yesterday\n if (dayReferenceDate.subtract(1, \"day\").isSame(dayDate, \"day\")) {\n return {\n timeAgo: `${dayDate.calendar(dayReferenceDate)}`,\n delay: secondsUntilNextDay(referenceDate),\n };\n }\n\n // formatted date with week during the current week\n if (dayDate.isSame(dayReferenceDate, \"week\")) {\n return {\n timeAgo: dayDate.format(`ddd, ${formatUseSeconds}`),\n delay: secondsUntilNextWeek(date),\n };\n }\n\n // formatted without special gimmicks\n return {\n timeAgo: dayDate.format(`L ${formatUseSeconds}`),\n delay: 0,\n };\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMA,UAAU,GAAG,CACjB;EAAEC,CAAC,EAAE,GAAL;EAAUC,CAAC,EAAE,GAAb;EAAkBC,CAAC,EAAE;AAArB,CADiB,EAEjB;EAAEF,CAAC,EAAE,GAAL;EAAUC,CAAC,EAAE;AAAb,CAFiB,EAGjB;EAAED,CAAC,EAAE,IAAL;EAAWC,CAAC,EAAE,EAAd;EAAkBC,CAAC,EAAE;AAArB,CAHiB,EAIjB;EAAEF,CAAC,EAAE,GAAL;EAAUC,CAAC,EAAE;AAAb,CAJiB,EAKjB;EAAED,CAAC,EAAE,IAAL;EAAWC,CAAC,EAAE,EAAd;EAAkBC,CAAC,EAAE;AAArB,CALiB,EAMjB;EAAEF,CAAC,EAAE,GAAL;EAAUC,CAAC,EAAE;AAAb,CANiB,EAOjB;EAAED,CAAC,EAAE,IAAL;EAAWC,CAAC,EAAE,EAAd;EAAkBC,CAAC,EAAE;AAArB,CAPiB,EAQjB;EAAEF,CAAC,EAAE,GAAL;EAAUC,CAAC,EAAE;AAAb,CARiB,EASjB;EAAED,CAAC,EAAE,IAAL;EAAWC,CAAC,EAAE,EAAd;EAAkBC,CAAC,EAAE;AAArB,CATiB,EAUjB;EAAEF,CAAC,EAAE,GAAL;EAAUC,CAAC,EAAE;AAAb,CAViB,EAWjB;EAAED,CAAC,EAAE,IAAL;EAAWE,CAAC,EAAE;AAAd,CAXiB,CAAnB;;AAcAC,
|
|
1
|
+
{"version":3,"file":"formatUtils.js","names":["thresholds","l","r","d","dayjs","extend","localeData","duration","calendar","localizedFormat","relativeTime","updateLocale","secondsUntilNextDay","date","Date","midnight","getTime","setDate","getDate","setHours","setMinutes","setSeconds","setMilliseconds","secondsUntilNextWeek","firstMonthDayOfWeek","getDay","firstMonthDayOfNextWeek","firstDayNextWeek","formatTimeAgo","locale","showSeconds","referenceDate","dayReferenceDate","dayDate","dayDiffSeconds","diff","formatUseSeconds","timeAgo","format","delay","humanize","dayDiffMinutes","isSame","subtract"],"sources":["../../src/TimeAgo/formatUtils.js"],"sourcesContent":["import dayjs from \"dayjs\";\nimport calendar from \"dayjs/plugin/calendar\";\nimport duration from \"dayjs/plugin/duration\";\nimport localeData from \"dayjs/plugin/localeData\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat\";\nimport relativeTime from \"dayjs/plugin/relativeTime\";\nimport updateLocale from \"dayjs/plugin/updateLocale\";\n\n/**\n * Relative time thresholds defined by\n * {@link https://xd.adobe.com/view/1b7df235-5cf8-4b51-a2f0-0be1bb591c55-4e2e/ Design System}\n *\n * Implementation using day.js {@link https://day.js.org/docs/en/customization/relative-time relativeTime}\n */\nconst thresholds = [\n { l: \"s\", r: 119, d: \"second\" },\n { l: \"m\", r: 1 },\n { l: \"mm\", r: 59, d: \"minute\" },\n { l: \"h\", r: 1 },\n { l: \"hh\", r: 23, d: \"hour\" },\n { l: \"d\", r: 1 },\n { l: \"dd\", r: 29, d: \"day\" },\n { l: \"M\", r: 1 },\n { l: \"MM\", r: 11, d: \"month\" },\n { l: \"y\", r: 17 },\n { l: \"yy\", d: \"year\" },\n];\n\ndayjs.extend(localeData);\ndayjs.extend(duration);\ndayjs.extend(calendar);\ndayjs.extend(localizedFormat);\ndayjs.extend(relativeTime, { thresholds });\ndayjs.extend(updateLocale);\n\nexport const secondsUntilNextDay = (date = new Date()) => {\n const midnight = new Date(date.getTime());\n\n midnight.setDate(midnight.getDate() + 1);\n midnight.setHours(0);\n midnight.setMinutes(0);\n midnight.setSeconds(0);\n midnight.setMilliseconds(0);\n\n return (midnight.getTime() - date.getTime()) / 1000;\n};\n\nconst secondsUntilNextWeek = (date = new Date()) => {\n const firstMonthDayOfWeek = date.getDate() - date.getDay();\n const firstMonthDayOfNextWeek = firstMonthDayOfWeek + 7; // auto roll over to next month if needed\n\n const firstDayNextWeek = new Date(date.getTime());\n\n firstDayNextWeek.setDate(firstMonthDayOfNextWeek);\n firstDayNextWeek.setHours(0);\n firstDayNextWeek.setMinutes(0);\n firstDayNextWeek.setSeconds(0);\n firstDayNextWeek.setMilliseconds(0);\n\n return (firstDayNextWeek.getTime() - date.getTime()) / 1000;\n};\n\n/**\n * @typedef {Object} TimeAgo\n * @property {string} timeAgo - the formatted date using the \"time ago format\"\n * @property {number} delay - the time until the date needs to be updated\n */\n\n/**\n * Formats a date to the a relative time format using dayjs.\n *\n * @param {Date} date - date to format.\n * @param {String} locale - locale to use.\n * @param {Boolean} [showSeconds=false] - if seconds should be part of the result.\n * @param {Date} referenceDate - reference date to use when formatting (defaults to current date).\n *\n * @return {TimeAgo} the formatted date using the \"time ago format\" and the time until it needs to be updated\n */\nexport const formatTimeAgo = (date, locale, showSeconds = false, referenceDate = new Date()) => {\n const dayReferenceDate = dayjs(referenceDate);\n const dayDate = dayjs(date).locale(locale);\n\n const dayDiffSeconds = dayReferenceDate.diff(dayDate, \"second\");\n\n const formatUseSeconds = showSeconds ? \"LTS\" : \"LT\";\n\n // check if the date is after the reference date\n if (date.getTime() > referenceDate.getTime()) {\n return {\n timeAgo: dayDate.format(`L ${formatUseSeconds}`),\n delay: (date.getTime() - referenceDate.getTime()) / 1000,\n };\n }\n\n // just now, until the 2 minutes\n if (dayDiffSeconds < 120) {\n return {\n timeAgo: dayjs.duration(dayDiffSeconds, \"second\").locale(locale).humanize(),\n delay: 120 - dayDiffSeconds,\n };\n }\n\n // ago in minutes, until the 1 hour mark\n const dayDiffMinutes = dayReferenceDate.diff(dayDate, \"minute\");\n\n if (dayDiffMinutes < 60) {\n return {\n timeAgo: dayjs.duration(-dayDiffMinutes, \"minute\").locale(locale).humanize(true),\n delay: 60 * (dayDiffMinutes + 1) - dayDiffSeconds,\n };\n }\n\n // formatted date with text description for today\n if (dayReferenceDate.isSame(dayDate, \"day\")) {\n return {\n timeAgo: `${dayDate.calendar(dayReferenceDate)}`,\n delay: secondsUntilNextDay(referenceDate),\n };\n }\n\n // formatted date with text description for yesterday\n if (dayReferenceDate.subtract(1, \"day\").isSame(dayDate, \"day\")) {\n return {\n timeAgo: `${dayDate.calendar(dayReferenceDate)}`,\n delay: secondsUntilNextDay(referenceDate),\n };\n }\n\n // formatted date with week during the current week\n if (dayDate.isSame(dayReferenceDate, \"week\")) {\n return {\n timeAgo: dayDate.format(`ddd, ${formatUseSeconds}`),\n delay: secondsUntilNextWeek(date),\n };\n }\n\n // formatted without special gimmicks\n return {\n timeAgo: dayDate.format(`L ${formatUseSeconds}`),\n delay: 0,\n };\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AAyDW,QAAzD,CAAkE,IAAlE,CADJ;MAELD,KAAK,EAAE,MAAME,cAAc,GAAG,CAAvB,IAA4BP;IAF9B,CAAP;EAID,CAhC6F,CAkC9F;;;EACA,IAAIF,gBAAgB,CAACU,MAAjB,CAAwBT,OAAxB,EAAiC,KAAjC,CAAJ,EAA6C;IAC3C,OAAO;MACLI,OAAO,YAAKJ,OAAO,CAACzB,QAAR,CAAiBwB,gBAAjB,CAAL,CADF;MAELO,KAAK,EAAE3B,mBAAmB,CAACmB,aAAD;IAFrB,CAAP;EAID,CAxC6F,CA0C9F;;;EACA,IAAIC,gBAAgB,CAACW,QAAjB,CAA0B,CAA1B,EAA6B,KAA7B,EAAoCD,MAApC,CAA2CT,OAA3C,EAAoD,KAApD,CAAJ,EAAgE;IAC9D,OAAO;MACLI,OAAO,YAAKJ,OAAO,CAACzB,QAAR,CAAiBwB,gBAAjB,CAAL,CADF;MAELO,KAAK,EAAE3B,mBAAmB,CAACmB,aAAD;IAFrB,CAAP;EAID,CAhD6F,CAkD9F;;;EACA,IAAIE,OAAO,CAACS,MAAR,CAAeV,gBAAf,EAAiC,MAAjC,CAAJ,EAA8C;IAC5C,OAAO;MACLK,OAAO,EAAEJ,OAAO,CAACK,MAAR,gBAAuBF,gBAAvB,EADJ;MAELG,KAAK,EAAEhB,oBAAoB,CAACV,IAAD;IAFtB,CAAP;EAID,CAxD6F,CA0D9F;;;EACA,OAAO;IACLwB,OAAO,EAAEJ,OAAO,CAACK,MAAR,aAAoBF,gBAApB,EADJ;IAELG,KAAK,EAAE;EAFF,CAAP;AAID,CA/DM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTimeAgo.js","names":["fmt","timestamp","locale","showSeconds","timestampMs","String","length","Date","useTimeAgo","options","disableRefresh","timeAgo","setTimeAgo","refreshTime","delay","newTimeAgo"],"sources":["../../src/TimeAgo/useTimeAgo.js"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport useTimeout from \"./useTimeout\";\nimport { formatTimeAgo } from \"./formatUtils\";\n\n/**\n * Calls `formatTimeAgo` with timestamp conversion\n */\nconst fmt = (timestamp, locale, showSeconds) => {\n const timestampMs = String(timestamp).length > 11 ? timestamp : timestamp * 1000;\n return formatTimeAgo(new Date(timestampMs), locale, showSeconds);\n};\n\nexport default function useTimeAgo(timestamp, options) {\n const { locale, disableRefresh = false, showSeconds = false } = options;\n const [timeAgo, setTimeAgo] = useState(fmt(timestamp, locale, showSeconds));\n const refreshTime = disableRefresh ? 0 : timeAgo.delay * 1000;\n\n useEffect(() => {\n const newTimeAgo = fmt(timestamp, locale, showSeconds);\n setTimeAgo(newTimeAgo);\n }, [timestamp, locale, showSeconds]);\n\n useTimeout(() => {\n const newTimeAgo = fmt(timestamp, locale, showSeconds);\n setTimeAgo(newTimeAgo);\n }, refreshTime);\n\n return timeAgo.timeAgo;\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;AACA;AACA;AACA,IAAMA,GAAG,GAAG,SAANA,GAAM,CAACC,SAAD,EAAYC,MAAZ,EAAoBC,WAApB,EAAoC;EAC9C,IAAMC,WAAW,GAAGC,MAAM,CAACJ,SAAD,CAAN,CAAkBK,MAAlB,GAA2B,EAA3B,GAAgCL,SAAhC,GAA4CA,SAAS,GAAG,IAA5E;EACA,OAAO,
|
|
1
|
+
{"version":3,"file":"useTimeAgo.js","names":["fmt","timestamp","locale","showSeconds","timestampMs","String","length","formatTimeAgo","Date","useTimeAgo","options","disableRefresh","useState","timeAgo","setTimeAgo","refreshTime","delay","useEffect","newTimeAgo","useTimeout"],"sources":["../../src/TimeAgo/useTimeAgo.js"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport useTimeout from \"./useTimeout\";\nimport { formatTimeAgo } from \"./formatUtils\";\n\n/**\n * Calls `formatTimeAgo` with timestamp conversion\n */\nconst fmt = (timestamp, locale, showSeconds) => {\n const timestampMs = String(timestamp).length > 11 ? timestamp : timestamp * 1000;\n return formatTimeAgo(new Date(timestampMs), locale, showSeconds);\n};\n\nexport default function useTimeAgo(timestamp, options) {\n const { locale, disableRefresh = false, showSeconds = false } = options;\n const [timeAgo, setTimeAgo] = useState(fmt(timestamp, locale, showSeconds));\n const refreshTime = disableRefresh ? 0 : timeAgo.delay * 1000;\n\n useEffect(() => {\n const newTimeAgo = fmt(timestamp, locale, showSeconds);\n setTimeAgo(newTimeAgo);\n }, [timestamp, locale, showSeconds]);\n\n useTimeout(() => {\n const newTimeAgo = fmt(timestamp, locale, showSeconds);\n setTimeAgo(newTimeAgo);\n }, refreshTime);\n\n return timeAgo.timeAgo;\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;AACA;AACA;AACA,IAAMA,GAAG,GAAG,SAANA,GAAM,CAACC,SAAD,EAAYC,MAAZ,EAAoBC,WAApB,EAAoC;EAC9C,IAAMC,WAAW,GAAGC,MAAM,CAACJ,SAAD,CAAN,CAAkBK,MAAlB,GAA2B,EAA3B,GAAgCL,SAAhC,GAA4CA,SAAS,GAAG,IAA5E;EACA,OAAO,IAAAM,0BAAA,EAAc,IAAIC,IAAJ,CAASJ,WAAT,CAAd,EAAqCF,MAArC,EAA6CC,WAA7C,CAAP;AACD,CAHD;;AAKe,SAASM,UAAT,CAAoBR,SAApB,EAA+BS,OAA/B,EAAwC;EACrD,IAAQR,MAAR,GAAgEQ,OAAhE,CAAQR,MAAR;EAAA,4BAAgEQ,OAAhE,CAAgBC,cAAhB;EAAA,IAAgBA,cAAhB,sCAAiC,KAAjC;EAAA,2BAAgED,OAAhE,CAAwCP,WAAxC;EAAA,IAAwCA,WAAxC,qCAAsD,KAAtD;;EACA,gBAA8B,IAAAS,eAAA,EAASZ,GAAG,CAACC,SAAD,EAAYC,MAAZ,EAAoBC,WAApB,CAAZ,CAA9B;EAAA;EAAA,IAAOU,OAAP;EAAA,IAAgBC,UAAhB;;EACA,IAAMC,WAAW,GAAGJ,cAAc,GAAG,CAAH,GAAOE,OAAO,CAACG,KAAR,GAAgB,IAAzD;EAEA,IAAAC,gBAAA,EAAU,YAAM;IACd,IAAMC,UAAU,GAAGlB,GAAG,CAACC,SAAD,EAAYC,MAAZ,EAAoBC,WAApB,CAAtB;IACAW,UAAU,CAACI,UAAD,CAAV;EACD,CAHD,EAGG,CAACjB,SAAD,EAAYC,MAAZ,EAAoBC,WAApB,CAHH;EAKA,IAAAgB,mBAAA,EAAW,YAAM;IACf,IAAMD,UAAU,GAAGlB,GAAG,CAACC,SAAD,EAAYC,MAAZ,EAAoBC,WAApB,CAAtB;IACAW,UAAU,CAACI,UAAD,CAAV;EACD,CAHD,EAGGH,WAHH;EAKA,OAAOF,OAAO,CAACA,OAAf;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTimeout.js","names":["useTimeout","callback","delay","savedCallback","current","undefined","id","setTimeout","clearTimeout"],"sources":["../../src/TimeAgo/useTimeout.js"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\nexport default function useTimeout(callback, delay) {\n const savedCallback = useRef(callback);\n\n useEffect(() => {\n savedCallback.current = callback;\n }, [callback]);\n\n useEffect(() => {\n if (!delay) return undefined;\n\n const id = setTimeout(() => savedCallback.current(), delay);\n return () => clearTimeout(id);\n }, [delay]);\n}\n"],"mappings":";;;;;;;AAAA;;AAEe,SAASA,UAAT,CAAoBC,QAApB,EAA8BC,KAA9B,EAAqC;EAClD,IAAMC,aAAa,GAAG,
|
|
1
|
+
{"version":3,"file":"useTimeout.js","names":["useTimeout","callback","delay","savedCallback","useRef","useEffect","current","undefined","id","setTimeout","clearTimeout"],"sources":["../../src/TimeAgo/useTimeout.js"],"sourcesContent":["import { useEffect, useRef } from \"react\";\n\nexport default function useTimeout(callback, delay) {\n const savedCallback = useRef(callback);\n\n useEffect(() => {\n savedCallback.current = callback;\n }, [callback]);\n\n useEffect(() => {\n if (!delay) return undefined;\n\n const id = setTimeout(() => savedCallback.current(), delay);\n return () => clearTimeout(id);\n }, [delay]);\n}\n"],"mappings":";;;;;;;AAAA;;AAEe,SAASA,UAAT,CAAoBC,QAApB,EAA8BC,KAA9B,EAAqC;EAClD,IAAMC,aAAa,GAAG,IAAAC,aAAA,EAAOH,QAAP,CAAtB;EAEA,IAAAI,gBAAA,EAAU,YAAM;IACdF,aAAa,CAACG,OAAd,GAAwBL,QAAxB;EACD,CAFD,EAEG,CAACA,QAAD,CAFH;EAIA,IAAAI,gBAAA,EAAU,YAAM;IACd,IAAI,CAACH,KAAL,EAAY,OAAOK,SAAP;IAEZ,IAAMC,EAAE,GAAGC,UAAU,CAAC;MAAA,OAAMN,aAAa,CAACG,OAAd,EAAN;IAAA,CAAD,EAAgCJ,KAAhC,CAArB;IACA,OAAO;MAAA,OAAMQ,YAAY,CAACF,EAAD,CAAlB;IAAA,CAAP;EACD,CALD,EAKG,CAACN,KAAD,CALH;AAMD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PeriodPicker.js","names":["PeriodPicker","props","onChangePeriod","period","selectDifferentPeriod","setState","currentPeriod","state","PeriodPickerOptions","AM","PM","classes","periodContainer","icon","handleChangePeriod","periodToggle","subtractIcon","React","Component","propTypes","PropTypes","instanceOf","Object","isRequired","func","oneOf"],"sources":["../../../src/TimePicker/PeriodPicker/PeriodPicker.js"],"sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport clsx from \"clsx\";\nimport { HvToggleButton } from \"@hitachivantara/uikit-react-core\";\nimport { DropUpXS as UpIcon, DropDownXS as DownIcon } from \"@hitachivantara/uikit-react-icons\";\nimport { PeriodPickerOptions } from \"../enums\";\n\nclass PeriodPicker extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n currentPeriod: props.period ?? PeriodPickerOptions.AM,\n };\n }\n\n /**\n * Handles the period change\n * @memberof PeriodPicker\n */\n handleChangePeriod = () => {\n const { onChangePeriod } = this.props;\n const period = this.selectDifferentPeriod();\n this.setState({\n currentPeriod: period,\n });\n onChangePeriod(period);\n };\n\n /**\n * Gets the new value for the period\n * @returns the new value for the period\n * @memberof UnitTimePicker\n */\n selectDifferentPeriod = () => {\n const { currentPeriod } = this.state;\n return currentPeriod === PeriodPickerOptions.AM\n ? PeriodPickerOptions.PM\n : PeriodPickerOptions.AM;\n };\n\n /**\n * Renders the PeriodPicker\n * @memberof UnitTimePicker\n */\n render() {\n const { classes } = this.props;\n const { currentPeriod } = this.state;\n\n return (\n <div className={classes.periodContainer}>\n <UpIcon className={classes.icon} onClick={this.handleChangePeriod} />\n <HvToggleButton\n className={classes.periodToggle}\n selected={currentPeriod === PeriodPickerOptions.PM}\n onClick={this.handleChangePeriod}\n >\n {currentPeriod}\n </HvToggleButton>\n <DownIcon\n className={clsx(classes.icon, classes.subtractIcon)}\n onClick={this.handleChangePeriod}\n />\n </div>\n );\n }\n}\n\nPeriodPicker.propTypes = {\n /**\n * A Jss Object used to override or extend the styles applied to the input/popper\n */\n classes: PropTypes.instanceOf(Object).isRequired,\n /**\n * Callback function called when the period value changes\n */\n onChangePeriod: PropTypes.func.isRequired,\n /**\n * Default period value\n */\n period: PropTypes.oneOf([PeriodPickerOptions.AM, PeriodPickerOptions.PM]),\n};\n\nexport default PeriodPicker;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEMA,Y;;;;;EACJ,sBAAYC,KAAZ,EAAmB;IAAA;;IAAA;;IAAA;IACjB,0BAAMA,KAAN;IADiB,iGAYE,YAAM;MACzB,IAAQC,cAAR,GAA2B,MAAKD,KAAhC,CAAQC,cAAR;;MACA,IAAMC,MAAM,GAAG,MAAKC,qBAAL,EAAf;;MACA,MAAKC,QAAL,CAAc;QACZC,aAAa,EAAEH;MADH,CAAd;;MAGAD,cAAc,CAACC,MAAD,CAAd;IACD,CAnBkB;IAAA,oGA0BK,YAAM;MAC5B,IAAQG,aAAR,GAA0B,MAAKC,KAA/B,CAAQD,aAAR;MACA,OAAOA,aAAa,KAAKE,
|
|
1
|
+
{"version":3,"file":"PeriodPicker.js","names":["PeriodPicker","props","onChangePeriod","period","selectDifferentPeriod","setState","currentPeriod","state","PeriodPickerOptions","AM","PM","classes","periodContainer","icon","handleChangePeriod","periodToggle","clsx","subtractIcon","React","Component","propTypes","PropTypes","instanceOf","Object","isRequired","func","oneOf"],"sources":["../../../src/TimePicker/PeriodPicker/PeriodPicker.js"],"sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport clsx from \"clsx\";\nimport { HvToggleButton } from \"@hitachivantara/uikit-react-core\";\nimport { DropUpXS as UpIcon, DropDownXS as DownIcon } from \"@hitachivantara/uikit-react-icons\";\nimport { PeriodPickerOptions } from \"../enums\";\n\nclass PeriodPicker extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n currentPeriod: props.period ?? PeriodPickerOptions.AM,\n };\n }\n\n /**\n * Handles the period change\n * @memberof PeriodPicker\n */\n handleChangePeriod = () => {\n const { onChangePeriod } = this.props;\n const period = this.selectDifferentPeriod();\n this.setState({\n currentPeriod: period,\n });\n onChangePeriod(period);\n };\n\n /**\n * Gets the new value for the period\n * @returns the new value for the period\n * @memberof UnitTimePicker\n */\n selectDifferentPeriod = () => {\n const { currentPeriod } = this.state;\n return currentPeriod === PeriodPickerOptions.AM\n ? PeriodPickerOptions.PM\n : PeriodPickerOptions.AM;\n };\n\n /**\n * Renders the PeriodPicker\n * @memberof UnitTimePicker\n */\n render() {\n const { classes } = this.props;\n const { currentPeriod } = this.state;\n\n return (\n <div className={classes.periodContainer}>\n <UpIcon className={classes.icon} onClick={this.handleChangePeriod} />\n <HvToggleButton\n className={classes.periodToggle}\n selected={currentPeriod === PeriodPickerOptions.PM}\n onClick={this.handleChangePeriod}\n >\n {currentPeriod}\n </HvToggleButton>\n <DownIcon\n className={clsx(classes.icon, classes.subtractIcon)}\n onClick={this.handleChangePeriod}\n />\n </div>\n );\n }\n}\n\nPeriodPicker.propTypes = {\n /**\n * A Jss Object used to override or extend the styles applied to the input/popper\n */\n classes: PropTypes.instanceOf(Object).isRequired,\n /**\n * Callback function called when the period value changes\n */\n onChangePeriod: PropTypes.func.isRequired,\n /**\n * Default period value\n */\n period: PropTypes.oneOf([PeriodPickerOptions.AM, PeriodPickerOptions.PM]),\n};\n\nexport default PeriodPicker;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEMA,Y;;;;;EACJ,sBAAYC,KAAZ,EAAmB;IAAA;;IAAA;;IAAA;IACjB,0BAAMA,KAAN;IADiB,iGAYE,YAAM;MACzB,IAAQC,cAAR,GAA2B,MAAKD,KAAhC,CAAQC,cAAR;;MACA,IAAMC,MAAM,GAAG,MAAKC,qBAAL,EAAf;;MACA,MAAKC,QAAL,CAAc;QACZC,aAAa,EAAEH;MADH,CAAd;;MAGAD,cAAc,CAACC,MAAD,CAAd;IACD,CAnBkB;IAAA,oGA0BK,YAAM;MAC5B,IAAQG,aAAR,GAA0B,MAAKC,KAA/B,CAAQD,aAAR;MACA,OAAOA,aAAa,KAAKE,0BAAA,CAAoBC,EAAtC,GACHD,0BAAA,CAAoBE,EADjB,GAEHF,0BAAA,CAAoBC,EAFxB;IAGD,CA/BkB;IAGjB,MAAKF,KAAL,GAAa;MACXD,aAAa,mBAAEL,KAAK,CAACE,MAAR,yDAAkBK,0BAAA,CAAoBC;IADxC,CAAb;IAHiB;EAMlB;EAED;AACF;AACA;AACA;;;;;;IAsBE;AACF;AACA;AACA;IACE,kBAAS;MACP,IAAQE,OAAR,GAAoB,KAAKV,KAAzB,CAAQU,OAAR;MACA,IAAQL,aAAR,GAA0B,KAAKC,KAA/B,CAAQD,aAAR;MAEA,oBACE;QAAK,SAAS,EAAEK,OAAO,CAACC;MAAxB,gBACE,6BAAC,yBAAD;QAAQ,SAAS,EAAED,OAAO,CAACE,IAA3B;QAAiC,OAAO,EAAE,KAAKC;MAA/C,EADF,eAEE,6BAAC,8BAAD;QACE,SAAS,EAAEH,OAAO,CAACI,YADrB;QAEE,QAAQ,EAAET,aAAa,KAAKE,0BAAA,CAAoBE,EAFlD;QAGE,OAAO,EAAE,KAAKI;MAHhB,GAKGR,aALH,CAFF,eASE,6BAAC,2BAAD;QACE,SAAS,EAAE,IAAAU,aAAA,EAAKL,OAAO,CAACE,IAAb,EAAmBF,OAAO,CAACM,YAA3B,CADb;QAEE,OAAO,EAAE,KAAKH;MAFhB,EATF,CADF;IAgBD;;;EA1DwBI,cAAA,CAAMC,S;;AA6DjC,wCAAAnB,YAAY,CAACoB,SAAb,GAAyB;EACvB;AACF;AACA;EACET,OAAO,EAAEU,kBAAA,CAAUC,UAAV,CAAqBC,MAArB,EAA6BC,UAJf;;EAKvB;AACF;AACA;EACEtB,cAAc,EAAEmB,kBAAA,CAAUI,IAAV,CAAeD,UARR;;EASvB;AACF;AACA;EACErB,MAAM,EAAEkB,kBAAA,CAAUK,KAAV,CAAgB,CAAClB,0BAAA,CAAoBC,EAArB,EAAyBD,0BAAA,CAAoBE,EAA7C,CAAhB;AAZe,CAAzB;eAeeV,Y"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["styles","name","PeriodPicker"],"sources":["../../../src/TimePicker/PeriodPicker/index.js"],"sourcesContent":["import withStyles from \"@material-ui/core/styles/withStyles\";\nimport styles from \"./styles\";\nimport PeriodPicker from \"./PeriodPicker\";\n\nexport default withStyles(styles, { name: \"HvTimePickerPeriodPicker\" })(PeriodPicker);\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;eAEe,
|
|
1
|
+
{"version":3,"file":"index.js","names":["withStyles","styles","name","PeriodPicker"],"sources":["../../../src/TimePicker/PeriodPicker/index.js"],"sourcesContent":["import withStyles from \"@material-ui/core/styles/withStyles\";\nimport styles from \"./styles\";\nimport PeriodPicker from \"./PeriodPicker\";\n\nexport default withStyles(styles, { name: \"HvTimePickerPeriodPicker\" })(PeriodPicker);\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;eAEe,IAAAA,mBAAA,EAAWC,eAAX,EAAmB;EAAEC,IAAI,EAAE;AAAR,CAAnB,EAAyDC,qBAAzD,C"}
|