@hitachivantara/uikit-react-core 5.57.0 → 5.58.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Button/Button.cjs +11 -0
- package/dist/cjs/Button/Button.cjs.map +1 -1
- package/dist/cjs/Button/Button.styles.cjs +79 -54
- package/dist/cjs/Button/Button.styles.cjs.map +1 -1
- package/dist/cjs/Button/types.cjs +9 -0
- package/dist/cjs/Button/types.cjs.map +1 -1
- package/dist/cjs/Calendar/model.cjs +23 -14
- package/dist/cjs/Calendar/model.cjs.map +1 -1
- package/dist/cjs/Calendar/utils.cjs +2 -3
- package/dist/cjs/Calendar/utils.cjs.map +1 -1
- package/dist/cjs/Carousel/Carousel.cjs +2 -2
- package/dist/cjs/Carousel/Carousel.cjs.map +1 -1
- package/dist/cjs/DotPagination/DotPagination.cjs +2 -2
- package/dist/cjs/DotPagination/DotPagination.cjs.map +1 -1
- package/dist/cjs/FileUploader/DropZone/DropZone.cjs +2 -4
- package/dist/cjs/FileUploader/DropZone/DropZone.cjs.map +1 -1
- package/dist/cjs/FilterGroup/FilterGroupContext.cjs +2 -4
- package/dist/cjs/FilterGroup/FilterGroupContext.cjs.map +1 -1
- package/dist/cjs/FilterGroup/RightPanel/RightPanel.cjs +1 -4
- package/dist/cjs/FilterGroup/RightPanel/RightPanel.cjs.map +1 -1
- package/dist/cjs/Grid/Grid.cjs +1 -3
- package/dist/cjs/Grid/Grid.cjs.map +1 -1
- package/dist/cjs/Loading/Loading.cjs +2 -4
- package/dist/cjs/Loading/Loading.cjs.map +1 -1
- package/dist/cjs/MultiButton/MultiButton.cjs +2 -1
- package/dist/cjs/MultiButton/MultiButton.cjs.map +1 -1
- package/dist/cjs/MultiButton/MultiButton.styles.cjs +3 -2
- package/dist/cjs/MultiButton/MultiButton.styles.cjs.map +1 -1
- package/dist/cjs/ProgressBar/ProgressBar.cjs +2 -4
- package/dist/cjs/ProgressBar/ProgressBar.cjs.map +1 -1
- package/dist/cjs/QueryBuilder/QueryBuilder.cjs +4 -8
- package/dist/cjs/QueryBuilder/QueryBuilder.cjs.map +1 -1
- package/dist/cjs/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.cjs +2 -3
- package/dist/cjs/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.cjs.map +1 -1
- package/dist/cjs/QueryBuilder/Rule/Value/NumericValue/NumericValue.cjs +4 -7
- package/dist/cjs/QueryBuilder/Rule/Value/NumericValue/NumericValue.cjs.map +1 -1
- package/dist/cjs/Snackbar/Snackbar.cjs +2 -3
- package/dist/cjs/Snackbar/Snackbar.cjs.map +1 -1
- package/dist/cjs/Stack/Stack.cjs +2 -6
- package/dist/cjs/Stack/Stack.cjs.map +1 -1
- package/dist/cjs/Table/TableCell/TableCell.cjs +3 -5
- package/dist/cjs/Table/TableCell/TableCell.cjs.map +1 -1
- package/dist/cjs/Table/TableHeader/TableHeader.cjs +4 -6
- package/dist/cjs/Table/TableHeader/TableHeader.cjs.map +1 -1
- package/dist/cjs/TreeView/internals/utils/EventManager.cjs +3 -5
- package/dist/cjs/TreeView/internals/utils/EventManager.cjs.map +1 -1
- package/dist/cjs/TreeView/internals/utils/FinalizationRegistryBasedCleanupTracking.cjs +5 -7
- package/dist/cjs/TreeView/internals/utils/FinalizationRegistryBasedCleanupTracking.cjs.map +1 -1
- package/dist/cjs/TreeView/internals/utils/TimerBasedCleanupTracking.cjs +2 -2
- package/dist/cjs/TreeView/internals/utils/TimerBasedCleanupTracking.cjs.map +1 -1
- package/dist/cjs/Typography/Typography.cjs +1 -0
- package/dist/cjs/Typography/Typography.cjs.map +1 -1
- package/dist/cjs/Typography/Typography.styles.cjs +1 -0
- package/dist/cjs/Typography/Typography.styles.cjs.map +1 -1
- package/dist/cjs/Typography/utils.cjs +1 -0
- package/dist/cjs/Typography/utils.cjs.map +1 -1
- package/dist/cjs/VerticalNavigation/Navigation/Navigation.cjs +3 -5
- package/dist/cjs/VerticalNavigation/Navigation/Navigation.cjs.map +1 -1
- package/dist/cjs/utils/Random.cjs +3 -0
- package/dist/cjs/utils/Random.cjs.map +1 -1
- package/dist/cjs/utils/classes.cjs +1 -1
- package/dist/cjs/utils/classes.cjs.map +1 -1
- package/dist/cjs/utils/helpers.cjs +33 -0
- package/dist/cjs/utils/helpers.cjs.map +1 -0
- package/dist/cjs/utils/setId.cjs +2 -4
- package/dist/cjs/utils/setId.cjs.map +1 -1
- package/dist/esm/Button/Button.js +12 -1
- package/dist/esm/Button/Button.js.map +1 -1
- package/dist/esm/Button/Button.styles.js +79 -54
- package/dist/esm/Button/Button.styles.js.map +1 -1
- package/dist/esm/Button/types.js +9 -0
- package/dist/esm/Button/types.js.map +1 -1
- package/dist/esm/Calendar/model.js +23 -14
- package/dist/esm/Calendar/model.js.map +1 -1
- package/dist/esm/Calendar/utils.js +1 -1
- package/dist/esm/Calendar/utils.js.map +1 -1
- package/dist/esm/Carousel/Carousel.js +2 -2
- package/dist/esm/Carousel/Carousel.js.map +1 -1
- package/dist/esm/DotPagination/DotPagination.js +1 -1
- package/dist/esm/DotPagination/DotPagination.js.map +1 -1
- package/dist/esm/FileUploader/DropZone/DropZone.js +1 -1
- package/dist/esm/FileUploader/DropZone/DropZone.js.map +1 -1
- package/dist/esm/FilterGroup/FilterGroupContext.js +1 -1
- package/dist/esm/FilterGroup/FilterGroupContext.js.map +1 -1
- package/dist/esm/FilterGroup/RightPanel/RightPanel.js +1 -2
- package/dist/esm/FilterGroup/RightPanel/RightPanel.js.map +1 -1
- package/dist/esm/Grid/Grid.js +1 -2
- package/dist/esm/Grid/Grid.js.map +1 -1
- package/dist/esm/Loading/Loading.js +2 -2
- package/dist/esm/Loading/Loading.js.map +1 -1
- package/dist/esm/MultiButton/MultiButton.js +2 -1
- package/dist/esm/MultiButton/MultiButton.js.map +1 -1
- package/dist/esm/MultiButton/MultiButton.styles.js +3 -2
- package/dist/esm/MultiButton/MultiButton.styles.js.map +1 -1
- package/dist/esm/ProgressBar/ProgressBar.js +2 -2
- package/dist/esm/ProgressBar/ProgressBar.js.map +1 -1
- package/dist/esm/QueryBuilder/QueryBuilder.js +3 -4
- package/dist/esm/QueryBuilder/QueryBuilder.js.map +1 -1
- package/dist/esm/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.js +1 -1
- package/dist/esm/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.js.map +1 -1
- package/dist/esm/QueryBuilder/Rule/Value/NumericValue/NumericValue.js +3 -4
- package/dist/esm/QueryBuilder/Rule/Value/NumericValue/NumericValue.js.map +1 -1
- package/dist/esm/Snackbar/Snackbar.js +1 -1
- package/dist/esm/Snackbar/Snackbar.js.map +1 -1
- package/dist/esm/Stack/Stack.js +2 -4
- package/dist/esm/Stack/Stack.js.map +1 -1
- package/dist/esm/Table/TableCell/TableCell.js +1 -1
- package/dist/esm/Table/TableCell/TableCell.js.map +1 -1
- package/dist/esm/Table/TableHeader/TableHeader.js +1 -1
- package/dist/esm/Table/TableHeader/TableHeader.js.map +1 -1
- package/dist/esm/TreeView/internals/utils/EventManager.js +3 -5
- package/dist/esm/TreeView/internals/utils/EventManager.js.map +1 -1
- package/dist/esm/TreeView/internals/utils/FinalizationRegistryBasedCleanupTracking.js +5 -7
- package/dist/esm/TreeView/internals/utils/FinalizationRegistryBasedCleanupTracking.js.map +1 -1
- package/dist/esm/TreeView/internals/utils/TimerBasedCleanupTracking.js +2 -2
- package/dist/esm/TreeView/internals/utils/TimerBasedCleanupTracking.js.map +1 -1
- package/dist/esm/Typography/Typography.js +1 -0
- package/dist/esm/Typography/Typography.js.map +1 -1
- package/dist/esm/Typography/Typography.styles.js +1 -0
- package/dist/esm/Typography/Typography.styles.js.map +1 -1
- package/dist/esm/Typography/utils.js +1 -0
- package/dist/esm/Typography/utils.js.map +1 -1
- package/dist/esm/VerticalNavigation/Navigation/Navigation.js +1 -1
- package/dist/esm/VerticalNavigation/Navigation/Navigation.js.map +1 -1
- package/dist/esm/utils/Random.js +3 -0
- package/dist/esm/utils/Random.js.map +1 -1
- package/dist/esm/utils/classes.js +1 -1
- package/dist/esm/utils/classes.js.map +1 -1
- package/dist/esm/utils/helpers.js +33 -0
- package/dist/esm/utils/helpers.js.map +1 -0
- package/dist/esm/utils/setId.js +1 -1
- package/dist/esm/utils/setId.js.map +1 -1
- package/dist/types/index.d.ts +22 -14
- package/package.json +5 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTimeValue.js","sources":["../../../../../../src/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.tsx"],"sourcesContent":["import { memo, useCallback, useMemo, useState } from \"react\";\nimport uniqueId from \"lodash/uniqueId\";\nimport dayjs from \"dayjs\";\nimport { useTheme } from \"@mui/material/styles\";\nimport useMediaQuery from \"@mui/material/useMediaQuery\";\n\nimport { HvWarningText } from \"../../../../Forms\";\nimport { HvTimePicker, HvTimePickerValue } from \"../../../../TimePicker\";\nimport { HvDatePicker } from \"../../../../DatePicker\";\n\nimport { useQueryBuilderContext } from \"../../../Context\";\nimport { padTime, parseDate, parseTime } from \"./utils\";\nimport { useClasses } from \"./DateTimeValue.styles\";\n\nfunction valueIsRange(operator?: string) {\n return operator === \"range\";\n}\n\nexport interface DateTimeValueProps {\n id: React.Key;\n operator?: string;\n value?: any;\n initialTouched?: boolean;\n}\n\nexport const DateTimeValue = ({\n id,\n operator,\n value: valueProp = {},\n initialTouched = false,\n}: DateTimeValueProps) => {\n const { classes, cx } = useClasses();\n\n const theme = useTheme();\n const isMdDown = useMediaQuery(theme.breakpoints.down(\"md\"));\n\n const isRange = valueIsRange(operator);\n\n const { labels, dispatchAction, readOnly } = useQueryBuilderContext();\n\n const elementId = uniqueId(`datetime${id}`);\n\n const [touchedDate, setTouchedDate] = useState(initialTouched);\n const [touchedTime, setTouchedTime] = useState(initialTouched);\n const [touchedEndDate, setTouchedEndDate] = useState(initialTouched);\n const [touchedEndTime, setTouchedEndTime] = useState(initialTouched);\n\n const onDateChange = useCallback(\n (data?: Date) => {\n setTouchedDate(true);\n\n let date;\n if (data != null) {\n date = dayjs(data).format(\"YYYY-MM-DD\");\n }\n\n const oldValue = !isRange ? valueProp?.date : valueProp?.start?.date;\n\n if (date !== oldValue) {\n let value;\n if (!isRange) {\n value = {\n date,\n time: valueProp?.time,\n };\n } else {\n value = {\n start: {\n date,\n time: valueProp?.start?.time,\n },\n end: valueProp?.end,\n };\n }\n\n dispatchAction({\n type: \"set-value\",\n id,\n value,\n });\n }\n },\n [dispatchAction, id, isRange, valueProp]\n );\n\n const onTimeChange = useCallback(\n (data: HvTimePickerValue) => {\n setTouchedTime(true);\n\n let time;\n if (data != null) {\n time = `${padTime(data.hours)}:${padTime(data.minutes)}:${padTime(\n data.seconds\n )}`;\n }\n\n const oldValue = !isRange ? valueProp?.time : valueProp?.start?.time;\n\n if (time !== oldValue) {\n let value;\n if (!isRange) {\n value = {\n date: valueProp?.date,\n time,\n };\n } else {\n value = {\n start: {\n date: valueProp?.start?.date,\n time,\n },\n end: valueProp?.end,\n };\n }\n\n dispatchAction({\n type: \"set-value\",\n id,\n value,\n });\n }\n },\n [dispatchAction, id, isRange, valueProp]\n );\n\n const onEndDateChange = useCallback(\n (data?: Date) => {\n setTouchedEndDate(true);\n\n let date;\n if (data != null) {\n date = dayjs(data).format(\"YYYY-MM-DD\");\n }\n\n if (date !== valueProp?.end?.date) {\n const value = {\n start: valueProp?.start,\n end: {\n date,\n time: valueProp?.end?.time,\n },\n };\n\n dispatchAction({\n type: \"set-value\",\n id,\n value,\n });\n }\n },\n [dispatchAction, id, valueProp]\n );\n\n const onEndTimeChange = useCallback(\n (data: HvTimePickerValue) => {\n setTouchedEndTime(true);\n\n let time;\n if (data != null) {\n time = `${padTime(data.hours)}:${padTime(data.minutes)}:${padTime(\n data.seconds\n )}`;\n }\n\n if (time !== valueProp?.end?.time) {\n const value = {\n start: valueProp?.start,\n end: {\n date: valueProp?.end?.date,\n time,\n },\n };\n\n dispatchAction({\n type: \"set-value\",\n id,\n value,\n });\n }\n },\n [dispatchAction, id, valueProp]\n );\n\n const startDate = isRange ? valueProp?.start?.date : valueProp?.date;\n const datePickerValue = useMemo(() => parseDate(startDate), [startDate]);\n const datePickerStatus = datePickerValue != null ? \"valid\" : \"invalid\";\n\n const startTime = (isRange ? valueProp?.start?.time : valueProp?.time) ?? \"\";\n const timePickerValue = useMemo(() => parseTime(startTime), [startTime]);\n const timePickerStatus = timePickerValue != null ? \"valid\" : \"invalid\";\n\n const endDate = isRange ? valueProp?.end?.date : null;\n const endDatePickerValue = useMemo(() => parseDate(endDate), [endDate]);\n\n const endTime = isRange ? valueProp?.end?.time : null;\n const endTimePickerValue = useMemo(() => parseTime(endTime), [endTime]);\n\n const dateStatus = !touchedDate ? \"standBy\" : datePickerStatus;\n const timeStatus = !touchedTime ? \"standBy\" : timePickerStatus;\n\n const endDateIsBefore =\n startDate != null && endDate != null && endDate < startDate;\n\n const endTimeIsBeforeOrSame =\n startDate != null &&\n endDate != null &&\n endDate === startDate &&\n startTime != null &&\n endTime != null &&\n endTime <= startTime;\n\n const endDateTimeIsBefore = endDateIsBefore || endTimeIsBeforeOrSame;\n\n const endDatePickerStatus =\n endDatePickerValue == null || endDateTimeIsBefore ? \"invalid\" : \"valid\";\n const endDateStatus = !touchedEndDate ? \"standBy\" : endDatePickerStatus;\n\n const endTimePickerStatus =\n endTimePickerValue == null || endDateTimeIsBefore ? \"invalid\" : \"valid\";\n const endTimeStatus = !touchedEndTime ? \"standBy\" : endTimePickerStatus;\n\n return (\n <div className={classes.root}>\n <div\n className={cx(classes.row, classes.horizontal, {\n [classes.isMdDown]: isMdDown,\n })}\n >\n <HvDatePicker\n className={classes.datePicker}\n name={`${elementId}-date`}\n required\n status={dateStatus}\n statusMessage={labels.rule.value.datetime.validation.required}\n label={\n isRange\n ? labels.rule.value.datetime.startDateLabel\n : labels.rule.value.datetime.dateLabel\n }\n placeholder={\n isRange\n ? labels.rule.value.datetime.startDatePlaceholder\n : labels.rule.value.datetime.datePlaceholder\n }\n value={datePickerValue}\n onChange={onDateChange}\n readOnly={readOnly}\n />\n <HvTimePicker\n className={classes.timePicker}\n timeFormat=\"24\"\n name={`${elementId}-time`}\n required\n status={timeStatus}\n statusMessage={labels.rule.value.datetime.validation.required}\n label={\n isRange\n ? labels.rule.value.datetime.startTimeLabel\n : labels.rule.value.datetime.timeLabel\n }\n placeholder={\n isRange\n ? labels.rule.value.datetime.startTimePlaceholder\n : labels.rule.value.datetime.timePlaceholder\n }\n value={timePickerValue || undefined}\n onChange={onTimeChange}\n onToggle={(_evt, open) => {\n if (!open && !touchedTime) {\n setTouchedTime(true);\n }\n }}\n readOnly={readOnly}\n />\n </div>\n {isRange && (\n <div className={cx(classes.row, classes.vertical)}>\n <div\n className={cx(classes.horizontal, {\n [classes.isMdDown]: isMdDown,\n })}\n >\n <HvDatePicker\n className={classes.datePicker}\n name={`${elementId}-endDate`}\n required\n status={endDateStatus}\n statusMessage={labels.rule.value.datetime.validation.required}\n aria-errormessage={\n endDateTimeIsBefore ? `${elementId}-combined-error` : undefined\n }\n label={labels.rule.value.datetime.endDateLabel}\n placeholder={labels.rule.value.datetime.endDatePlaceholder}\n value={endDatePickerValue}\n onChange={onEndDateChange}\n readOnly={readOnly}\n />\n <HvTimePicker\n className={classes.timePicker}\n timeFormat=\"24\"\n name={`${elementId}-endTime`}\n required\n status={endTimeStatus}\n statusMessage={labels.rule.value.datetime.validation.required}\n aria-errormessage={\n endDateTimeIsBefore ? `${elementId}-combined-error` : undefined\n }\n label={labels.rule.value.datetime.endTimeLabel}\n placeholder={labels.rule.value.datetime.endTimePlaceholder}\n value={endTimePickerValue || undefined}\n onChange={onEndTimeChange}\n onToggle={(_evt, open) => {\n if (!open && !touchedEndTime) {\n setTouchedEndTime(true);\n }\n }}\n readOnly={readOnly}\n />\n </div>\n <HvWarningText\n disableBorder\n id={`${elementId}-combined-error`}\n isVisible={endDateTimeIsBefore}\n >\n {labels.rule.value.datetime.validation.invalidInterval}\n </HvWarningText>\n </div>\n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,UAAU,CAAC,MAAM,SAAS;AACpB,sBAAA,CAAC,QAAQ,CAAC,gBAAgB;AAC5B,sCAAkB,IAAI;AAAA,kBACxB;AAAA,gBACF;AAAA,gBACA;AAAA,cAAA;AAAA,YACF;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,MACA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,eAAa;AAAA,UACb,IAAI,GAAG,SAAS;AAAA,UAChB,WAAW;AAAA,UAEV,UAAO,OAAA,KAAK,MAAM,SAAS,WAAW;AAAA,QAAA;AAAA,MACzC;AAAA,IAAA,GACF;AAAA,EAEJ,EAAA,CAAA;AAEJ;AAEe,KAAK,aAAa;"}
|
|
1
|
+
{"version":3,"file":"DateTimeValue.js","sources":["../../../../../../src/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.tsx"],"sourcesContent":["import { memo, useCallback, useMemo, useState } from \"react\";\nimport dayjs from \"dayjs\";\nimport { useTheme } from \"@mui/material/styles\";\nimport useMediaQuery from \"@mui/material/useMediaQuery\";\n\nimport { HvWarningText } from \"../../../../Forms\";\nimport { HvTimePicker, HvTimePickerValue } from \"../../../../TimePicker\";\nimport { HvDatePicker } from \"../../../../DatePicker\";\nimport { uniqueId } from \"../../../../utils/helpers\";\n\nimport { useQueryBuilderContext } from \"../../../Context\";\nimport { padTime, parseDate, parseTime } from \"./utils\";\nimport { useClasses } from \"./DateTimeValue.styles\";\n\nfunction valueIsRange(operator?: string) {\n return operator === \"range\";\n}\n\nexport interface DateTimeValueProps {\n id: React.Key;\n operator?: string;\n value?: any;\n initialTouched?: boolean;\n}\n\nexport const DateTimeValue = ({\n id,\n operator,\n value: valueProp = {},\n initialTouched = false,\n}: DateTimeValueProps) => {\n const { classes, cx } = useClasses();\n\n const theme = useTheme();\n const isMdDown = useMediaQuery(theme.breakpoints.down(\"md\"));\n\n const isRange = valueIsRange(operator);\n\n const { labels, dispatchAction, readOnly } = useQueryBuilderContext();\n\n const elementId = uniqueId(`datetime${id}`);\n\n const [touchedDate, setTouchedDate] = useState(initialTouched);\n const [touchedTime, setTouchedTime] = useState(initialTouched);\n const [touchedEndDate, setTouchedEndDate] = useState(initialTouched);\n const [touchedEndTime, setTouchedEndTime] = useState(initialTouched);\n\n const onDateChange = useCallback(\n (data?: Date) => {\n setTouchedDate(true);\n\n let date;\n if (data != null) {\n date = dayjs(data).format(\"YYYY-MM-DD\");\n }\n\n const oldValue = !isRange ? valueProp?.date : valueProp?.start?.date;\n\n if (date !== oldValue) {\n let value;\n if (!isRange) {\n value = {\n date,\n time: valueProp?.time,\n };\n } else {\n value = {\n start: {\n date,\n time: valueProp?.start?.time,\n },\n end: valueProp?.end,\n };\n }\n\n dispatchAction({\n type: \"set-value\",\n id,\n value,\n });\n }\n },\n [dispatchAction, id, isRange, valueProp]\n );\n\n const onTimeChange = useCallback(\n (data: HvTimePickerValue) => {\n setTouchedTime(true);\n\n let time;\n if (data != null) {\n time = `${padTime(data.hours)}:${padTime(data.minutes)}:${padTime(\n data.seconds\n )}`;\n }\n\n const oldValue = !isRange ? valueProp?.time : valueProp?.start?.time;\n\n if (time !== oldValue) {\n let value;\n if (!isRange) {\n value = {\n date: valueProp?.date,\n time,\n };\n } else {\n value = {\n start: {\n date: valueProp?.start?.date,\n time,\n },\n end: valueProp?.end,\n };\n }\n\n dispatchAction({\n type: \"set-value\",\n id,\n value,\n });\n }\n },\n [dispatchAction, id, isRange, valueProp]\n );\n\n const onEndDateChange = useCallback(\n (data?: Date) => {\n setTouchedEndDate(true);\n\n let date;\n if (data != null) {\n date = dayjs(data).format(\"YYYY-MM-DD\");\n }\n\n if (date !== valueProp?.end?.date) {\n const value = {\n start: valueProp?.start,\n end: {\n date,\n time: valueProp?.end?.time,\n },\n };\n\n dispatchAction({\n type: \"set-value\",\n id,\n value,\n });\n }\n },\n [dispatchAction, id, valueProp]\n );\n\n const onEndTimeChange = useCallback(\n (data: HvTimePickerValue) => {\n setTouchedEndTime(true);\n\n let time;\n if (data != null) {\n time = `${padTime(data.hours)}:${padTime(data.minutes)}:${padTime(\n data.seconds\n )}`;\n }\n\n if (time !== valueProp?.end?.time) {\n const value = {\n start: valueProp?.start,\n end: {\n date: valueProp?.end?.date,\n time,\n },\n };\n\n dispatchAction({\n type: \"set-value\",\n id,\n value,\n });\n }\n },\n [dispatchAction, id, valueProp]\n );\n\n const startDate = isRange ? valueProp?.start?.date : valueProp?.date;\n const datePickerValue = useMemo(() => parseDate(startDate), [startDate]);\n const datePickerStatus = datePickerValue != null ? \"valid\" : \"invalid\";\n\n const startTime = (isRange ? valueProp?.start?.time : valueProp?.time) ?? \"\";\n const timePickerValue = useMemo(() => parseTime(startTime), [startTime]);\n const timePickerStatus = timePickerValue != null ? \"valid\" : \"invalid\";\n\n const endDate = isRange ? valueProp?.end?.date : null;\n const endDatePickerValue = useMemo(() => parseDate(endDate), [endDate]);\n\n const endTime = isRange ? valueProp?.end?.time : null;\n const endTimePickerValue = useMemo(() => parseTime(endTime), [endTime]);\n\n const dateStatus = !touchedDate ? \"standBy\" : datePickerStatus;\n const timeStatus = !touchedTime ? \"standBy\" : timePickerStatus;\n\n const endDateIsBefore =\n startDate != null && endDate != null && endDate < startDate;\n\n const endTimeIsBeforeOrSame =\n startDate != null &&\n endDate != null &&\n endDate === startDate &&\n startTime != null &&\n endTime != null &&\n endTime <= startTime;\n\n const endDateTimeIsBefore = endDateIsBefore || endTimeIsBeforeOrSame;\n\n const endDatePickerStatus =\n endDatePickerValue == null || endDateTimeIsBefore ? \"invalid\" : \"valid\";\n const endDateStatus = !touchedEndDate ? \"standBy\" : endDatePickerStatus;\n\n const endTimePickerStatus =\n endTimePickerValue == null || endDateTimeIsBefore ? \"invalid\" : \"valid\";\n const endTimeStatus = !touchedEndTime ? \"standBy\" : endTimePickerStatus;\n\n return (\n <div className={classes.root}>\n <div\n className={cx(classes.row, classes.horizontal, {\n [classes.isMdDown]: isMdDown,\n })}\n >\n <HvDatePicker\n className={classes.datePicker}\n name={`${elementId}-date`}\n required\n status={dateStatus}\n statusMessage={labels.rule.value.datetime.validation.required}\n label={\n isRange\n ? labels.rule.value.datetime.startDateLabel\n : labels.rule.value.datetime.dateLabel\n }\n placeholder={\n isRange\n ? labels.rule.value.datetime.startDatePlaceholder\n : labels.rule.value.datetime.datePlaceholder\n }\n value={datePickerValue}\n onChange={onDateChange}\n readOnly={readOnly}\n />\n <HvTimePicker\n className={classes.timePicker}\n timeFormat=\"24\"\n name={`${elementId}-time`}\n required\n status={timeStatus}\n statusMessage={labels.rule.value.datetime.validation.required}\n label={\n isRange\n ? labels.rule.value.datetime.startTimeLabel\n : labels.rule.value.datetime.timeLabel\n }\n placeholder={\n isRange\n ? labels.rule.value.datetime.startTimePlaceholder\n : labels.rule.value.datetime.timePlaceholder\n }\n value={timePickerValue || undefined}\n onChange={onTimeChange}\n onToggle={(_evt, open) => {\n if (!open && !touchedTime) {\n setTouchedTime(true);\n }\n }}\n readOnly={readOnly}\n />\n </div>\n {isRange && (\n <div className={cx(classes.row, classes.vertical)}>\n <div\n className={cx(classes.horizontal, {\n [classes.isMdDown]: isMdDown,\n })}\n >\n <HvDatePicker\n className={classes.datePicker}\n name={`${elementId}-endDate`}\n required\n status={endDateStatus}\n statusMessage={labels.rule.value.datetime.validation.required}\n aria-errormessage={\n endDateTimeIsBefore ? `${elementId}-combined-error` : undefined\n }\n label={labels.rule.value.datetime.endDateLabel}\n placeholder={labels.rule.value.datetime.endDatePlaceholder}\n value={endDatePickerValue}\n onChange={onEndDateChange}\n readOnly={readOnly}\n />\n <HvTimePicker\n className={classes.timePicker}\n timeFormat=\"24\"\n name={`${elementId}-endTime`}\n required\n status={endTimeStatus}\n statusMessage={labels.rule.value.datetime.validation.required}\n aria-errormessage={\n endDateTimeIsBefore ? `${elementId}-combined-error` : undefined\n }\n label={labels.rule.value.datetime.endTimeLabel}\n placeholder={labels.rule.value.datetime.endTimePlaceholder}\n value={endTimePickerValue || undefined}\n onChange={onEndTimeChange}\n onToggle={(_evt, open) => {\n if (!open && !touchedEndTime) {\n setTouchedEndTime(true);\n }\n }}\n readOnly={readOnly}\n />\n </div>\n <HvWarningText\n disableBorder\n id={`${elementId}-combined-error`}\n isVisible={endDateTimeIsBefore}\n >\n {labels.rule.value.datetime.validation.invalidInterval}\n </HvWarningText>\n </div>\n )}\n </div>\n );\n};\n\nexport default memo(DateTimeValue);\n"],"names":[],"mappings":";;;;;;;;;;;;AAcA,SAAS,aAAa,UAAmB;AACvC,SAAO,aAAa;AACtB;AASO,MAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,OAAO,YAAY,CAAC;AAAA,EACpB,iBAAiB;AACnB,MAA0B;AACxB,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW;AAEnC,QAAM,QAAQ;AACd,QAAM,WAAW,cAAc,MAAM,YAAY,KAAK,IAAI,CAAC;AAErD,QAAA,UAAU,aAAa,QAAQ;AAErC,QAAM,EAAE,QAAQ,gBAAgB,aAAa,uBAAuB;AAEpE,QAAM,YAAY,SAAS,WAAW,EAAE,EAAE;AAE1C,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,cAAc;AAC7D,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,cAAc;AAC7D,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,cAAc;AACnE,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,cAAc;AAEnE,QAAM,eAAe;AAAA,IACnB,CAAC,SAAgB;AACf,qBAAe,IAAI;AAEf,UAAA;AACJ,UAAI,QAAQ,MAAM;AAChB,eAAO,MAAM,IAAI,EAAE,OAAO,YAAY;AAAA,MACxC;AAEA,YAAM,WAAW,CAAC,UAAU,WAAW,OAAO,WAAW,OAAO;AAEhE,UAAI,SAAS,UAAU;AACjB,YAAA;AACJ,YAAI,CAAC,SAAS;AACJ,kBAAA;AAAA,YACN;AAAA,YACA,MAAM,WAAW;AAAA,UAAA;AAAA,QACnB,OACK;AACG,kBAAA;AAAA,YACN,OAAO;AAAA,c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E,sBAAsB,GAAG,SAAS,oBAAoB;AAAA,gBAExD,OAAO,OAAO,KAAK,MAAM,SAAS;AAAA,gBAClC,aAAa,OAAO,KAAK,MAAM,SAAS;AAAA,gBACxC,OAAO,sBAAsB;AAAA,gBAC7B,UAAU;AAAA,gBACV,UAAU,CAAC,MAAM,SAAS;AACpB,sBAAA,CAAC,QAAQ,CAAC,gBAAgB;AAC5B,sCAAkB,IAAI;AAAA,kBACxB;AAAA,gBACF;AAAA,gBACA;AAAA,cAAA;AAAA,YACF;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,MACA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,eAAa;AAAA,UACb,IAAI,GAAG,SAAS;AAAA,UAChB,WAAW;AAAA,UAEV,UAAO,OAAA,KAAK,MAAM,SAAS,WAAW;AAAA,QAAA;AAAA,MACzC;AAAA,IAAA,GACF;AAAA,EAEJ,EAAA,CAAA;AAEJ;AAEe,KAAK,aAAa;"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { jsxs, jsx } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { useCallback, useState, memo } from "react";
|
|
3
|
-
import uniqueId from "lodash/uniqueId";
|
|
4
|
-
import isEmpty from "lodash/isEmpty";
|
|
5
3
|
import { useTheme } from "@mui/material/styles";
|
|
6
4
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
5
|
+
import { uniqueId } from "../../../../utils/helpers.js";
|
|
7
6
|
import { useQueryBuilderContext } from "../../../Context.js";
|
|
8
7
|
import { useClasses } from "./Numeric.styles.js";
|
|
9
8
|
import { HvInput } from "../../../../Input/Input.js";
|
|
@@ -20,7 +19,7 @@ const NumericValue = ({
|
|
|
20
19
|
const isMdDown = useMediaQuery(theme.breakpoints.down("md"));
|
|
21
20
|
const onSingleValueChange = useCallback(
|
|
22
21
|
(_, data) => {
|
|
23
|
-
const numericData =
|
|
22
|
+
const numericData = !data ? null : Number(data);
|
|
24
23
|
dispatchAction({
|
|
25
24
|
type: "set-value",
|
|
26
25
|
id,
|
|
@@ -31,7 +30,7 @@ const NumericValue = ({
|
|
|
31
30
|
);
|
|
32
31
|
const onRangeValueChange = useCallback(
|
|
33
32
|
(_, data, from = true) => {
|
|
34
|
-
const numericData =
|
|
33
|
+
const numericData = !data ? null : Number(data);
|
|
35
34
|
const currentValue = value;
|
|
36
35
|
const numericRange = {
|
|
37
36
|
from: currentValue?.from,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumericValue.js","sources":["../../../../../../src/QueryBuilder/Rule/Value/NumericValue/NumericValue.tsx"],"sourcesContent":["import { memo, useCallback, useState } from \"react\";\nimport uniqueId from \"lodash/uniqueId\";\nimport isEmpty from \"lodash/isEmpty\";\nimport { useTheme } from \"@mui/material/styles\";\nimport useMediaQuery from \"@mui/material/useMediaQuery\";\n\nimport { HvInput } from \"../../../../Input\";\n\nimport { useQueryBuilderContext } from \"../../../Context\";\nimport { useClasses } from \"./Numeric.styles\";\nimport { HvQueryBuilderNumericRange } from \"../../../types\";\n\nexport interface NumericValueProps {\n id: React.Key;\n value?: any;\n operator?: string;\n initialTouched?: boolean;\n}\n\nexport const NumericValue = ({\n id,\n value,\n operator,\n initialTouched = false,\n}: NumericValueProps) => {\n const { classes, cx } = useClasses();\n\n const isRange = operator === \"range\";\n const { labels, dispatchAction, readOnly } = useQueryBuilderContext();\n\n const theme = useTheme();\n\n const isMdDown = useMediaQuery(theme.breakpoints.down(\"md\"));\n\n const onSingleValueChange = useCallback(\n (_, data: string) => {\n const numericData = isEmpty(data) ? null : Number(data);\n dispatchAction({\n type: \"set-value\",\n id,\n value: Number.isNaN(numericData) ? data : numericData,\n });\n },\n [dispatchAction, id]\n );\n\n const onRangeValueChange = useCallback(\n (_, data: string, from = true) => {\n const numericData = isEmpty(data) ? null : Number(data);\n const currentValue = value;\n const numericRange = {\n from: currentValue?.from,\n to: currentValue?.to,\n };\n if (from) {\n numericRange.from = Number.isNaN(numericData) ? data : numericData;\n } else {\n numericRange.to = Number.isNaN(numericData) ? data : numericData;\n }\n dispatchAction({\n type: \"set-value\",\n id,\n value: numericRange,\n });\n },\n [dispatchAction, id, value]\n );\n\n const [touchedNumeric, setTouchedNumeric] = useState(initialTouched);\n const [touchedNumericTo, setTouchedNumericTo] = useState(initialTouched);\n\n const elementId = uniqueId(\"numeric\");\n\n let numericValidation: \"required\" | \"invalid\" | null = null;\n let rightValidation: \"required\" | \"invalid\" | \"greaterThan\" | \"equal\" | null =\n null;\n\n if (touchedNumeric || touchedNumericTo) {\n if (value === undefined || value?.toString() === \"\") {\n if (touchedNumeric) {\n numericValidation = \"required\";\n }\n if (touchedNumericTo) {\n rightValidation = \"required\";\n }\n } else if (!isRange) {\n if (Number.isNaN(Number(value))) {\n numericValidation = \"invalid\";\n }\n } else if (isRange) {\n const rangeValue = value;\n if (\n rangeValue?.from === undefined ||\n rangeValue?.from?.toString() === \"\"\n ) {\n numericValidation = \"required\";\n } else if (Number.isNaN(Number(rangeValue?.from))) {\n numericValidation = \"invalid\";\n }\n\n if (rangeValue?.to === undefined || rangeValue?.to?.toString() === \"\") {\n rightValidation = \"required\";\n } else if (Number.isNaN(Number(rangeValue?.to))) {\n rightValidation = \"invalid\";\n } else if (Number(rangeValue?.from) > Number(rangeValue?.to)) {\n rightValidation = \"greaterThan\";\n } else if (Number(rangeValue?.from) === Number(rangeValue?.to)) {\n rightValidation = \"equal\";\n }\n }\n }\n\n const numericStatus = numericValidation != null ? \"invalid\" : \"valid\";\n const rightStatus = rightValidation != null ? \"invalid\" : \"valid\";\n\n const renderRangeInputs = (rangeValue: HvQueryBuilderNumericRange) => (\n <div\n className={cx(classes.rangeContainer, { [classes.isMdDown]: isMdDown })}\n >\n <div className={classes.inputContainer}>\n <HvInput\n label={labels.rule.value.numeric.range.leftLabel}\n className={classes.input}\n id={`${elementId}-numeric-from`}\n name={`${elementId}-numeric-from`}\n value={rangeValue?.from?.toString() || \"\"}\n onChange={(event, data) => onRangeValueChange(event, data)}\n onBlur={() => {\n setTouchedNumeric(true);\n }}\n onKeyDown={(e: any) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n }\n }}\n status={!touchedNumeric ? \"standBy\" : numericStatus}\n statusMessage={\n numericValidation\n ? labels.rule.value.numeric.validation[numericValidation]\n : \"\"\n }\n required\n inputProps={{\n autoComplete: \"off\",\n }}\n placeholder={labels.rule.value.numeric.placeholder}\n readOnly={readOnly}\n />\n </div>\n <div className={classes.inputContainer}>\n <HvInput\n label={labels.rule.value.numeric.range.rightLabel}\n className={classes.input}\n id={`${elementId}-numeric-to`}\n name={`${elementId}-numeric-to`}\n value={rangeValue?.to?.toString() || \"\"}\n onChange={(event, data) => onRangeValueChange(event, data, false)}\n onBlur={() => {\n setTouchedNumericTo(true);\n }}\n onKeyDown={(e: any) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n }\n }}\n status={!touchedNumericTo ? \"standBy\" : rightStatus}\n statusMessage={\n rightValidation\n ? labels.rule.value.numeric.validation[rightValidation]\n : \"\"\n }\n required\n inputProps={{\n autoComplete: \"off\",\n }}\n placeholder={labels.rule.value.numeric.placeholder}\n readOnly={readOnly}\n />\n </div>\n </div>\n );\n\n return (\n <div className={classes.root}>\n {isRange && renderRangeInputs(value || {})}\n {!isRange && (\n <div className={classes.inputContainer}>\n <HvInput\n label={labels.rule.value.numeric.label}\n className={classes.input}\n id={`${elementId}-numeric`}\n name={`${elementId}-numeric`}\n value={value?.toString() || \"\"}\n onChange={onSingleValueChange}\n onBlur={() => {\n setTouchedNumeric(true);\n }}\n onKeyDown={(e: any) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n }\n }}\n status={!touchedNumeric ? \"standBy\" : numericStatus}\n required\n inputProps={{\n autoComplete: \"off\",\n }}\n placeholder={labels.rule.value.numeric.placeholder}\n statusMessage={\n numericValidation\n ? labels.rule.value.numeric.validation[numericValidation]\n : \"\"\n }\n readOnly={readOnly}\n />\n </div>\n )}\n </div>\n );\n};\n\nexport default memo(NumericVal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AAQ;AAAA,YACvC;AAAA,UAAA;AAAA,QAAA,GAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIJ,SACG,qBAAA,OAAA,EAAI,WAAW,QAAQ,MACrB,UAAA;AAAA,IAAW,WAAA,kBAAkB,SAAS,EAAE;AAAA,IACxC,CAAC,WACA,oBAAC,OAAI,EAAA,WAAW,QAAQ,gBACtB,UAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,OAAO,OAAO,KAAK,MAAM,QAAQ;AAAA,QACjC,WAAW,QAAQ;AAAA,QACnB,IAAI,GAAG,SAAS;AAAA,QAChB,MAAM,GAAG,SAAS;AAAA,QAClB,OAAO,OAAO,SAAA,KAAc;AAAA,QAC5B,UAAU;AAAA,QACV,QAAQ,MAAM;AACZ,4BAAkB,IAAI;AAAA,QACxB;AAAA,QACA,WAAW,CAAC,MAAW;AACjB,cAAA,EAAE,QAAQ,SAAS;AACrB,cAAE,eAAe;AAAA,UACnB;AAAA,QACF;AAAA,QACA,QAAQ,CAAC,iBAAiB,YAAY;AAAA,QACtC,UAAQ;AAAA,QACR,YAAY;AAAA,UACV,cAAc;AAAA,QAChB;AAAA,QACA,aAAa,OAAO,KAAK,MAAM,QAAQ;AAAA,QACvC,eACE,oBACI,OAAO,KAAK,MAAM,QAAQ,WAAW,iBAAiB,IACtD;AAAA,QAEN;AAAA,MAAA;AAAA,IAAA,GAEJ;AAAA,EAEJ,EAAA,CAAA;AAEJ;AAEe,KAAK,YAAY;"}
|
|
1
|
+
{"version":3,"file":"NumericValue.js","sources":["../../../../../../src/QueryBuilder/Rule/Value/NumericValue/NumericValue.tsx"],"sourcesContent":["import { memo, useCallback, useState } from \"react\";\nimport { useTheme } from \"@mui/material/styles\";\nimport useMediaQuery from \"@mui/material/useMediaQuery\";\n\nimport { HvInput } from \"../../../../Input\";\nimport { uniqueId } from \"../../../../utils/helpers\";\nimport { useQueryBuilderContext } from \"../../../Context\";\nimport { useClasses } from \"./Numeric.styles\";\nimport { HvQueryBuilderNumericRange } from \"../../../types\";\n\nexport interface NumericValueProps {\n id: React.Key;\n value?: any;\n operator?: string;\n initialTouched?: boolean;\n}\n\nexport const NumericValue = ({\n id,\n value,\n operator,\n initialTouched = false,\n}: NumericValueProps) => {\n const { classes, cx } = useClasses();\n\n const isRange = operator === \"range\";\n const { labels, dispatchAction, readOnly } = useQueryBuilderContext();\n\n const theme = useTheme();\n\n const isMdDown = useMediaQuery(theme.breakpoints.down(\"md\"));\n\n const onSingleValueChange = useCallback(\n (_, data: string) => {\n const numericData = !data ? null : Number(data);\n dispatchAction({\n type: \"set-value\",\n id,\n value: Number.isNaN(numericData) ? data : numericData,\n });\n },\n [dispatchAction, id]\n );\n\n const onRangeValueChange = useCallback(\n (_, data: string, from = true) => {\n const numericData = !data ? null : Number(data);\n const currentValue = value;\n const numericRange = {\n from: currentValue?.from,\n to: currentValue?.to,\n };\n if (from) {\n numericRange.from = Number.isNaN(numericData) ? data : numericData;\n } else {\n numericRange.to = Number.isNaN(numericData) ? data : numericData;\n }\n dispatchAction({\n type: \"set-value\",\n id,\n value: numericRange,\n });\n },\n [dispatchAction, id, value]\n );\n\n const [touchedNumeric, setTouchedNumeric] = useState(initialTouched);\n const [touchedNumericTo, setTouchedNumericTo] = useState(initialTouched);\n\n const elementId = uniqueId(\"numeric\");\n\n let numericValidation: \"required\" | \"invalid\" | null = null;\n let rightValidation: \"required\" | \"invalid\" | \"greaterThan\" | \"equal\" | null =\n null;\n\n if (touchedNumeric || touchedNumericTo) {\n if (value === undefined || value?.toString() === \"\") {\n if (touchedNumeric) {\n numericValidation = \"required\";\n }\n if (touchedNumericTo) {\n rightValidation = \"required\";\n }\n } else if (!isRange) {\n if (Number.isNaN(Number(value))) {\n numericValidation = \"invalid\";\n }\n } else if (isRange) {\n const rangeValue = value;\n if (\n rangeValue?.from === undefined ||\n rangeValue?.from?.toString() === \"\"\n ) {\n numericValidation = \"required\";\n } else if (Number.isNaN(Number(rangeValue?.from))) {\n numericValidation = \"invalid\";\n }\n\n if (rangeValue?.to === undefined || rangeValue?.to?.toString() === \"\") {\n rightValidation = \"required\";\n } else if (Number.isNaN(Number(rangeValue?.to))) {\n rightValidation = \"invalid\";\n } else if (Number(rangeValue?.from) > Number(rangeValue?.to)) {\n rightValidation = \"greaterThan\";\n } else if (Number(rangeValue?.from) === Number(rangeValue?.to)) {\n rightValidation = \"equal\";\n }\n }\n }\n\n const numericStatus = numericValidation != null ? \"invalid\" : \"valid\";\n const rightStatus = rightValidation != null ? \"invalid\" : \"valid\";\n\n const renderRangeInputs = (rangeValue: HvQueryBuilderNumericRange) => (\n <div\n className={cx(classes.rangeContainer, { [classes.isMdDown]: isMdDown })}\n >\n <div className={classes.inputContainer}>\n <HvInput\n label={labels.rule.value.numeric.range.leftLabel}\n className={classes.input}\n id={`${elementId}-numeric-from`}\n name={`${elementId}-numeric-from`}\n value={rangeValue?.from?.toString() || \"\"}\n onChange={(event, data) => onRangeValueChange(event, data)}\n onBlur={() => {\n setTouchedNumeric(true);\n }}\n onKeyDown={(e: any) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n }\n }}\n status={!touchedNumeric ? \"standBy\" : numericStatus}\n statusMessage={\n numericValidation\n ? labels.rule.value.numeric.validation[numericValidation]\n : \"\"\n }\n required\n inputProps={{\n autoComplete: \"off\",\n }}\n placeholder={labels.rule.value.numeric.placeholder}\n readOnly={readOnly}\n />\n </div>\n <div className={classes.inputContainer}>\n <HvInput\n label={labels.rule.value.numeric.range.rightLabel}\n className={classes.input}\n id={`${elementId}-numeric-to`}\n name={`${elementId}-numeric-to`}\n value={rangeValue?.to?.toString() || \"\"}\n onChange={(event, data) => onRangeValueChange(event, data, false)}\n onBlur={() => {\n setTouchedNumericTo(true);\n }}\n onKeyDown={(e: any) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n }\n }}\n status={!touchedNumericTo ? \"standBy\" : rightStatus}\n statusMessage={\n rightValidation\n ? labels.rule.value.numeric.validation[rightValidation]\n : \"\"\n }\n required\n inputProps={{\n autoComplete: \"off\",\n }}\n placeholder={labels.rule.value.numeric.placeholder}\n readOnly={readOnly}\n />\n </div>\n </div>\n );\n\n return (\n <div className={classes.root}>\n {isRange && renderRangeInputs(value || {})}\n {!isRange && (\n <div className={classes.inputContainer}>\n <HvInput\n label={labels.rule.value.numeric.label}\n className={classes.input}\n id={`${elementId}-numeric`}\n name={`${elementId}-numeric`}\n value={value?.toString() || \"\"}\n onChange={onSingleValueChange}\n onBlur={() => {\n setTouchedNumeric(true);\n }}\n onKeyDown={(e: any) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n }\n }}\n status={!touchedNumeric ? \"standBy\" : numericStatus}\n required\n inputProps={{\n autoComplete: \"off\",\n }}\n placeholder={labels.rule.value.numeric.placeholder}\n statusMessage={\n numericValidation\n ? labels.rule.value.numeric.validation[numericValidation]\n : \"\"\n }\n readOnly={readOnly}\n />\n </div>\n )}\n </div>\n );\n};\n\nexport default memo(NumericValue);\n"],"names":[],"mappings":";;;;;;;;AAiBO,MAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB;AACnB,MAAyB;AACvB,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW;AAEnC,QAAM,UAAU,aAAa;AAC7B,QAAM,EAAE,QAAQ,gBAAgB,aAAa,uBAAuB;AAEpE,QAAM,QAAQ;AAEd,QAAM,WAAW,cAAc,MAAM,YAAY,KAAK,IAAI,CAAC;AAE3D,QAAM,sBAAsB;AAAA,IAC1B,CAAC,GAAG,SAAiB;AACnB,YAAM,cAAc,CAAC,OAAO,OAAO,OAAO,IAAI;AAC/B,qBAAA;AAAA,QACb,MAAM;AAAA,QACN;AAAA,QACA,OAAO,OAAO,MAAM,WAAW,IAAI,OAAO;AAAA,MAAA,CAC3C;AAAA,IACH;AAAA,IACA,CAAC,gBAAgB,EAAE;AAAA,EAAA;AAGrB,QAAM,qBAAqB;AAAA,IACzB,CAAC,GAAG,MAAc,OAA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YAAY;AAAA,QACtC,UAAQ;AAAA,QACR,YAAY;AAAA,UACV,cAAc;AAAA,QAChB;AAAA,QACA,aAAa,OAAO,KAAK,MAAM,QAAQ;AAAA,QACvC,eACE,oBACI,OAAO,KAAK,MAAM,QAAQ,WAAW,iBAAiB,IACtD;AAAA,QAEN;AAAA,MAAA;AAAA,IAAA,GAEJ;AAAA,EAEJ,EAAA,CAAA;AAEJ;AAEe,KAAK,YAAY;"}
|
|
@@ -2,7 +2,7 @@ import { jsx } from "@emotion/react/jsx-runtime";
|
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import Slide from "@mui/material/Slide";
|
|
4
4
|
import Snackbar from "@mui/material/Snackbar";
|
|
5
|
-
import capitalize from "
|
|
5
|
+
import { capitalize } from "../utils/helpers.js";
|
|
6
6
|
import { setId } from "../utils/setId.js";
|
|
7
7
|
import { useClasses } from "./Snackbar.styles.js";
|
|
8
8
|
import { staticClasses } from "./Snackbar.styles.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Snackbar.js","sources":["../../../src/Snackbar/Snackbar.tsx"],"sourcesContent":["import { SyntheticEvent, useCallback } from \"react\";\nimport Slide, { SlideProps } from \"@mui/material/Slide\";\nimport MuiSnackbar, {\n SnackbarCloseReason,\n SnackbarOrigin,\n SnackbarProps as MuiSnackbarProps,\n} from \"@mui/material/Snackbar\";\nimport capitalize from \"
|
|
1
|
+
{"version":3,"file":"Snackbar.js","sources":["../../../src/Snackbar/Snackbar.tsx"],"sourcesContent":["import { SyntheticEvent, useCallback } from \"react\";\nimport Slide, { SlideProps } from \"@mui/material/Slide\";\nimport MuiSnackbar, {\n SnackbarCloseReason,\n SnackbarOrigin,\n SnackbarProps as MuiSnackbarProps,\n} from \"@mui/material/Snackbar\";\n\nimport { capitalize } from \"../utils/helpers\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { setId } from \"../utils/setId\";\nimport { HvActionGeneric, HvActionsGenericProps } from \"../ActionsGeneric\";\nimport { HvSnackbarContentProps, HvSnackbarContent } from \"./SnackbarContent\";\nimport { staticClasses, useClasses } from \"./Snackbar.styles\";\nimport { HvSnackbarVariant } from \"./types\";\n\nexport { staticClasses as snackbarClasses };\n\nexport type HvSnackbarClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSnackbarProps\n extends Omit<MuiSnackbarProps, \"action\" | \"classes\" | \"children\"> {\n /** If true, Snackbar is open. */\n open?: boolean;\n /**\n * Callback fired when the component requests to be closed.\n * Typically onClose is used to set state in the parent component, which is used to control the Snackbar open prop.\n * The reason parameter can optionally be used to control the response to onClose, for example ignoring click away.\n * */\n onClose?:\n | ((\n event: Event | SyntheticEvent<any, Event>,\n reason: SnackbarCloseReason\n ) => void)\n | undefined;\n /** The message to display. */\n label?: React.ReactNode;\n /**\n * The anchor of the Snackbar. vertical: \"top\", \"bottom\" | horizontal: \"left\", \"center\", \"right\".\n * It defines where the snackbar will end his animation */\n anchorOrigin?: SnackbarOrigin;\n /** The number of milliseconds to wait before automatically calling the onClose function. onClose should then set the state of the open prop to hide the Snackbar */\n autoHideDuration?: number;\n /** Variant of the snackbar. */\n variant?: HvSnackbarVariant;\n /** Custom icon to replace the variant default. */\n customIcon?: React.ReactNode;\n /** Controls if the associated icon to the variant should be shown. */\n showIcon?: boolean;\n /** Action to display. */\n action?: React.ReactNode | HvActionGeneric;\n /**\n * The callback function called when an action is triggered, receiving `action` as parameter.\n *\n * @deprecated Use `onAction` instead.\n * */\n actionCallback?: HvActionsGenericProps[\"actionsCallback\"];\n /** The callback function called when an action is triggered, receiving `action` as parameter. */\n onAction?: HvActionsGenericProps[\"onAction\"];\n /** Duration of transition in milliseconds. */\n transitionDuration?: number;\n /** Direction of slide transition. */\n transitionDirection?: \"up\" | \"down\" | \"left\" | \"right\";\n /** The container the snackbar should slide from. */\n container?: SlideProps[\"container\"];\n /** Custom offset from top/bottom of the page, in px. */\n offset?: number;\n /** Others applied to the content of the snackbar. */\n snackbarContentProps?: HvSnackbarContentProps;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvSnackbarClasses;\n /** @ignore */\n ref?: MuiSnackbarProps[\"ref\"];\n}\n\n/**\n * A Snackbar provides brief messages about app processes.\n * It is dismissed automatically after a given interval.\n *\n * Snackbar can be built with two different components.\n * One is the HvSnackbar, which wraps all the positioning, transition, auto hide, etc.\n * The other is the HvSnackbarContent, which allows a finer control and customization of the content of the Snackbar.\n */\nexport const HvSnackbar = ({\n classes: classesProp,\n className,\n id,\n open = false,\n onClose,\n label = \"\",\n anchorOrigin = { vertical: \"top\", horizontal: \"right\" },\n autoHideDuration = 5000,\n variant = \"default\",\n showIcon = false,\n customIcon = null,\n action = null,\n actionCallback, // TODO - remove in v6\n onAction,\n transitionDuration = 300,\n transitionDirection = \"left\",\n container,\n offset = 60,\n snackbarContentProps,\n ...others\n}: HvSnackbarProps) => {\n const { classes } = useClasses(classesProp);\n\n const anchorOriginOffset = {\n anchorOriginTop: {\n top: `${offset}px`,\n },\n anchorOriginBottom: {\n bottom: `${offset}px`,\n },\n };\n\n const SlideTransition = useCallback<\n NonNullable<MuiSnackbarProps[\"TransitionComponent\"]>\n >(\n (properties) => (\n <Slide\n {...properties}\n container={container}\n direction={transitionDirection}\n />\n ),\n [container, transitionDirection]\n );\n\n return (\n <MuiSnackbar\n style={\n anchorOriginOffset[`anchorOrigin${capitalize(anchorOrigin.vertical)}`]\n }\n classes={classes}\n className={className}\n id={id}\n anchorOrigin={anchorOrigin}\n open={open}\n onClose={onClose}\n autoHideDuration={autoHideDuration}\n transitionDuration={transitionDuration}\n TransitionComponent={SlideTransition}\n {...others}\n >\n <HvSnackbarContent\n id={setId(id, \"content\")}\n label={label}\n variant={variant}\n customIcon={customIcon}\n showIcon={showIcon}\n action={action}\n actionCallback={actionCallback}\n onAction={onAction}\n {...snackbarContentProps}\n />\n </MuiSnackbar>\n );\n};\n"],"names":["MuiSnackbar"],"mappings":";;;;;;;;;AAmFO,MAAM,aAAa,CAAC;AAAA,EACzB,SAA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import { jsx, jsxs, Fragment } from "@emotion/react/jsx-runtime";
|
|
|
2
2
|
import React__default, { useRef, useMemo, useCallback } from "react";
|
|
3
3
|
import { useTheme } from "@mui/material/styles";
|
|
4
4
|
import MuiDivider from "@mui/material/Divider";
|
|
5
|
-
import isString from "lodash/isString";
|
|
6
|
-
import isBoolean from "lodash/isBoolean";
|
|
7
5
|
import { useWidth } from "../hooks/useWidth.js";
|
|
8
6
|
import { useDefaultProps } from "../hooks/useDefaultProps.js";
|
|
9
7
|
import { useClasses } from "./Stack.styles.js";
|
|
10
8
|
import { staticClasses } from "./Stack.styles.js";
|
|
11
9
|
import { HvFocus } from "../Focus/Focus.js";
|
|
12
10
|
const getDirection = (direction, width, breakpoints) => {
|
|
13
|
-
if (
|
|
11
|
+
if (typeof direction === "string")
|
|
14
12
|
return direction;
|
|
15
13
|
for (let i = breakpoints.indexOf(width); i >= 0; i -= 1) {
|
|
16
14
|
if (direction[breakpoints[i]] !== void 0) {
|
|
@@ -40,7 +38,7 @@ const HvStack = (props) => {
|
|
|
40
38
|
[direction, width, breakpoints]
|
|
41
39
|
);
|
|
42
40
|
const getDividerComponent = useCallback(() => {
|
|
43
|
-
if (
|
|
41
|
+
if (typeof divider === "boolean" && divider) {
|
|
44
42
|
return /* @__PURE__ */ jsx(
|
|
45
43
|
MuiDivider,
|
|
46
44
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stack.js","sources":["../../../src/Stack/Stack.tsx"],"sourcesContent":["import React, { useMemo, useRef, useCallback } from \"react\";\n\nimport { useTheme } from \"@mui/material/styles\";\nimport MuiDivider, {\n DividerProps as MuiDividerProps,\n} from \"@mui/material/Divider\";\n\nimport
|
|
1
|
+
{"version":3,"file":"Stack.js","sources":["../../../src/Stack/Stack.tsx"],"sourcesContent":["import React, { useMemo, useRef, useCallback } from \"react\";\n\nimport { useTheme } from \"@mui/material/styles\";\nimport MuiDivider, {\n DividerProps as MuiDividerProps,\n} from \"@mui/material/Divider\";\n\nimport { HvBreakpoints } from \"@hitachivantara/uikit-styles\";\n\nimport { useWidth } from \"../hooks/useWidth\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { HvFocus } from \"../Focus\";\nimport { ExtractNames } from \"../utils/classes\";\n\nimport { useClasses, staticClasses } from \"./Stack.styles\";\n\nexport { staticClasses as stackClasses };\n\nexport type HvStackClasses = ExtractNames<typeof useClasses>;\n\nexport type HvStackDirection = \"column\" | \"row\" | Partial<HvStackBreakpoints>;\nexport interface HvStackBreakpoints extends Record<HvBreakpoints, string> {}\n\nexport interface HvStackProps extends HvBaseProps {\n /** The direction of the stack. Can be either a string or an object that states the direction for each breakpoint. */\n direction?: HvStackDirection;\n /** The spacing between elements of the stack. */\n spacing?: HvBreakpoints;\n /** The divider component to be used between the stack elements.\n * - If `true` the Material-UI Divider component will be used.\n * - If a React node is passed then the custom divider will be used.\n */\n divider?: boolean | React.ReactNode;\n /** The properties to pass on to the Material-UI component. */\n dividerProps?: MuiDividerProps;\n /** Sets whether or not there should be arrow navigation between the stack elements. */\n withNavigation?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvStackClasses;\n}\n\n/**\n * @returns {string} - Returns a direction for the stack: column or row. If the\n * `direction` property is a string and a valid direction then we\n * use it. If it's an object with multiple directions by breakpoint\n * we use the appropriate one or search for the nearest breakpoint\n * smaller than the current one to use.\n */\nconst getDirection = (direction: any, width: any, breakpoints: any) => {\n if (typeof direction === \"string\") return direction;\n\n for (let i = breakpoints.indexOf(width); i >= 0; i -= 1) {\n if (direction[breakpoints[i]] !== undefined) {\n return direction[breakpoints[i]];\n }\n }\n return \"column\";\n};\n\n/**\n * A Stack component allows the organization of its children in a vertical or horizontal layout.\n *\n * It also allows the specification of the spacing between the stack elements and the addition of a divider between the elements.\n */\nexport const HvStack = (props: HvStackProps) => {\n const {\n classes: classesProp,\n className,\n children,\n direction = \"column\",\n spacing = \"sm\",\n divider = false,\n withNavigation = false,\n dividerProps = {},\n ...others\n } = useDefaultProps(\"HvStack\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const width = useWidth();\n const containerRef = useRef(null);\n const { breakpoints } = useTheme();\n\n const processedDirection = useMemo(\n () => getDirection(direction, width, breakpoints.keys),\n [direction, width, breakpoints]\n );\n\n /**\n * @returns {node} - The divider component to use. If the property `divider` is\n * set to `true` then the Material-UI divider is used, otherwise\n * we use the custom divider the user passed.\n */\n const getDividerComponent = useCallback(() => {\n if (typeof divider === \"boolean\" && divider) {\n return (\n <MuiDivider\n orientation={\n processedDirection === \"column\" ? \"horizontal\" : \"vertical\"\n }\n flexItem={processedDirection === \"row\"}\n role=\"separator\"\n {...dividerProps}\n />\n );\n }\n return divider;\n }, [divider, dividerProps, processedDirection]);\n\n return (\n <div\n ref={containerRef}\n className={cx(\n classes.root,\n classes[processedDirection],\n classes[spacing],\n className\n )}\n {...others}\n >\n {React.Children.map(children, (child, i) => {\n return (\n <>\n {divider && i !== 0 && getDividerComponent()}\n {withNavigation ? (\n <HvFocus\n rootRef={containerRef}\n focusDisabled={false}\n strategy=\"grid\"\n navigationJump={\n processedDirection === \"column\"\n ? 1\n : React.Children.count(children) || 0\n }\n filterClass=\"child\"\n >\n <div className=\"child\">{child}</div>\n </HvFocus>\n ) : (\n child\n )}\n </>\n );\n })}\n </div>\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;;AAiDA,MAAM,eAAe,CAAC,WAAgB,OAAY,gBAAqB;AACrE,MAAI,OAAO,cAAc;AAAiB,WAAA;AAEjC,WAAA,IAAI,YAAY,QAAQ,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG;AACvD,QAAI,UAAU,YAAY,CAAC,CAAC,MAAM,QAAW;AACpC,aAAA,UAAU,YAAY,CAAC,CAAC;AAAA,IACjC;AAAA,EACF;AACO,SAAA;AACT;AAOa,MAAA,UAAU,CAAC,UAAwB;AACxC,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,I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WAAU,SAAS,UAAM,OAAA;AAAA,YAAA;AAAA,UAAA,IAGhC;AAAA,QAEJ,EAAA,CAAA;AAAA,MAAA,CAEH;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useContext } from "react";
|
|
3
|
-
import capitalize from "
|
|
3
|
+
import { capitalize } from "../../utils/helpers.js";
|
|
4
4
|
import { useDefaultProps } from "../../hooks/useDefaultProps.js";
|
|
5
5
|
import TableContext from "../TableContext.js";
|
|
6
6
|
import TableSectionContext from "../TableSectionContext.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableCell.js","sources":["../../../../src/Table/TableCell/TableCell.tsx"],"sourcesContent":["import { CSSProperties, forwardRef, TdHTMLAttributes, useContext } from \"react\";\nimport capitalize from \"
|
|
1
|
+
{"version":3,"file":"TableCell.js","sources":["../../../../src/Table/TableCell/TableCell.tsx"],"sourcesContent":["import { CSSProperties, forwardRef, TdHTMLAttributes, useContext } from \"react\";\n\nimport { capitalize } from \"../../utils/helpers\";\nimport { ExtractNames } from \"../../utils/classes\";\nimport { useDefaultProps } from \"../../hooks/useDefaultProps\";\n\nimport {\n HvTableCellAlign,\n HvTableCellType,\n HvTableCellVariant,\n} from \"../Table\";\nimport TableContext from \"../TableContext\";\nimport TableSectionContext from \"../TableSectionContext\";\nimport { staticClasses, useClasses } from \"./TableCell.styles\";\n\nexport { staticClasses as tableCellClasses };\n\nexport type HvTableCellClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTableCellProps\n extends Omit<TdHTMLAttributes<HTMLTableCellElement>, \"align\"> {\n /** The component used for the root node. Either a string to use a HTML element or a component. Defaults to td. */\n component?: React.ElementType;\n /** Content to be rendered */\n children?: React.ReactNode;\n /** Inline styles to be applied to the root element. */\n style?: CSSProperties;\n /** Set the text-align on the table cell content. */\n align?: HvTableCellAlign;\n /** Sets the cell's variant. */\n variant?: HvTableCellVariant | \"listcheckbox\" | \"listactions\";\n /** Specify the cell's type. The prop defaults to the value inherited from the parent TableHead, TableBody, or TableFooter components. */\n type?: HvTableCellType;\n /** Whether or not the cell is part of a sorted column. */\n sorted?: boolean;\n /** The cell is part of a sticky column. */\n stickyColumn?: boolean;\n /** The cell is part of the last sticky to the left column. */\n stickyColumnMostLeft?: boolean;\n /** The cell is part of the first sticky to the right column. */\n stickyColumnLeastRight?: boolean;\n /** The cell is part of the first column in the group. */\n groupColumnMostLeft?: boolean;\n /** The cell is part of the last column in the group. */\n groupColumnMostRight?: boolean;\n /** Whether or not the cell is resizable */\n resizable?: boolean;\n /** Whether or not the cell is being resized */\n resizing?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTableCellClasses;\n}\n\nconst defaultComponent = \"td\";\n\n/**\n * `HvTableCell` acts as a `td` element and inherits styles from its context\n */\nexport const HvTableCell = forwardRef<HTMLElement, HvTableCellProps>(\n (props, externalRef) => {\n const {\n children,\n component,\n className,\n style,\n classes: classesProp,\n align = \"inherit\",\n variant = \"default\",\n type: typeProp,\n stickyColumn = false,\n stickyColumnMostLeft = false,\n stickyColumnLeastRight = false,\n groupColumnMostLeft = false,\n groupColumnMostRight = false,\n sorted = false,\n resizable = false,\n resizing = false,\n ...others\n } = useDefaultProps(\"HvTableCell\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const tableContext = useContext(TableContext);\n const tableSectionContext = useContext(TableSectionContext);\n\n const type = typeProp || tableSectionContext?.type || \"body\";\n\n const Component =\n component || tableContext?.components?.Td || defaultComponent;\n\n return (\n <Component\n ref={externalRef}\n role={Component === defaultComponent ? null : \"cell\"}\n style={style}\n className={cx(\n classes.root,\n classes[type],\n {\n [classes[`align${capitalize(align)}`]]: align !== \"inherit\",\n [classes.variantList]: tableContext.variant === \"listrow\",\n [classes.variantListHead]:\n tableContext.variant === \"listrow\" && type !== \"body\",\n [classes[`variant${capitalize(variant)}`]]: variant !== \"default\",\n [classes.sorted]: sorted,\n [classes.stickyColumn]: stickyColumn,\n [classes.stickyColumnMostLeft]: stickyColumnMostLeft,\n [classes.stickyColumnLeastRight]: stickyColumnLeastRight,\n [classes.groupColumnMostLeft]: groupColumnMostLeft,\n [classes.groupColumnMostRight]: groupColumnMostRight,\n [classes.resizable]: resizable,\n [classes.resizing]: resizing,\n },\n className\n )}\n {...others}\n >\n {children}\n </Component>\n );\n }\n);\n"],"names":[],"mappings":";;;;;;;;AAqDA,MAAM,mBAAmB;AAKlB,MAAM,cAAc;AAAA,EACzB,CAAC,OAAO,gBAAgB;AAChB,UAAA;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,MAAM;AAAA,MACN,eAAe;AAAA,MACf,uBAAuB;AAAA,MACvB,yBAAyB;AAAA,MACzB,sBAAsB;AAAA,MACtB,uBAAuB;AAAA,MACvB,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,WAAW;AAAA,MACX,GAAG;AAAA,IAAA,IACD,gBAAgB,eAAe,KAAK;AAExC,UAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAExC,UAAA,eAAe,WAAW,YAAY;AACtC,UAAA,sBAAsB,WAAW,mBAAmB;AAEpD,UAAA,OAAO,YAAY,qBAAqB,QAAQ;AAEtD,UAAM,YACJ,aAAa,cAAc,YAAY,MAAM;AAG7C,WAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAK;AAAA,QACL,MAAM,cAAc,mBAAmB,OAAO;AAAA,QAC9C;AAAA,QACA,WAAW;AAAA,UACT,QAAQ;AAAA,UACR,QAAQ,IAAI;AAAA,UACZ;AAAA,YACE,CAAC,QAAQ,QAAQ,WAAW,KAAK,CAAC,EAAE,CAAC,GAAG,UAAU;AAAA,YAClD,CAAC,QAAQ,WAAW,GAAG,aAAa,YAAY;AAAA,YAChD,CAAC,QAAQ,eAAe,GACtB,aAAa,YAAY,aAAa,SAAS;AAAA,YACjD,CAAC,QAAQ,UAAU,WAAW,OAAO,CAAC,EAAE,CAAC,GAAG,YAAY;AAAA,YACxD,CAAC,QAAQ,MAAM,GAAG;AAAA,YAClB,CAAC,QAAQ,YAAY,GAAG;AAAA,YACxB,CAAC,QAAQ,oBAAoB,GAAG;AAAA,YAChC,CAAC,QAAQ,sBAAsB,GAAG;AAAA,YAClC,CAAC,QAAQ,mBAAmB,GAAG;AAAA,YAC/B,CAAC,QAAQ,oBAAoB,GAAG;AAAA,YAChC,CAAC,QAAQ,SAAS,GAAG;AAAA,YACrB,CAAC,QAAQ,QAAQ,GAAG;AAAA,UACtB;AAAA,UACA;AAAA,QACF;AAAA,QACC,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useContext, useMemo } from "react";
|
|
3
|
-
import capitalize from "lodash/capitalize";
|
|
4
3
|
import { alpha, hexToRgb } from "@mui/material/styles";
|
|
5
4
|
import { theme } from "@hitachivantara/uikit-styles";
|
|
6
5
|
import { useTheme } from "../../hooks/useTheme.js";
|
|
6
|
+
import { capitalize } from "../../utils/helpers.js";
|
|
7
7
|
import { useDefaultProps } from "../../hooks/useDefaultProps.js";
|
|
8
8
|
import TableContext from "../TableContext.js";
|
|
9
9
|
import TableSectionContext from "../TableSectionContext.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableHeader.js","sources":["../../../../src/Table/TableHeader/TableHeader.tsx"],"sourcesContent":["import {\n forwardRef,\n HTMLAttributes,\n ThHTMLAttributes,\n useContext,\n useMemo,\n} from \"react\";\
|
|
1
|
+
{"version":3,"file":"TableHeader.js","sources":["../../../../src/Table/TableHeader/TableHeader.tsx"],"sourcesContent":["import {\n forwardRef,\n HTMLAttributes,\n ThHTMLAttributes,\n useContext,\n useMemo,\n} from \"react\";\nimport { hexToRgb, alpha } from \"@mui/material/styles\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { HvTypography, HvTypographyProps } from \"../../Typography\";\nimport { useTheme } from \"../../hooks/useTheme\";\nimport { ExtractNames } from \"../../utils/classes\";\nimport { capitalize } from \"../../utils/helpers\";\nimport { HvButton, HvButtonProps } from \"../../Button\";\nimport { useDefaultProps } from \"../../hooks/useDefaultProps\";\n\nimport TableContext from \"../TableContext\";\nimport TableSectionContext from \"../TableSectionContext\";\nimport { getSortIcon, isParagraph } from \"./utils\";\nimport { useClasses, staticClasses } from \"./TableHeader.styles\";\nimport {\n HvTableCellAlign,\n HvTableCellType,\n HvTableCellVariant,\n} from \"../Table\";\n\nexport { staticClasses as tableHeaderClasses };\n\nexport type HvTableHeaderClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTableHeaderProps\n extends Omit<ThHTMLAttributes<HTMLTableCellElement>, \"align\"> {\n /** The component used for the root node. Either a string to use a HTML element or a component. Defaults to th. */\n component?: React.ElementType;\n /** Content to be rendered */\n children?: React.ReactNode;\n /** The scope of cells that the header element relates to. */\n scope?: \"col\" | \"row\" | \"colgroup\" | \"rowgroup\";\n /** Set the text-align on the table cell content. */\n align?: HvTableCellAlign;\n /** Sets the cell's variant. */\n variant?: HvTableCellVariant;\n /** Specify the cell type. The prop defaults to the value inherited from the parent TableHead, TableBody, or TableFooter components. */\n type?: HvTableCellType;\n /** The cell is part of a sticky column. */\n stickyColumn?: boolean;\n /** The cell is part of the last sticky to the left column. */\n stickyColumnMostLeft?: boolean;\n /** The cell is part of the first sticky to the right column. */\n stickyColumnLeastRight?: boolean;\n /** The cell is part of the first column in the group. */\n groupColumnMostLeft?: boolean;\n /** The cell is part of the last column in the group. */\n groupColumnMostRight?: boolean;\n /** Whether or not the cell is sorted */\n sorted?: boolean;\n /** Whether or not the cell is sortable */\n sortable?: boolean;\n /** Set sort direction icon and aria-sort. */\n sortDirection?: \"ascending\" | \"descending\" | false;\n /** Extra props to be passed onto the text in the header. */\n headerTextProps?: HvTypographyProps;\n /** Whether or not the cell is resizable */\n resizable?: boolean;\n /** Whether or not the cell is being resized */\n resizing?: boolean;\n /** The resize props injected in the resize handler */\n resizerProps?: HTMLAttributes<HTMLDivElement>;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTableHeaderClasses;\n /** Extra props to be passed onto the sort button in the header. */\n sortButtonProps?: HvButtonProps;\n}\n\nconst defaultComponent = \"th\";\n\n/**\n * `HvTableHeader` acts as a `th` element and inherits styles from its context\n */\nexport const HvTableHeader = forwardRef<HTMLElement, HvTableHeaderProps>(\n (props, externalRef) => {\n const {\n children,\n component,\n className,\n style: styleProp,\n classes: classesProp,\n scope: scopeProp,\n align = \"inherit\",\n variant = \"default\",\n type: typeProp,\n stickyColumn = false,\n stickyColumnMostLeft = false,\n stickyColumnLeastRight = false,\n groupColumnMostLeft = false,\n groupColumnMostRight = false,\n sortDirection = \"none\",\n sorted,\n sortable,\n headerTextProps,\n resizerProps = {},\n resizable = false,\n resizing = false,\n sortButtonProps,\n ...others\n } = useDefaultProps(\"HvTableHeader\", props);\n const { classes, cx, css } = useClasses(classesProp);\n\n const { colors } = useTheme();\n const tableContext = useContext(TableContext);\n const tableSectionContext = useContext(TableSectionContext);\n\n const type = typeProp || tableSectionContext?.type || \"body\";\n const isHeadCell = type === \"head\";\n\n const scope = scopeProp ?? (isHeadCell ? \"col\" : \"row\");\n\n const Sort = useMemo(\n () => getSortIcon(sorted && sortDirection),\n [sorted, sortDirection]\n );\n\n const Component =\n component || tableContext?.components?.Th || defaultComponent;\n\n const role =\n Component === defaultComponent\n ? null\n : isHeadCell\n ? \"columnheader\"\n : \"rowheader\";\n const paragraph = isParagraph(children);\n\n // Keep the header sticky\n const style = stickyColumn\n ? { ...styleProp, position: \"sticky\" }\n : styleProp;\n\n return (\n <Component\n ref={externalRef}\n role={role}\n scope={scope}\n style={style}\n className={cx(\n classes.root,\n classes[type],\n type === \"body\" &&\n css({\n [`&.${staticClasses.sorted}`]: {\n backgroundColor: alpha(\n hexToRgb(colors?.atmo1 || theme.colors.atmo1),\n 0.4\n ),\n },\n }),\n {\n [classes.groupColumnMostLeft]: groupColumnMostLeft,\n [classes.groupColumnMostRight]: groupColumnMostRight,\n [classes.sortable]: sortable,\n [classes.sorted]: sorted,\n [classes.resizable]: resizable,\n [classes.resizing]: resizing,\n [classes.stickyColumn]: stickyColumn,\n [classes.stickyColumnMostLeft]: stickyColumnMostLeft,\n [classes.stickyColumnLeastRight]: stickyColumnLeastRight,\n [classes.variantList]: tableContext.variant === \"listrow\",\n [classes[`align${capitalize(align)}`]]: align !== \"inherit\",\n [classes[`variant${capitalize(variant)}`]]: variant !== \"default\",\n },\n className\n )}\n aria-sort={sortable ? sortDirection : undefined}\n {...others}\n >\n <div\n className={cx(classes.headerContent, {\n [classes[`alignFlex${capitalize(align)}`]]: align !== \"inherit\",\n })}\n >\n {isHeadCell && sortable && (\n <HvButton\n className={classes.sortButton}\n icon\n overrideIconColors={false}\n aria-label=\"Sort\"\n {...sortButtonProps}\n >\n <Sort className={classes.sortIcon} />\n </HvButton>\n )}\n <HvTypography\n component=\"div\"\n className={cx({\n [classes.headerText]: !paragraph,\n [classes.headerParagraph]: paragraph,\n [classes.sortableHeaderText]: sortable,\n })}\n variant=\"label\"\n {...headerTextProps}\n >\n {children}\n </HvTypography>\n {resizable && <div {...resizerProps} className={classes.resizer} />}\n </div>\n </Component>\n );\n }\n);\n"],"names":[],"mappings":";;;;;;;;;;;;;AA4EA,MAAM,mBAAmB;AAKlB,MAAM,gBAAgB;AAAA,EAC3B,CAAC,OAAO,gBAAgB;AAChB,UAAA;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP,SAAS;AAAA,MACT,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,MAAM;AAAA,MACN,eAAe;AAAA,MACf,uBAAuB;A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BAAA;AAAA,cACH;AAAA,cACC,aAAc,oBAAA,OAAA,EAAK,GAAG,cAAc,WAAW,QAAQ,SAAS;AAAA,YAAA;AAAA,UAAA;AAAA,QACnE;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
class EventManager {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
this.events = {};
|
|
6
|
-
}
|
|
2
|
+
maxListeners = 20;
|
|
3
|
+
warnOnce = false;
|
|
4
|
+
events = {};
|
|
7
5
|
on(eventName, listener, options = {}) {
|
|
8
6
|
let collection = this.events[eventName];
|
|
9
7
|
if (!collection) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventManager.js","sources":["../../../../../src/TreeView/internals/utils/EventManager.ts"],"sourcesContent":["export type EventListener = (...args: any[]) => void;\n\nexport interface EventListenerOptions {\n isFirst?: boolean;\n}\n\ninterface EventListenerCollection {\n /**\n * List of listeners to run before the others\n * They are run in the opposite order of the registration order\n */\n highPriority: Map<EventListener, true>;\n /**\n * List of events to run after the high priority listeners\n * They are run in the registration order\n */\n regular: Map<EventListener, true>;\n}\n\n// Used https://gist.github.com/mudge/5830382 as a starting point.\n// See https://github.com/browserify/events/blob/master/events.js for\n// the Node.js (https://nodejs.org/api/events.html) polyfill used by webpack.\nexport class EventManager {\n maxListeners = 20;\n\n warnOnce = false;\n\n events: { [eventName: string]: EventListenerCollection } = {};\n\n on(\n eventName: string,\n listener: EventListener,\n options: EventListenerOptions = {}\n ): void {\n let collection = this.events[eventName];\n\n if (!collection) {\n collection = {\n highPriority: new Map(),\n regular: new Map(),\n };\n this.events[eventName] = collection;\n }\n\n if (options.isFirst) {\n collection.highPriority.set(listener, true);\n } else {\n collection.regular.set(listener, true);\n }\n }\n\n removeListener(eventName: string, listener: EventListener): void {\n if (this.events[eventName]) {\n this.events[eventName].regular.delete(listener);\n this.events[eventName].highPriority.delete(listener);\n }\n }\n\n removeAllListeners(): void {\n this.events = {};\n }\n\n emit(eventName: string, ...args: any[]): void {\n const collection = this.events[eventName];\n if (!collection) {\n return;\n }\n\n const highPriorityListeners = Array.from(collection.highPriority.keys());\n const regularListeners = Array.from(collection.regular.keys());\n\n for (let i = highPriorityListeners.length - 1; i >= 0; i -= 1) {\n const listener = highPriorityListeners[i];\n if (collection.highPriority.has(listener)) {\n listener.apply(this, args);\n }\n }\n\n for (let i = 0; i < regularListeners.length; i += 1) {\n const listener = regularListeners[i];\n if (collection.regular.has(listener)) {\n listener.apply(this, args);\n }\n }\n }\n\n once(eventName: string, listener: EventListener): void {\n // eslint-disable-next-line consistent-this\n const that = this;\n this.on(eventName, function oneTimeListener(...args) {\n that.removeListener(eventName, oneTimeListener);\n listener.apply(that, args);\n });\n }\n}\n"],"names":[],"mappings":"AAsBO,MAAM,aAAa;AAAA,
|
|
1
|
+
{"version":3,"file":"EventManager.js","sources":["../../../../../src/TreeView/internals/utils/EventManager.ts"],"sourcesContent":["export type EventListener = (...args: any[]) => void;\n\nexport interface EventListenerOptions {\n isFirst?: boolean;\n}\n\ninterface EventListenerCollection {\n /**\n * List of listeners to run before the others\n * They are run in the opposite order of the registration order\n */\n highPriority: Map<EventListener, true>;\n /**\n * List of events to run after the high priority listeners\n * They are run in the registration order\n */\n regular: Map<EventListener, true>;\n}\n\n// Used https://gist.github.com/mudge/5830382 as a starting point.\n// See https://github.com/browserify/events/blob/master/events.js for\n// the Node.js (https://nodejs.org/api/events.html) polyfill used by webpack.\nexport class EventManager {\n maxListeners = 20;\n\n warnOnce = false;\n\n events: { [eventName: string]: EventListenerCollection } = {};\n\n on(\n eventName: string,\n listener: EventListener,\n options: EventListenerOptions = {}\n ): void {\n let collection = this.events[eventName];\n\n if (!collection) {\n collection = {\n highPriority: new Map(),\n regular: new Map(),\n };\n this.events[eventName] = collection;\n }\n\n if (options.isFirst) {\n collection.highPriority.set(listener, true);\n } else {\n collection.regular.set(listener, true);\n }\n }\n\n removeListener(eventName: string, listener: EventListener): void {\n if (this.events[eventName]) {\n this.events[eventName].regular.delete(listener);\n this.events[eventName].highPriority.delete(listener);\n }\n }\n\n removeAllListeners(): void {\n this.events = {};\n }\n\n emit(eventName: string, ...args: any[]): void {\n const collection = this.events[eventName];\n if (!collection) {\n return;\n }\n\n const highPriorityListeners = Array.from(collection.highPriority.keys());\n const regularListeners = Array.from(collection.regular.keys());\n\n for (let i = highPriorityListeners.length - 1; i >= 0; i -= 1) {\n const listener = highPriorityListeners[i];\n if (collection.highPriority.has(listener)) {\n listener.apply(this, args);\n }\n }\n\n for (let i = 0; i < regularListeners.length; i += 1) {\n const listener = regularListeners[i];\n if (collection.regular.has(listener)) {\n listener.apply(this, args);\n }\n }\n }\n\n once(eventName: string, listener: EventListener): void {\n // eslint-disable-next-line consistent-this\n const that = this;\n this.on(eventName, function oneTimeListener(...args) {\n that.removeListener(eventName, oneTimeListener);\n listener.apply(that, args);\n });\n }\n}\n"],"names":[],"mappings":"AAsBO,MAAM,aAAa;AAAA,EACxB,eAAe;AAAA,EAEf,WAAW;AAAA,EAEX,SAA2D,CAAA;AAAA,EAE3D,GACE,WACA,UACA,UAAgC,CAAA,GAC1B;AACF,QAAA,aAAa,KAAK,OAAO,SAAS;AAEtC,QAAI,CAAC,YAAY;AACF,mBAAA;AAAA,QACX,kCAAkB,IAAI;AAAA,QACtB,6BAAa,IAAI;AAAA,MAAA;AAEd,WAAA,OAAO,SAAS,IAAI;AAAA,IAC3B;AAEA,QAAI,QAAQ,SAAS;AACR,iBAAA,aAAa,IAAI,UAAU,IAAI;AAAA,IAAA,OACrC;AACM,iBAAA,QAAQ,IAAI,UAAU,IAAI;AAAA,IACvC;AAAA,EACF;AAAA,EAEA,eAAe,WAAmB,UAA+B;AAC3D,QAAA,KAAK,OAAO,SAAS,GAAG;AAC1B,WAAK,OAAO,SAAS,EAAE,QAAQ,OAAO,QAAQ;AAC9C,WAAK,OAAO,SAAS,EAAE,aAAa,OAAO,QAAQ;AAAA,IACrD;AAAA,EACF;AAAA,EAEA,qBAA2B;AACzB,SAAK,SAAS;EAChB;AAAA,EAEA,KAAK,cAAsB,MAAmB;AACtC,UAAA,aAAa,KAAK,OAAO,SAAS;AACxC,QAAI,CAAC,YAAY;AACf;AAAA,IACF;AAEA,UAAM,wBAAwB,MAAM,KAAK,WAAW,aAAa,MAAM;AACvE,UAAM,mBAAmB,MAAM,KAAK,WAAW,QAAQ,MAAM;AAE7D,aAAS,IAAI,sBAAsB,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG;AACvD,YAAA,WAAW,sBAAsB,CAAC;AACxC,UAAI,WAAW,aAAa,IAAI,QAAQ,GAAG;AAChC,iBAAA,MAAM,MAAM,IAAI;AAAA,MAC3B;AAAA,IACF;AAEA,aAAS,IAAI,GAAG,IAAI,iBAAiB,QAAQ,KAAK,GAAG;AAC7C,YAAA,WAAW,iBAAiB,CAAC;AACnC,UAAI,WAAW,QAAQ,IAAI,QAAQ,GAAG;AAC3B,iBAAA,MAAM,MAAM,IAAI;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AAAA,EAEA,KAAK,WAAmB,UAA+B;AAErD,UAAM,OAAO;AACb,SAAK,GAAG,WAAW,SAAS,mBAAmB,MAAM;AAC9C,WAAA,eAAe,WAAW,eAAe;AACrC,eAAA,MAAM,MAAM,IAAI;AAAA,IAAA,CAC1B;AAAA,EACH;AACF;"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
class FinalizationRegistryBasedCleanupTracking {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
});
|
|
8
|
-
}
|
|
2
|
+
registry = new FinalizationRegistry((unsubscribe) => {
|
|
3
|
+
if (typeof unsubscribe === "function") {
|
|
4
|
+
unsubscribe();
|
|
5
|
+
}
|
|
6
|
+
});
|
|
9
7
|
register(object, unsubscribe, unregisterToken) {
|
|
10
8
|
this.registry.register(object, unsubscribe, unregisterToken);
|
|
11
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FinalizationRegistryBasedCleanupTracking.js","sources":["../../../../../src/TreeView/internals/utils/FinalizationRegistryBasedCleanupTracking.ts"],"sourcesContent":["import {\n CleanupTracking,\n UnsubscribeFn,\n UnregisterToken,\n} from \"./CleanupTracking\";\n\nexport class FinalizationRegistryBasedCleanupTracking\n implements CleanupTracking\n{\n registry = new FinalizationRegistry<UnsubscribeFn>((unsubscribe) => {\n if (typeof unsubscribe === \"function\") {\n unsubscribe();\n }\n });\n\n register(\n object: any,\n unsubscribe: UnsubscribeFn,\n unregisterToken: UnregisterToken\n ): void {\n this.registry.register(object, unsubscribe, unregisterToken);\n }\n\n unregister(unregisterToken: UnregisterToken): void {\n this.registry.unregister(unregisterToken);\n }\n\n // eslint-disable-next-line class-methods-use-this\n reset() {}\n}\n"],"names":[],"mappings":"AAMO,MAAM,yCAEb;AAAA,
|
|
1
|
+
{"version":3,"file":"FinalizationRegistryBasedCleanupTracking.js","sources":["../../../../../src/TreeView/internals/utils/FinalizationRegistryBasedCleanupTracking.ts"],"sourcesContent":["import {\n CleanupTracking,\n UnsubscribeFn,\n UnregisterToken,\n} from \"./CleanupTracking\";\n\nexport class FinalizationRegistryBasedCleanupTracking\n implements CleanupTracking\n{\n registry = new FinalizationRegistry<UnsubscribeFn>((unsubscribe) => {\n if (typeof unsubscribe === \"function\") {\n unsubscribe();\n }\n });\n\n register(\n object: any,\n unsubscribe: UnsubscribeFn,\n unregisterToken: UnregisterToken\n ): void {\n this.registry.register(object, unsubscribe, unregisterToken);\n }\n\n unregister(unregisterToken: UnregisterToken): void {\n this.registry.unregister(unregisterToken);\n }\n\n // eslint-disable-next-line class-methods-use-this\n reset() {}\n}\n"],"names":[],"mappings":"AAMO,MAAM,yCAEb;AAAA,EACE,WAAW,IAAI,qBAAoC,CAAC,gBAAgB;AAC9D,QAAA,OAAO,gBAAgB,YAAY;AACzB;IACd;AAAA,EAAA,CACD;AAAA,EAED,SACE,QACA,aACA,iBACM;AACN,SAAK,SAAS,SAAS,QAAQ,aAAa,eAAe;AAAA,EAC7D;AAAA,EAEA,WAAW,iBAAwC;AAC5C,SAAA,SAAS,WAAW,eAAe;AAAA,EAC1C;AAAA;AAAA,EAGA,QAAQ;AAAA,EAAC;AACX;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const CLEANUP_TIMER_LOOP_MILLIS = 1e3;
|
|
2
2
|
class TimerBasedCleanupTracking {
|
|
3
|
+
timeouts = /* @__PURE__ */ new Map();
|
|
4
|
+
cleanupTimeout = CLEANUP_TIMER_LOOP_MILLIS;
|
|
3
5
|
constructor(timeout = CLEANUP_TIMER_LOOP_MILLIS) {
|
|
4
|
-
this.timeouts = /* @__PURE__ */ new Map();
|
|
5
|
-
this.cleanupTimeout = CLEANUP_TIMER_LOOP_MILLIS;
|
|
6
6
|
this.cleanupTimeout = timeout;
|
|
7
7
|
}
|
|
8
8
|
register(object, unsubscribe, unregisterToken) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimerBasedCleanupTracking.js","sources":["../../../../../src/TreeView/internals/utils/TimerBasedCleanupTracking.ts"],"sourcesContent":["import {\n CleanupTracking,\n UnregisterToken,\n UnsubscribeFn,\n} from \"./CleanupTracking\";\n\n// If no effect ran after this amount of time, we assume that the render was not committed by React\nconst CLEANUP_TIMER_LOOP_MILLIS = 1000;\n\nexport class TimerBasedCleanupTracking implements CleanupTracking {\n timeouts? = new Map<number, NodeJS.Timeout>();\n\n cleanupTimeout = CLEANUP_TIMER_LOOP_MILLIS;\n\n constructor(timeout = CLEANUP_TIMER_LOOP_MILLIS) {\n this.cleanupTimeout = timeout;\n }\n\n register(\n object: any,\n unsubscribe: UnsubscribeFn,\n unregisterToken: UnregisterToken\n ): void {\n if (!this.timeouts) {\n this.timeouts = new Map<number, NodeJS.Timeout>();\n }\n\n const timeout = setTimeout(() => {\n if (typeof unsubscribe === \"function\") {\n unsubscribe();\n }\n this.timeouts!.delete(unregisterToken.cleanupToken);\n }, this.cleanupTimeout);\n\n this.timeouts!.set(unregisterToken!.cleanupToken, timeout);\n }\n\n unregister(unregisterToken: UnregisterToken): void {\n const timeout = this.timeouts!.get(unregisterToken.cleanupToken);\n if (timeout) {\n this.timeouts!.delete(unregisterToken.cleanupToken);\n clearTimeout(timeout);\n }\n }\n\n reset() {\n if (this.timeouts) {\n this.timeouts.forEach((value, key) => {\n this.unregister({ cleanupToken: key });\n });\n this.timeouts = undefined;\n }\n }\n}\n"],"names":[],"mappings":"AAOA,MAAM,4BAA4B;AAE3B,MAAM,0BAAqD;AAAA,
|
|
1
|
+
{"version":3,"file":"TimerBasedCleanupTracking.js","sources":["../../../../../src/TreeView/internals/utils/TimerBasedCleanupTracking.ts"],"sourcesContent":["import {\n CleanupTracking,\n UnregisterToken,\n UnsubscribeFn,\n} from \"./CleanupTracking\";\n\n// If no effect ran after this amount of time, we assume that the render was not committed by React\nconst CLEANUP_TIMER_LOOP_MILLIS = 1000;\n\nexport class TimerBasedCleanupTracking implements CleanupTracking {\n timeouts? = new Map<number, NodeJS.Timeout>();\n\n cleanupTimeout = CLEANUP_TIMER_LOOP_MILLIS;\n\n constructor(timeout = CLEANUP_TIMER_LOOP_MILLIS) {\n this.cleanupTimeout = timeout;\n }\n\n register(\n object: any,\n unsubscribe: UnsubscribeFn,\n unregisterToken: UnregisterToken\n ): void {\n if (!this.timeouts) {\n this.timeouts = new Map<number, NodeJS.Timeout>();\n }\n\n const timeout = setTimeout(() => {\n if (typeof unsubscribe === \"function\") {\n unsubscribe();\n }\n this.timeouts!.delete(unregisterToken.cleanupToken);\n }, this.cleanupTimeout);\n\n this.timeouts!.set(unregisterToken!.cleanupToken, timeout);\n }\n\n unregister(unregisterToken: UnregisterToken): void {\n const timeout = this.timeouts!.get(unregisterToken.cleanupToken);\n if (timeout) {\n this.timeouts!.delete(unregisterToken.cleanupToken);\n clearTimeout(timeout);\n }\n }\n\n reset() {\n if (this.timeouts) {\n this.timeouts.forEach((value, key) => {\n this.unregister({ cleanupToken: key });\n });\n this.timeouts = undefined;\n }\n }\n}\n"],"names":[],"mappings":"AAOA,MAAM,4BAA4B;AAE3B,MAAM,0BAAqD;AAAA,EAChE,+BAAgB;EAEhB,iBAAiB;AAAA,EAEjB,YAAY,UAAU,2BAA2B;AAC/C,SAAK,iBAAiB;AAAA,EACxB;AAAA,EAEA,SACE,QACA,aACA,iBACM;AACF,QAAA,CAAC,KAAK,UAAU;AACb,WAAA,+BAAe;IACtB;AAEM,UAAA,UAAU,WAAW,MAAM;AAC3B,UAAA,OAAO,gBAAgB,YAAY;AACzB;MACd;AACK,WAAA,SAAU,OAAO,gBAAgB,YAAY;AAAA,IAAA,GACjD,KAAK,cAAc;AAEtB,SAAK,SAAU,IAAI,gBAAiB,cAAc,OAAO;AAAA,EAC3D;AAAA,EAEA,WAAW,iBAAwC;AACjD,UAAM,UAAU,KAAK,SAAU,IAAI,gBAAgB,YAAY;AAC/D,QAAI,SAAS;AACN,WAAA,SAAU,OAAO,gBAAgB,YAAY;AAClD,mBAAa,OAAO;AAAA,IACtB;AAAA,EACF;AAAA,EAEA,QAAQ;AACN,QAAI,KAAK,UAAU;AACjB,WAAK,SAAS,QAAQ,CAAC,OAAO,QAAQ;AACpC,aAAK,WAAW,EAAE,cAAc,IAAK,CAAA;AAAA,MAAA,CACtC;AACD,WAAK,WAAW;AAAA,IAClB;AAAA,EACF;AACF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Typography.js","sources":["../../../src/Typography/Typography.tsx"],"sourcesContent":["import {\n fixedForwardRef,\n PolymorphicComponentRef,\n PolymorphicRef,\n} from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { useTheme } from \"../hooks/useTheme\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport {\n HvTypographyLegacyVariants,\n HvTypographyVariants,\n mapVariant,\n} from \"./utils\";\nimport { staticClasses, useClasses } from \"./Typography.styles\";\n\nexport { staticClasses as typographyClasses };\n\nexport type HvTypographyClasses = ExtractNames<typeof useClasses>;\n\nconst HvTypographyMap = {\n display: \"h1\",\n title1: \"h1\",\n title2: \"h2\",\n title3: \"h3\",\n title4: \"h4\",\n body: \"p\",\n label: \"span\",\n caption1: \"p\",\n caption2: \"p\",\n // LEGACY\n \"5xlTitle\": \"h1\",\n \"4xlTitle\": \"h1\",\n \"3xlTitle\": \"h1\",\n xxlTitle: \"h1\",\n xlTitle: \"h1\",\n lTitle: \"h2\",\n mTitle: \"h3\",\n sTitle: \"h4\",\n xsTitle: \"h5\",\n xxsTitle: \"h6\",\n sectionTitle: \"p\",\n highlightText: \"p\",\n normalText: \"p\",\n placeholderText: \"p\",\n link: \"p\",\n disabledText: \"p\",\n selectedNavText: \"p\",\n vizText: \"p\",\n vizTextDisabled: \"p\",\n xsInlineLink: \"p\",\n} satisfies Record<\n HvTypographyVariants | HvTypographyLegacyVariants,\n React.ElementType\n>;\n\nexport type HvTypographyProps<C extends React.ElementType = \"p\"> =\n PolymorphicComponentRef<\n C,\n {\n /** Use the variant prop to change the visual style of the Typography. */\n variant?: HvTypographyVariants | HvTypographyLegacyVariants;\n /** If `true` the typography will display the look of a link. */\n link?: boolean;\n /** If `true` the typography will display the look of a disabled state. */\n disabled?: boolean;\n /**\n * If `true`, the typography will render a \"p\" element\n * @deprecated use `component=\"p\"` instead\n * */\n paragraph?: boolean;\n /**\n * If `true`, the text will not wrap, but instead will truncate with a text overflow ellipsis.\n *\n * Note that text overflow can only happen with block or inline-block level elements\n * (the element needs to have a width in order to overflow).\n */\n noWrap?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTypographyClasses;\n }\n >;\n\n/**\n * Typography component is used to render text and paragraphs within an interface.\n */\nexport const HvTypography = fixedForwardRef(function HvTypography<\n C extends React.ElementType = \"p\"\n>(props: HvTypographyProps<C>, ref: PolymorphicRef<C>) {\n const {\n className,\n component: ComponentProp,\n classes: classesProp,\n variant: variantProp = \"body\",\n link = false,\n noWrap = false,\n paragraph = false,\n disabled = false,\n ...others\n } = useDefaultProps(\"HvTypography\", props);\n const { classes, cx } = useClasses(classesProp);\n const { activeTheme } = useTheme();\n\n const variant = mapVariant(variantProp, activeTheme?.name);\n\n const Component =\n ComponentProp || (paragraph && \"p\") || HvTypographyMap[variant] || \"span\";\n\n return (\n <Component\n ref={ref}\n className={cx(\n classes.root,\n classes[variant],\n {\n [classes.isLink]: link,\n [classes.noWrap]: noWrap,\n [classes.disabled]: disabled,\n },\n className\n )}\n disabled={disabled}\n {...others}\n />\n );\n});\n"],"names":["HvTypography"],"mappings":";;;;;;;AAmBA,MAAM,kBAAkB;AAAA,EACtB,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,UAAU;AAAA;AAAA,EAEV,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,cAAc;AAAA,EACd,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,MAAM;AAAA,EACN,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,cAAc;AAChB;AAmCO,MAAM,eAAe,gBAAgB,SAASA,cAEnD,OAA6B,KAAwB;AAC/C,QAAA;AAAA,IACJ;AAAA,IACA,WAAW;AAAA,IACX,SAAS;AAAA,IACT,SAAS,cAAc;AAAA,IACvB,OAAO;AAAA,IACP,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,GAAG;AAAA,EAAA,IACD,gBAAgB,gBAAgB,KAAK;AACzC,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AACxC,QAAA,EAAE,gBAAgB;AAExB,QAAM,UAAU,WAAW,aAAa,aAAa,IAAI;AAEzD,QAAM,YACJ,iBAAkB,aAAa,OAAQ,gBAAgB,OAAO,KAAK;AAGnE,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,WAAW;AAAA,QACT,QAAQ;AAAA,QACR,QAAQ,OAAO;AAAA,QACf;AAAA,UACE,CAAC,QAAQ,MAAM,GAAG;AAAA,UAClB,CAAC,QAAQ,MAAM,GAAG;AAAA,UAClB,CAAC,QAAQ,QAAQ,GAAG;AAAA,QACtB;AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;"}
|
|
1
|
+
{"version":3,"file":"Typography.js","sources":["../../../src/Typography/Typography.tsx"],"sourcesContent":["import {\n fixedForwardRef,\n PolymorphicComponentRef,\n PolymorphicRef,\n} from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { useTheme } from \"../hooks/useTheme\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport {\n HvTypographyLegacyVariants,\n HvTypographyVariants,\n mapVariant,\n} from \"./utils\";\nimport { staticClasses, useClasses } from \"./Typography.styles\";\n\nexport { staticClasses as typographyClasses };\n\nexport type HvTypographyClasses = ExtractNames<typeof useClasses>;\n\nconst HvTypographyMap = {\n display: \"h1\",\n title1: \"h1\",\n title2: \"h2\",\n title3: \"h3\",\n title4: \"h4\",\n body: \"p\",\n label: \"span\",\n captionLabel: \"p\",\n caption1: \"p\",\n caption2: \"p\",\n // LEGACY\n \"5xlTitle\": \"h1\",\n \"4xlTitle\": \"h1\",\n \"3xlTitle\": \"h1\",\n xxlTitle: \"h1\",\n xlTitle: \"h1\",\n lTitle: \"h2\",\n mTitle: \"h3\",\n sTitle: \"h4\",\n xsTitle: \"h5\",\n xxsTitle: \"h6\",\n sectionTitle: \"p\",\n highlightText: \"p\",\n normalText: \"p\",\n placeholderText: \"p\",\n link: \"p\",\n disabledText: \"p\",\n selectedNavText: \"p\",\n vizText: \"p\",\n vizTextDisabled: \"p\",\n xsInlineLink: \"p\",\n} satisfies Record<\n HvTypographyVariants | HvTypographyLegacyVariants,\n React.ElementType\n>;\n\nexport type HvTypographyProps<C extends React.ElementType = \"p\"> =\n PolymorphicComponentRef<\n C,\n {\n /** Use the variant prop to change the visual style of the Typography. */\n variant?: HvTypographyVariants | HvTypographyLegacyVariants;\n /** If `true` the typography will display the look of a link. */\n link?: boolean;\n /** If `true` the typography will display the look of a disabled state. */\n disabled?: boolean;\n /**\n * If `true`, the typography will render a \"p\" element\n * @deprecated use `component=\"p\"` instead\n * */\n paragraph?: boolean;\n /**\n * If `true`, the text will not wrap, but instead will truncate with a text overflow ellipsis.\n *\n * Note that text overflow can only happen with block or inline-block level elements\n * (the element needs to have a width in order to overflow).\n */\n noWrap?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTypographyClasses;\n }\n >;\n\n/**\n * Typography component is used to render text and paragraphs within an interface.\n */\nexport const HvTypography = fixedForwardRef(function HvTypography<\n C extends React.ElementType = \"p\"\n>(props: HvTypographyProps<C>, ref: PolymorphicRef<C>) {\n const {\n className,\n component: ComponentProp,\n classes: classesProp,\n variant: variantProp = \"body\",\n link = false,\n noWrap = false,\n paragraph = false,\n disabled = false,\n ...others\n } = useDefaultProps(\"HvTypography\", props);\n const { classes, cx } = useClasses(classesProp);\n const { activeTheme } = useTheme();\n\n const variant = mapVariant(variantProp, activeTheme?.name);\n\n const Component =\n ComponentProp || (paragraph && \"p\") || HvTypographyMap[variant] || \"span\";\n\n return (\n <Component\n ref={ref}\n className={cx(\n classes.root,\n classes[variant],\n {\n [classes.isLink]: link,\n [classes.noWrap]: noWrap,\n [classes.disabled]: disabled,\n },\n className\n )}\n disabled={disabled}\n {...others}\n />\n );\n});\n"],"names":["HvTypography"],"mappings":";;;;;;;AAmBA,MAAM,kBA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AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;"}
|
|
@@ -25,6 +25,7 @@ const { useClasses, staticClasses } = createClasses("HvTypography", {
|
|
|
25
25
|
title4: { ...theme.typography.title4 },
|
|
26
26
|
body: { ...theme.typography.body },
|
|
27
27
|
label: { ...theme.typography.label },
|
|
28
|
+
captionLabel: { ...theme.typography.captionLabel },
|
|
28
29
|
caption1: { ...theme.typography.caption1 },
|
|
29
30
|
caption2: { ...theme.typography.caption2 },
|
|
30
31
|
// legacy variants
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Typography.styles.js","sources":["../../../src/Typography/Typography.styles.ts"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"../utils/classes\";\n\nexport const { useClasses, staticClasses } = createClasses(\"HvTypography\", {\n root: {\n fontFamily: theme.fontFamily.body,\n },\n disabled: {\n color: theme.colors.secondary_60,\n },\n isLink: {\n cursor: \"pointer\",\n color: theme.colors.primary,\n textDecoration: \"underline\",\n },\n noWrap: {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n },\n // variants\n display: { ...theme.typography.display },\n title1: { ...theme.typography.title1 },\n title2: { ...theme.typography.title2 },\n title3: { ...theme.typography.title3 },\n title4: { ...theme.typography.title4 },\n body: { ...theme.typography.body },\n label: { ...theme.typography.label },\n caption1: { ...theme.typography.caption1 },\n caption2: { ...theme.typography.caption2 },\n // legacy variants\n \"5xlTitle\": { ...theme.typography[\"5xlTitle\"] },\n \"4xlTitle\": { ...theme.typography[\"4xlTitle\"] },\n // @ts-ignore non-existent variant\n \"3xlTitle\": { ...theme.typography[\"3xlTitle\"] },\n xxlTitle: { ...theme.typography.xxlTitle },\n xlTitle: {},\n lTitle: { ...theme.typography.lTitle },\n mTitle: {},\n sTitle: { ...theme.typography.sTitle },\n xsTitle: {},\n xxsTitle: { ...theme.typography.xxsTitle },\n sectionTitle: {\n ...theme.typography.sectionTitle,\n textTransform: \"uppercase\",\n },\n highlightText: {},\n normalText: {},\n placeholderText: { ...theme.typography.placeholderText },\n link: {\n ...theme.typography.link,\n cursor: \"pointer\",\n textDecoration: \"underline\",\n },\n disabledText: { ...theme.typography.disabledText },\n selectedNavText: { ...theme.typography.selectedNavText },\n vizText: {},\n vizTextDisabled: { ...theme.typography.vizTextDisabled },\n xsInlineLink: { ...theme.typography.xsInlineLink },\n});\n"],"names":[],"mappings":";;AAIO,MAAM,EAAE,YAAY,kBAAkB,cAAc,gBAAgB;AAAA,EACzE,MAAM;AAAA,IACJ,YAAY,MAAM,WAAW;AAAA,EAC/B;AAAA,EACA,UAAU;AAAA,IACR,OAAO,MAAM,OAAO;AAAA,EACtB;AAAA,EACA,QAAQ;AAAA,IACN,QAAQ;AAAA,IACR,OAAO,MAAM,OAAO;AAAA,IACpB,gBAAgB;AAAA,EAClB;AAAA,EACA,QAAQ;AAAA,IACN,UAAU;AAAA,IACV,cAAc;AAAA,IACd,YAAY;AAAA,EACd;AAAA;AAAA,EAEA,SAAS,EAAE,GAAG,MAAM,WAAW,QAAQ;AAAA,EACvC,QAAQ,EAAE,GAAG,MAAM,WAAW,OAAO;AAAA,EACrC,QAAQ,EAAE,GAAG,MAAM,WAAW,OAAO;AAAA,EACrC,QAAQ,EAAE,GAAG,MAAM,WAAW,OAAO;AAAA,EACrC,QAAQ,EAAE,GAAG,MAAM,WAAW,OAAO;AAAA,EACrC,MAAM,EAAE,GAAG,MAAM,WAAW,KAAK;AAAA,EACjC,OAAO,EAAE,GAAG,MAAM,WAAW,MAAM;AAAA,EACnC,UAAU,EAAE,GAAG,MAAM,WAAW,SAAS;AAAA,EACzC,UAAU,EAAE,GAAG,MAAM,WAAW,SAAS;AAAA;AAAA,EAEzC,YAAY,EAAE,GAAG,MAAM,WAAW,UAAU,EAAE;AAAA,EAC9C,YAAY,EAAE,GAAG,MAAM,WAAW,UAAU,EAAE;AAAA;AAAA,EAE9C,YAAY,EAAE,GAAG,MAAM,WAAW,UAAU,EAAE;AAAA,EAC9C,UAAU,EAAE,GAAG,MAAM,WAAW,SAAS;AAAA,EACzC,SAAS,CAAC;AAAA,EACV,QAAQ,EAAE,GAAG,MAAM,WAAW,OAAO;AAAA,EACrC,QAAQ,CAAC;AAAA,EACT,QAAQ,EAAE,GAAG,MAAM,WAAW,OAAO;AAAA,EACrC,SAAS,CAAC;AAAA,EACV,UAAU,EAAE,GAAG,MAAM,WAAW,SAAS;AAAA,EACzC,cAAc;AAAA,IACZ,GAAG,MAAM,WAAW;AAAA,IACpB,eAAe;AAAA,EACjB;AAAA,EACA,eAAe,CAAC;AAAA,EAChB,YAAY,CAAC;AAAA,EACb,iBAAiB,EAAE,GAAG,MAAM,WAAW,gBAAgB;AAAA,EACvD,MAAM;AAAA,IACJ,GAAG,MAAM,WAAW;AAAA,IACpB,QAAQ;AAAA,IACR,gBAAgB;AAAA,EAClB;AAAA,EACA,cAAc,EAAE,GAAG,MAAM,WAAW,aAAa;AAAA,EACjD,iBAAiB,EAAE,GAAG,MAAM,WAAW,gBAAgB;AAAA,EACvD,SAAS,CAAC;AAAA,EACV,iBAAiB,EAAE,GAAG,MAAM,WAAW,gBAAgB;AAAA,EACvD,cAAc,EAAE,GAAG,MAAM,WAAW,aAAa;AACnD,CAAC;"}
|
|
1
|
+
{"version":3,"file":"Typography.styles.js","sources":["../../../src/Typography/Typography.styles.ts"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"../utils/classes\";\n\nexport const { useClasses, staticClasses } = createClasses(\"HvTypography\", {\n root: {\n fontFamily: theme.fontFamily.body,\n },\n disabled: {\n color: theme.colors.secondary_60,\n },\n isLink: {\n cursor: \"pointer\",\n color: theme.colors.primary,\n textDecoration: \"underline\",\n },\n noWrap: {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n },\n // variants\n display: { ...theme.typography.display },\n title1: { ...theme.typography.title1 },\n title2: { ...theme.typography.title2 },\n title3: { ...theme.typography.title3 },\n title4: { ...theme.typography.title4 },\n body: { ...theme.typography.body },\n label: { ...theme.typography.label },\n captionLabel: { ...theme.typography.captionLabel },\n caption1: { ...theme.typography.caption1 },\n caption2: { ...theme.typography.caption2 },\n // legacy variants\n \"5xlTitle\": { ...theme.typography[\"5xlTitle\"] },\n \"4xlTitle\": { ...theme.typography[\"4xlTitle\"] },\n // @ts-ignore non-existent variant\n \"3xlTitle\": { ...theme.typography[\"3xlTitle\"] },\n xxlTitle: { ...theme.typography.xxlTitle },\n xlTitle: {},\n lTitle: { ...theme.typography.lTitle },\n mTitle: {},\n sTitle: { ...theme.typography.sTitle },\n xsTitle: {},\n xxsTitle: { ...theme.typography.xxsTitle },\n sectionTitle: {\n ...theme.typography.sectionTitle,\n textTransform: \"uppercase\",\n },\n highlightText: {},\n normalText: {},\n placeholderText: { ...theme.typography.placeholderText },\n link: {\n ...theme.typography.link,\n cursor: \"pointer\",\n textDecoration: \"underline\",\n },\n disabledText: { ...theme.typography.disabledText },\n selectedNavText: { ...theme.typography.selectedNavText },\n vizText: {},\n vizTextDisabled: { ...theme.typography.vizTextDisabled },\n xsInlineLink: { ...theme.typography.xsInlineLink },\n});\n"],"names":[],"mappings":";;AAIO,MAAM,EAAE,YAAY,kBAAkB,cAAc,gBAAgB;AAAA,EACzE,MAAM;AAAA,IACJ,YAAY,MAAM,WAAW;AAAA,EAC/B;AAAA,EACA,UAAU;AAAA,IACR,OAAO,MAAM,OAAO;AAAA,EACtB;AAAA,EACA,QAAQ;AAAA,IACN,QAAQ;AAAA,IACR,OAAO,MAAM,OAAO;AAAA,IACpB,gBAAgB;AAAA,EAClB;AAAA,EACA,QAAQ;AAAA,IACN,UAAU;AAAA,IACV,cAAc;AAAA,IACd,YAAY;AAAA,EACd;AAAA;AAAA,EAEA,SAAS,EAAE,GAAG,MAAM,WAAW,QAAQ;AAAA,EACvC,QAAQ,EAAE,GA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AA,EACvD,SAAS,CAAC;AAAA,EACV,iBAAiB,EAAE,GAAG,MAAM,WAAW,gBAAgB;AAAA,EACvD,cAAc,EAAE,GAAG,MAAM,WAAW,aAAa;AACnD,CAAC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../src/Typography/utils.ts"],"sourcesContent":["export const typographyVariants = [\n \"display\",\n \"title1\",\n \"title2\",\n \"title3\",\n \"title4\",\n \"body\",\n \"label\",\n \"caption1\",\n \"caption2\",\n] as const;\n\nexport type HvTypographyVariants = (typeof typographyVariants)[number];\n\n/** @deprecated */\nexport type HvTypographyLegacyVariants =\n | \"5xlTitle\"\n | \"4xlTitle\"\n | \"3xlTitle\"\n | \"xxlTitle\"\n | \"xlTitle\"\n | \"lTitle\"\n | \"mTitle\"\n | \"sTitle\"\n | \"xsTitle\"\n | \"xxsTitle\"\n | \"sectionTitle\"\n | \"highlightText\"\n | \"normalText\"\n | \"placeholderText\"\n | \"link\"\n | \"disabledText\"\n | \"selectedNavText\"\n | \"vizText\"\n | \"vizTextDisabled\"\n | \"xsInlineLink\";\n\ntype Variant = HvTypographyVariants | HvTypographyLegacyVariants;\n\nconst mappableVariants = new Map<Variant, HvTypographyVariants>([\n [\"3xlTitle\", \"display\"],\n [\"xlTitle\", \"title1\"],\n [\"mTitle\", \"title2\"],\n [\"xsTitle\", \"title3\"],\n [\"highlightText\", \"label\"],\n [\"normalText\", \"body\"],\n [\"vizText\", \"caption1\"],\n]);\n\nconst isLegacyVariant = (variant: string) => {\n return [\n \"5xlTitle\",\n \"4xlTitle\",\n \"3xlTitle\",\n \"xxlTitle\",\n \"xlTitle\",\n \"lTitle\",\n \"mTitle\",\n \"sTitle\",\n \"xsTitle\",\n \"xxsTitle\",\n \"sectionTitle\",\n \"highlightText\",\n \"normalText\",\n \"placeholderText\",\n \"link\",\n \"disabledText\",\n \"selectedNavText\",\n \"vizText\",\n \"vizTextDisabled\",\n \"xsInlineLink\",\n ].includes(variant);\n};\n\nexport const mapVariant = (variant: Variant, theme?: string) => {\n if (theme === \"ds3\") return variant;\n const mappedVariant = mappableVariants.get(variant);\n\n if (import.meta.env.DEV) {\n /* eslint-disable no-console */\n const msg = `The typography variant ${variant} is deprecated.`;\n if (mappedVariant) {\n console.warn(`${msg} Use ${mappedVariant} instead.`);\n }\n if (isLegacyVariant(variant)) {\n console.warn(msg);\n }\n }\n\n return mappedVariant || variant;\n};\n"],"names":[],"mappings":"AAAO,MAAM,qBAAqB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AA6BA,MAAM,uCAAuB,IAAmC;AAAA,EAC9D,CAAC,YAAY,SAAS;AAAA,EACtB,CAAC,WAAW,QAAQ;AAAA,EACpB,CAAC,UAAU,QAAQ;AAAA,EACnB,CAAC,WAAW,QAAQ;AAAA,EACpB,CAAC,iBAAiB,OAAO;AAAA,EACzB,CAAC,cAAc,MAAM;AAAA,EACrB,CAAC,WAAW,UAAU;AACxB,CAAC;AA2BY,MAAA,aAAa,CAAC,SAAkB,UAAmB;AAC9D,MAAI,UAAU;AAAc,WAAA;AACtB,QAAA,gBAAgB,iBAAiB,IAAI,OAAO;AAalD,SAAO,iBAAiB;AAC1B;"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/Typography/utils.ts"],"sourcesContent":["export const typographyVariants = [\n \"display\",\n \"title1\",\n \"title2\",\n \"title3\",\n \"title4\",\n \"body\",\n \"label\",\n \"captionLabel\",\n \"caption1\",\n \"caption2\",\n] as const;\n\nexport type HvTypographyVariants = (typeof typographyVariants)[number];\n\n/** @deprecated */\nexport type HvTypographyLegacyVariants =\n | \"5xlTitle\"\n | \"4xlTitle\"\n | \"3xlTitle\"\n | \"xxlTitle\"\n | \"xlTitle\"\n | \"lTitle\"\n | \"mTitle\"\n | \"sTitle\"\n | \"xsTitle\"\n | \"xxsTitle\"\n | \"sectionTitle\"\n | \"highlightText\"\n | \"normalText\"\n | \"placeholderText\"\n | \"link\"\n | \"disabledText\"\n | \"selectedNavText\"\n | \"vizText\"\n | \"vizTextDisabled\"\n | \"xsInlineLink\";\n\ntype Variant = HvTypographyVariants | HvTypographyLegacyVariants;\n\nconst mappableVariants = new Map<Variant, HvTypographyVariants>([\n [\"3xlTitle\", \"display\"],\n [\"xlTitle\", \"title1\"],\n [\"mTitle\", \"title2\"],\n [\"xsTitle\", \"title3\"],\n [\"highlightText\", \"label\"],\n [\"normalText\", \"body\"],\n [\"vizText\", \"caption1\"],\n]);\n\nconst isLegacyVariant = (variant: string) => {\n return [\n \"5xlTitle\",\n \"4xlTitle\",\n \"3xlTitle\",\n \"xxlTitle\",\n \"xlTitle\",\n \"lTitle\",\n \"mTitle\",\n \"sTitle\",\n \"xsTitle\",\n \"xxsTitle\",\n \"sectionTitle\",\n \"highlightText\",\n \"normalText\",\n \"placeholderText\",\n \"link\",\n \"disabledText\",\n \"selectedNavText\",\n \"vizText\",\n \"vizTextDisabled\",\n \"xsInlineLink\",\n ].includes(variant);\n};\n\nexport const mapVariant = (variant: Variant, theme?: string) => {\n if (theme === \"ds3\") return variant;\n const mappedVariant = mappableVariants.get(variant);\n\n if (import.meta.env.DEV) {\n /* eslint-disable no-console */\n const msg = `The typography variant ${variant} is deprecated.`;\n if (mappedVariant) {\n console.warn(`${msg} Use ${mappedVariant} instead.`);\n }\n if (isLegacyVariant(variant)) {\n console.warn(msg);\n }\n }\n\n return mappedVariant || variant;\n};\n"],"names":[],"mappings":"AAAO,MAAM,qBAAqB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AA6BA,MAAM,uCAAuB,IAAmC;AAAA,EAC9D,CAAC,YAAY,SAAS;AAAA,EACtB,CAAC,WAAW,QAAQ;AAAA,EACpB,CAAC,UAAU,QAAQ;AAAA,EACnB,CAAC,WAAW,QAAQ;AAAA,EACpB,CAAC,iBAAiB,OAAO;AAAA,EACzB,CAAC,cAAc,MAAM;AAAA,EACrB,CAAC,WAAW,UAAU;AACxB,CAAC;AA2BY,MAAA,aAAa,CAAC,SAAkB,UAAmB;AAC9D,MAAI,UAAU;AAAc,WAAA;AACtB,QAAA,gBAAgB,iBAAiB,IAAI,OAAO;AAalD,SAAO,iBAAiB;AAC1B;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { useContext, useState, useCallback, useMemo, useEffect } from "react";
|
|
3
|
-
import uniqueId from "
|
|
3
|
+
import { uniqueId } from "../../utils/helpers.js";
|
|
4
4
|
import { wrapperTooltip } from "../../utils/wrapperTooltip.js";
|
|
5
5
|
import { setId } from "../../utils/setId.js";
|
|
6
6
|
import { useControlled } from "../../hooks/useControlled.js";
|