@hitachivantara/uikit-react-core 5.37.1 → 5.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Calendar/CalendarHeader/CalendarHeader.cjs.map +1 -1
- package/dist/cjs/components/Calendar/CalendarNavigation/ComposedNavigation/ComposedNavigation.cjs.map +1 -1
- package/dist/cjs/components/Calendar/CalendarNavigation/MonthSelector/MonthSelector.cjs.map +1 -1
- package/dist/cjs/components/Calendar/model.cjs.map +1 -1
- package/dist/cjs/components/FilterGroup/RightPanel/RightPanel.cjs +11 -3
- package/dist/cjs/components/FilterGroup/RightPanel/RightPanel.cjs.map +1 -1
- package/dist/cjs/components/Grid/Grid.cjs +38 -17
- package/dist/cjs/components/Grid/Grid.cjs.map +1 -1
- package/dist/cjs/components/Header/Navigation/MenuBar/Bar.cjs.map +1 -1
- package/dist/cjs/components/Header/Navigation/MenuBar/MenuBar.cjs.map +1 -1
- package/dist/cjs/components/Header/Navigation/MenuItem/MenuItem.cjs.map +1 -1
- package/dist/cjs/components/Input/Input.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/ConfirmationDialog/ConfirmationDialog.styles.cjs +1 -3
- package/dist/cjs/components/QueryBuilder/ConfirmationDialog/ConfirmationDialog.styles.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/QueryBuilder.styles.cjs +4 -5
- package/dist/cjs/components/QueryBuilder/QueryBuilder.styles.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/Rule/Rule.cjs +4 -4
- package/dist/cjs/components/QueryBuilder/Rule/Rule.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/Rule/Rule.styles.cjs +7 -4
- package/dist/cjs/components/QueryBuilder/Rule/Rule.styles.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.styles.cjs +3 -5
- package/dist/cjs/components/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.styles.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/Rule/Value/NumericValue/Numeric.styles.cjs +6 -10
- package/dist/cjs/components/QueryBuilder/Rule/Value/NumericValue/Numeric.styles.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/RuleGroup/RuleGroup.cjs +10 -13
- package/dist/cjs/components/QueryBuilder/RuleGroup/RuleGroup.cjs.map +1 -1
- package/dist/cjs/components/Table/TableBody/TableBody.cjs +1 -1
- package/dist/cjs/components/Table/TableBody/TableBody.cjs.map +1 -1
- package/dist/cjs/components/Tooltip/Tooltip.cjs +1 -1
- package/dist/cjs/components/Tooltip/Tooltip.cjs.map +1 -1
- package/dist/cjs/components/Typography/Typography.cjs +7 -0
- package/dist/cjs/components/Typography/Typography.cjs.map +1 -1
- package/dist/cjs/hooks/useControlled.cjs.map +1 -1
- package/dist/cjs/hooks/useImageLoaded.cjs +1 -1
- package/dist/cjs/hooks/useImageLoaded.cjs.map +1 -1
- package/dist/esm/components/Calendar/CalendarHeader/CalendarHeader.js.map +1 -1
- package/dist/esm/components/Calendar/CalendarNavigation/ComposedNavigation/ComposedNavigation.js.map +1 -1
- package/dist/esm/components/Calendar/CalendarNavigation/MonthSelector/MonthSelector.js.map +1 -1
- package/dist/esm/components/Calendar/model.js.map +1 -1
- package/dist/esm/components/FilterGroup/RightPanel/RightPanel.js +11 -3
- package/dist/esm/components/FilterGroup/RightPanel/RightPanel.js.map +1 -1
- package/dist/esm/components/Grid/Grid.js +38 -17
- package/dist/esm/components/Grid/Grid.js.map +1 -1
- package/dist/esm/components/Header/Navigation/MenuBar/Bar.js.map +1 -1
- package/dist/esm/components/Header/Navigation/MenuBar/MenuBar.js.map +1 -1
- package/dist/esm/components/Header/Navigation/MenuItem/MenuItem.js.map +1 -1
- package/dist/esm/components/Input/Input.js.map +1 -1
- package/dist/esm/components/QueryBuilder/ConfirmationDialog/ConfirmationDialog.styles.js +1 -3
- package/dist/esm/components/QueryBuilder/ConfirmationDialog/ConfirmationDialog.styles.js.map +1 -1
- package/dist/esm/components/QueryBuilder/QueryBuilder.styles.js +4 -5
- package/dist/esm/components/QueryBuilder/QueryBuilder.styles.js.map +1 -1
- package/dist/esm/components/QueryBuilder/Rule/Rule.js +4 -4
- package/dist/esm/components/QueryBuilder/Rule/Rule.js.map +1 -1
- package/dist/esm/components/QueryBuilder/Rule/Rule.styles.js +7 -4
- package/dist/esm/components/QueryBuilder/Rule/Rule.styles.js.map +1 -1
- package/dist/esm/components/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.styles.js +3 -5
- package/dist/esm/components/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.styles.js.map +1 -1
- package/dist/esm/components/QueryBuilder/Rule/Value/NumericValue/Numeric.styles.js +6 -10
- package/dist/esm/components/QueryBuilder/Rule/Value/NumericValue/Numeric.styles.js.map +1 -1
- package/dist/esm/components/QueryBuilder/RuleGroup/RuleGroup.js +10 -13
- package/dist/esm/components/QueryBuilder/RuleGroup/RuleGroup.js.map +1 -1
- package/dist/esm/components/Table/TableBody/TableBody.js +1 -1
- package/dist/esm/components/Table/TableBody/TableBody.js.map +1 -1
- package/dist/esm/components/Tooltip/Tooltip.js +1 -1
- package/dist/esm/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/esm/components/Typography/Typography.js +7 -0
- package/dist/esm/components/Typography/Typography.js.map +1 -1
- package/dist/esm/hooks/useControlled.js.map +1 -1
- package/dist/esm/hooks/useImageLoaded.js +1 -1
- package/dist/esm/hooks/useImageLoaded.js.map +1 -1
- package/dist/types/index.d.ts +30 -24
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalendarHeader.cjs","sources":["../../../../../src/components/Calendar/CalendarHeader/CalendarHeader.tsx"],"sourcesContent":["import { useState, useEffect, useContext } from \"react\";\nimport dayjs from \"dayjs\";\nimport localeData from \"dayjs/plugin/localeData\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat\";\n\nimport {\n HvFormElementContext,\n HvFormElementValueContext,\n HvFormElementDescriptorsContext,\n} from \"@core/components/Forms\";\nimport { isKey } from \"@core/utils/keyboardUtils\";\nimport { setId } from \"@core/utils/setId\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { useDefaultProps } from \"@core/hooks\";\nimport { HvInput, HvInputProps } from \"@core/components/Input\";\n\nimport { isRange, isSameDay, formatToLocale, isDate } from \"../utils\";\nimport { DateRangeProp } from \"../types\";\nimport { staticClasses, useClasses } from \"./CalendarHeader.styles\";\n\nexport { staticClasses as calendarHeaderClasses };\n\nexport type HvCalendarHeaderClasses = ExtractNames<typeof useClasses>;\n\ndayjs.extend(localeData);\ndayjs.extend(localizedFormat);\ndayjs.extend(customParseFormat);\n\nexport const HvCalendarHeader = (props: HvCalendarHeaderProps) => {\n const {\n id,\n value,\n locale = \"en-US\",\n classes: classesProp,\n onChange,\n showEndDate,\n showDayOfWeek = false,\n onFocus,\n invalidDateLabel = \"Invalid Date\",\n } = useDefaultProps(\"HvCalendarHeader\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const { elementId } = useContext(HvFormElementContext);\n const elementValue = useContext(HvFormElementValueContext);\n const { label } = useContext(HvFormElementDescriptorsContext);\n\n let localValue: string | Date | DateRangeProp | undefined =\n value ?? elementValue ?? \"\";\n if (isRange(localValue)) {\n localValue = showEndDate ? localValue.endDate : localValue.startDate;\n }\n\n const [dateValue, setDateValue] = useState<\n string | Date | DateRangeProp | undefined\n >(localValue);\n const [editedValue, setEditedValue] = useState<string | null>(null);\n const [displayValue, setDisplayValue] = useState(\"\");\n const [weekdayDisplay, setWeekdayDisplay] = useState(\"\");\n\n const localId = id ?? setId(elementId, \"calendarHeader\");\n\n const inputValue = editedValue ?? displayValue;\n const localeFormat = dayjs().locale(locale).localeData().longDateFormat(\"L\");\n\n const [isValidValue, setIsValidValue] = useState(\n inputValue.length === 0 || (!!inputValue && dayjs(localValue).isValid())\n );\n\n const validateInput = (incomingValid) =>\n incomingValid === undefined || dayjs(incomingValid).isValid();\n\n useEffect(() => {\n const valid = validateInput(localValue);\n setIsValidValue(valid);\n if (valid) {\n if (!localValue) {\n setDisplayValue(\"\");\n setEditedValue(null);\n setWeekdayDisplay(\"\");\n return;\n }\n const weekday = new Intl.DateTimeFormat(locale, {\n weekday: \"short\",\n }).format(isDate(localValue) ? localValue : 0);\n setDisplayValue(formatToLocale(localValue, locale));\n setEditedValue(null);\n setWeekdayDisplay(weekday);\n }\n }, [localValue, locale]);\n\n const handleNewDate = (event, date) => {\n // attempt to format in locale data, or fallback to default\n const localeParsedDate = dayjs(date, localeFormat);\n\n const isValidInput = localeParsedDate.isValid();\n const dateParsed = isValidInput\n ? localeParsedDate.toDate()\n : dayjs(date).toDate();\n // prevent extra updates\n if (!isSameDay(dateParsed, dateValue)) {\n setDateValue(dateParsed);\n onChange?.(event, dateParsed);\n }\n\n setIsValidValue(isValidInput);\n if (isValidInput) {\n setEditedValue(null);\n }\n };\n\n const onBlurHandler: HvInputProps[\"onBlur\"] = (event) => {\n if (editedValue == null) return;\n if (editedValue === \"\") {\n setIsValidValue(true);\n setEditedValue(null);\n return;\n }\n handleNewDate(event, editedValue);\n };\n\n const keyDownHandler: HvInputProps[\"onKeyDown\"] = (event) => {\n if (!isKey(event, \"Enter\") || editedValue == null || editedValue === \"\")\n return;\n event.preventDefault();\n\n handleNewDate(event, editedValue);\n };\n\n const onFocusHandler: HvInputProps[\"onFocus\"] = (event) => {\n if (!localValue) return;\n const formattedDate =\n isValidValue && isDate(localValue)\n ? dayjs(localValue).locale(locale).format(\"L\")\n : editedValue;\n setEditedValue(formattedDate);\n onFocus?.(event, formattedDate);\n };\n\n const onChangeHandler: HvInputProps[\"onChange\"] = (event, val) => {\n setEditedValue(val);\n };\n\n const isInvalid = !isValidValue && inputValue !== \"\";\n\n // This component needs to be further refactored\n // It's not possible to clear the date\n // In a new major there's no need for all these classes\n return (\n <div\n id={localId}\n className={cx(classes.root, {\n [classes.invalid]: isInvalid,\n })}\n >\n {showDayOfWeek && (\n <HvTypography className={classes.headerDayOfWeek}>\n {weekdayDisplay || \"\\u00A0\"}\n </HvTypography>\n )}\n <HvInput\n type=\"text\"\n id={setId(localId, \"header-input\")}\n className={classes.headerDate}\n classes={{\n input: classes.input,\n inputBorderContainer: classes.inputBorderContainer,\n error: classes.invalidMessageStyling,\n }}\n placeholder={localeFormat}\n value={inputValue}\n aria-labelledby={label?.[0]?.id}\n onBlur={onBlurHandler}\n onFocus={onFocusHandler}\n onChange={onChangeHandler}\n onKeyDown={keyDownHandler}\n status={isInvalid ? \"invalid\" : \"valid\"}\n statusMessage={invalidDateLabel}\n />\n </div>\n );\n};\n\n// TODO: refactor this out\nHvCalendarHeader.formElementType = \"HvCalendarHeader\";\n\nexport interface HvCalendarHeaderProps {\n /**\n * A Jss Object used to override or extend the component styles.\n */\n classes?: HvCalendarHeaderClasses;\n /**\n * Identifier.\n */\n id?: string;\n /**\n * The text to be shown on the main part of the header.\n */\n value?: string | Date | DateRangeProp;\n /**\n * Locale to be used by the calendar.\n */\n locale?: string;\n /**\n * Callback to define the input date.\n */\n onChange?: (\n event:\n | React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>\n | undefined,\n value: Date | DateRangeProp\n ) => void;\n /**\n * Callback to handle input onFocus.\n */\n onFocus?: (\n event: React.FocusEvent<HTMLTextAreaElement | HTMLInputElement>,\n formattedDate: string | null\n ) => void;\n /**\n * Indicates if header should display end date in a date range.\n */\n showEndDate?: boolean;\n /**\n * Indicates if header should display the day of week.\n */\n showDayOfWeek?: boolean;\n /**\n * Label shown when date is invalid.\n */\n invalidDateLabel?: string;\n}\n"],"names":["dayjs","extend","localeData","localizedFormat","customParseFormat","HvCalendarHeader","props","id","value","locale","classes","classesProp","onChange","showEndDate","showDayOfWeek","onFocus","invalidDateLabel","useDefaultProps","cx","useClasses","elementId","useContext","HvFormElementContext","elementValue","HvFormElementValueContext","label","HvFormElementDescriptorsContext","localValue","isRange","endDate","startDate","dateValue","setDateValue","useState","editedValue","setEditedValue","displayValue","setDisplayValue","weekdayDisplay","setWeekdayDisplay","localId","setId","inputValue","localeFormat","longDateFormat","isValidValue","setIsValidValue","length","isValid","validateInput","incomingValid","undefined","useEffect","valid","weekday","Intl","DateTimeFormat","format","isDate","formatToLocale","handleNewDate","event","date","localeParsedDate","isValidInput","dateParsed","toDate","isSameDay","onBlurHandler","keyDownHandler","isKey","preventDefault","onFocusHandler","formattedDate","onChangeHandler","val","isInvalid","root","invalid","HvTypography","headerDayOfWeek","jsx","HvInput","headerDate","input","inputBorderContainer","error","invalidMessageStyling","formElementType"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA0BAA,eAAAA,QAAMC,OAAOC,oBAAAA,OAAU;AACvBF,eAAAA,QAAMC,OAAOE,yBAAAA,OAAe;AAC5BH,eAAAA,QAAMC,OAAOG,2BAAAA,OAAiB;AAEjBC,MAAAA,mBAAmBA,CAACC,UAAiC;AAC1D,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC,SAAS;AAAA,IACTC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC,gBAAgB;AAAA,IAChBC;AAAAA,IACAC,mBAAmB;AAAA,EAAA,IACjBC,gBAAgB,gBAAA,oBAAoBX,KAAK;AAEvC,QAAA;AAAA,IAAEI;AAAAA,IAASQ;AAAAA,EAAAA,IAAOC,sBAAAA,WAAWR,WAAW;AAExC,QAAA;AAAA,IAAES;AAAAA,EAAAA,IAAcC,MAAAA,WAAWC,mBAAAA,oBAAoB;AAC/CC,QAAAA,eAAeF,iBAAWG,wBAAAA,yBAAyB;AACnD,QAAA;AAAA,IAAEC;AAAAA,EAAAA,IAAUJ,MAAAA,WAAWK,8BAAAA,+BAA+B;AAExDC,MAAAA,aACFnB,SAASe,gBAAgB;AACvBK,MAAAA,MAAAA,QAAQD,UAAU,GAAG;AACVd,iBAAAA,cAAcc,WAAWE,UAAU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EiE,WAAa,cAAA,EAAA,WAAWrE,QAAQsE,iBAC9B1C,4BAAkB,KACrB;AAAA,IAED2C,2BAAAA,IAAAC,MAAAA,SAAA,EACC,MAAK,QACL,IAAIzC,MAAAA,MAAMD,SAAS,cAAc,GACjC,WAAW9B,QAAQyE,YACnB,SAAS;AAAA,MACPC,OAAO1E,QAAQ0E;AAAAA,MACfC,sBAAsB3E,QAAQ2E;AAAAA,MAC9BC,OAAO5E,QAAQ6E;AAAAA,IACjB,GACA,aAAa5C,cACb,OAAOD,YACP,mBAAiBjB,QAAQ,CAAC,GAAGlB,IAC7B,QAAQ6D,eACR,SAASI,gBACT,UAAUE,iBACV,WAAWL,gBACX,QAAQO,YAAY,YAAY,SAChC,eAAe5D,iBAAiB,CAAA;AAAA,EAEpC,EAAA,CAAA;AAEJ;AAGAX,iBAAiBmF,kBAAkB;;;"}
|
|
1
|
+
{"version":3,"file":"CalendarHeader.cjs","sources":["../../../../../src/components/Calendar/CalendarHeader/CalendarHeader.tsx"],"sourcesContent":["import { useState, useEffect, useContext } from \"react\";\nimport dayjs from \"dayjs\";\nimport localeData from \"dayjs/plugin/localeData\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat\";\n\nimport {\n HvFormElementContext,\n HvFormElementValueContext,\n HvFormElementDescriptorsContext,\n} from \"@core/components/Forms\";\nimport { isKey } from \"@core/utils/keyboardUtils\";\nimport { setId } from \"@core/utils/setId\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { useDefaultProps } from \"@core/hooks\";\nimport { HvInput, HvInputProps } from \"@core/components/Input\";\n\nimport { isRange, isSameDay, formatToLocale, isDate } from \"../utils\";\nimport { DateRangeProp } from \"../types\";\nimport { staticClasses, useClasses } from \"./CalendarHeader.styles\";\n\nexport { staticClasses as calendarHeaderClasses };\n\nexport type HvCalendarHeaderClasses = ExtractNames<typeof useClasses>;\n\ndayjs.extend(localeData);\ndayjs.extend(localizedFormat);\ndayjs.extend(customParseFormat);\n\nexport const HvCalendarHeader = (props: HvCalendarHeaderProps) => {\n const {\n id,\n value,\n locale = \"en-US\",\n classes: classesProp,\n onChange,\n showEndDate,\n showDayOfWeek = false,\n onFocus,\n invalidDateLabel = \"Invalid Date\",\n } = useDefaultProps(\"HvCalendarHeader\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const { elementId } = useContext(HvFormElementContext);\n const elementValue = useContext(HvFormElementValueContext);\n const { label } = useContext(HvFormElementDescriptorsContext);\n\n let localValue: string | Date | DateRangeProp | undefined =\n value ?? elementValue ?? \"\";\n if (isRange(localValue)) {\n localValue = showEndDate ? localValue.endDate : localValue.startDate;\n }\n\n const [dateValue, setDateValue] = useState<\n string | Date | DateRangeProp | undefined\n >(localValue);\n const [editedValue, setEditedValue] = useState<string | null>(null);\n const [displayValue, setDisplayValue] = useState(\"\");\n const [weekdayDisplay, setWeekdayDisplay] = useState(\"\");\n\n const localId = id ?? setId(elementId, \"calendarHeader\");\n\n const inputValue = editedValue ?? displayValue;\n const localeFormat = dayjs().locale(locale).localeData().longDateFormat(\"L\");\n\n const [isValidValue, setIsValidValue] = useState(\n inputValue.length === 0 || (!!inputValue && dayjs(localValue).isValid())\n );\n\n const validateInput = (incomingValid: any) =>\n incomingValid === undefined || dayjs(incomingValid).isValid();\n\n useEffect(() => {\n const valid = validateInput(localValue);\n setIsValidValue(valid);\n if (valid) {\n if (!localValue) {\n setDisplayValue(\"\");\n setEditedValue(null);\n setWeekdayDisplay(\"\");\n return;\n }\n const weekday = new Intl.DateTimeFormat(locale, {\n weekday: \"short\",\n }).format(isDate(localValue) ? localValue : 0);\n setDisplayValue(formatToLocale(localValue, locale));\n setEditedValue(null);\n setWeekdayDisplay(weekday);\n }\n }, [localValue, locale]);\n\n const handleNewDate = (event: any, date: string) => {\n // attempt to format in locale data, or fallback to default\n const localeParsedDate = dayjs(date, localeFormat);\n\n const isValidInput = localeParsedDate.isValid();\n const dateParsed = isValidInput\n ? localeParsedDate.toDate()\n : dayjs(date).toDate();\n // prevent extra updates\n if (!isSameDay(dateParsed, dateValue)) {\n setDateValue(dateParsed);\n onChange?.(event, dateParsed);\n }\n\n setIsValidValue(isValidInput);\n if (isValidInput) {\n setEditedValue(null);\n }\n };\n\n const onBlurHandler: HvInputProps[\"onBlur\"] = (event) => {\n if (editedValue == null) return;\n if (editedValue === \"\") {\n setIsValidValue(true);\n setEditedValue(null);\n return;\n }\n handleNewDate(event, editedValue);\n };\n\n const keyDownHandler: HvInputProps[\"onKeyDown\"] = (event) => {\n if (!isKey(event, \"Enter\") || editedValue == null || editedValue === \"\")\n return;\n event.preventDefault();\n\n handleNewDate(event, editedValue);\n };\n\n const onFocusHandler: HvInputProps[\"onFocus\"] = (event) => {\n if (!localValue) return;\n const formattedDate =\n isValidValue && isDate(localValue)\n ? dayjs(localValue).locale(locale).format(\"L\")\n : editedValue;\n setEditedValue(formattedDate);\n onFocus?.(event, formattedDate);\n };\n\n const onChangeHandler: HvInputProps[\"onChange\"] = (event, val) => {\n setEditedValue(val);\n };\n\n const isInvalid = !isValidValue && inputValue !== \"\";\n\n // This component needs to be further refactored\n // It's not possible to clear the date\n // In a new major there's no need for all these classes\n return (\n <div\n id={localId}\n className={cx(classes.root, {\n [classes.invalid]: isInvalid,\n })}\n >\n {showDayOfWeek && (\n <HvTypography className={classes.headerDayOfWeek}>\n {weekdayDisplay || \"\\u00A0\"}\n </HvTypography>\n )}\n <HvInput\n type=\"text\"\n id={setId(localId, \"header-input\")}\n className={classes.headerDate}\n classes={{\n input: classes.input,\n inputBorderContainer: classes.inputBorderContainer,\n error: classes.invalidMessageStyling,\n }}\n placeholder={localeFormat}\n value={inputValue}\n aria-labelledby={label?.[0]?.id}\n onBlur={onBlurHandler}\n onFocus={onFocusHandler}\n onChange={onChangeHandler}\n onKeyDown={keyDownHandler}\n status={isInvalid ? \"invalid\" : \"valid\"}\n statusMessage={invalidDateLabel}\n />\n </div>\n );\n};\n\n// TODO: refactor this out\nHvCalendarHeader.formElementType = \"HvCalendarHeader\";\n\nexport interface HvCalendarHeaderProps {\n /**\n * A Jss Object used to override or extend the component styles.\n */\n classes?: HvCalendarHeaderClasses;\n /**\n * Identifier.\n */\n id?: string;\n /**\n * The text to be shown on the main part of the header.\n */\n value?: string | Date | DateRangeProp;\n /**\n * Locale to be used by the calendar.\n */\n locale?: string;\n /**\n * Callback to define the input date.\n */\n onChange?: (\n event:\n | React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>\n | undefined,\n value: Date | DateRangeProp\n ) => void;\n /**\n * Callback to handle input onFocus.\n */\n onFocus?: (\n event: React.FocusEvent<HTMLTextAreaElement | HTMLInputElement>,\n formattedDate: string | null\n ) => void;\n /**\n * Indicates if header should display end date in a date range.\n */\n showEndDate?: boolean;\n /**\n * Indicates if header should display the day of week.\n */\n showDayOfWeek?: boolean;\n /**\n * Label shown when date is invalid.\n */\n invalidDateLabel?: string;\n}\n"],"names":["dayjs","extend","localeData","localizedFormat","customParseFormat","HvCalendarHeader","props","id","value","locale","classes","classesProp","onChange","showEndDate","showDayOfWeek","onFocus","invalidDateLabel","useDefaultProps","cx","useClasses","elementId","useContext","HvFormElementContext","elementValue","HvFormElementValueContext","label","HvFormElementDescriptorsContext","localValue","isRange","endDate","startDate","dateValue","setDateValue","useState","editedValue","setEditedValue","displayValue","setDisplayValue","weekdayDisplay","setWeekdayDisplay","localId","setId","inputValue","localeFormat","longDateFormat","isValidValue","setIsValidValue","length","isValid","validateInput","incomingValid","undefined","useEffect","valid","weekday","Intl","DateTimeFormat","format","isDate","formatToLocale","handleNewDate","event","date","localeParsedDate","isValidInput","dateParsed","toDate","isSameDay","onBlurHandler","keyDownHandler","isKey","preventDefault","onFocusHandler","formattedDate","onChangeHandler","val","isInvalid","root","invalid","HvTypography","headerDayOfWeek","jsx","HvInput","headerDate","input","inputBorderContainer","error","invalidMessageStyling","formElementType"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;A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eAAe5D,iBAAiB,CAAA;AAAA,EAEpC,EAAA,CAAA;AAEJ;AAGAX,iBAAiBmF,kBAAkB;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposedNavigation.cjs","sources":["../../../../../../src/components/Calendar/CalendarNavigation/ComposedNavigation/ComposedNavigation.tsx"],"sourcesContent":["import { setId } from \"@core/utils/setId\";\n\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { getMonthNamesList } from \"../../utils\";\nimport { ViewMode } from \"../../enums\";\nimport { Navigation } from \"../Navigation\";\nimport { VisibilitySelectorActions } from \"../../types\";\n\nimport { staticClasses, useClasses } from \"./ComposedNavigation.styles\";\n\nexport { staticClasses as composedNavigationClasses };\n\nexport type HvComposedNavigationClasses = ExtractNames<typeof useClasses>;\n\nexport const HvComposedNavigation = ({\n classes: classesProp,\n id,\n locale,\n onChange,\n onViewModeChange,\n visibleYear,\n visibleMonth,\n ...others\n}: HvComposedNavigationProps) => {\n const { classes } = useClasses(classesProp);\n\n const listMonthNamesLong = getMonthNamesList(locale, \"long\");\n const monthName = listMonthNamesLong[visibleMonth - 1];\n\n return (\n <div className={classes.navigationContainer} {...others}>\n <div className={classes.navigationMonth}>\n <Navigation\n id={setId(id, \"navigation-month\")}\n navigationText={monthName}\n onNavigatePrevious={(event) => {\n onChange?.(event, \"previous_month\");\n }}\n onNavigateNext={(event) => {\n onChange?.(event, \"next_month\");\n }}\n onTextClick={() => {\n onViewModeChange(\"monthly\");\n }}\n className={classes.navigationMonth}\n />\n </div>\n\n <Navigation\n id={setId(id, \"navigation-year\")}\n navigationText={visibleYear.toString()}\n onNavigatePrevious={(event) => {\n onChange?.(event, \"previous_year\");\n }}\n onNavigateNext={(event) => {\n onChange?.(event, \"next_year\");\n }}\n />\n </div>\n );\n};\n\nexport interface HvComposedNavigationProps {\n /**\n * A Jss Object used to override or extend the component styles.\n */\n classes?: HvComposedNavigationClasses;\n /**\n * Identifier.\n */\n id?: string;\n /**\n * Locale to be used by the calendar.\n */\n locale?: string;\n /**\n * Callback to define the input date.\n */\n onChange?: (event, action: VisibilitySelectorActions) => void;\n /**\n * Callback to define the view mode.\n */\n onViewModeChange: (viewMode: ViewMode) => void;\n /**\n * Controls the visible month of the Calendar\n */\n visibleMonth: number;\n /**\n * Controls the visible month of the Calendar\n */\n visibleYear: number;\n}\n"],"names":["HvComposedNavigation","classes","classesProp","id","locale","onChange","onViewModeChange","visibleYear","visibleMonth","others","useClasses","listMonthNamesLong","getMonthNamesList","monthName","navigationContainer","jsx","navigationMonth","Navigation","setId","event","toString"],"mappings":";;;;;;;AAeO,MAAMA,uBAAuBA,CAAC;AAAA,EACnCC,SAASC;AAAAA,EACTC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACA,GAAGC;AACsB,MAAM;AACzB,QAAA;AAAA,IAAER;AAAAA,EAAAA,IAAYS,0BAAAA,WAAWR,WAAW;AAEpCS,QAAAA,qBAAqBC,MAAAA,kBAAkBR,QAAQ,MAAM;AACrDS,QAAAA,YAAYF,mBAAmBH,eAAe,CAAC;AAErD,yCACG,OAAI,EAAA,WAAWP,QAAQa,qBAAqB,GAAIL,QAC/C,UAAA;AAAA,IAAAM,2BAAA,IAAC,OAAI,EAAA,WAAWd,QAAQe,iBACtB,yCAACC,WACC,YAAA,EAAA,IAAIC,MAAMf,MAAAA,IAAI,kBAAkB,GAChC,gBAAgBU,WAChB,oBAAqBM,CAAU,UAAA;AAC7Bd,iBAAWc,OAAO,gBAAgB;AAAA,IAAA,GAEpC,gBAAiBA,CAAU,UAAA;AACzBd,iBAAWc,OAAO,YAAY;AAAA,IAChC,GACA,aAAa,MAAM;AACjBb,uBAAiB,SAAS;AAAA,IAE5B,GAAA,WAAWL,QAAQe,gBAAAA,CAAgB,EAEvC,CAAA;AAAA,IAECD,2BAAAA,IAAAE,WAAAA,YAAA,EACC,IAAIC,MAAAA,MAAMf,IAAI,iBAAiB,GAC/B,gBAAgBI,YAAYa,SAC5B,GAAA,oBAAqBD,CAAU,UAAA;AAC7Bd,iBAAWc,OAAO,eAAe;AAAA,IAAA,GAEnC,gBAAiBA,CAAU,UAAA;AACzBd,iBAAWc,OAAO,WAAW;AAAA,IAAA,GAC7B;AAAA,EAEN,EAAA,CAAA;AAEJ;;;"}
|
|
1
|
+
{"version":3,"file":"ComposedNavigation.cjs","sources":["../../../../../../src/components/Calendar/CalendarNavigation/ComposedNavigation/ComposedNavigation.tsx"],"sourcesContent":["import { setId } from \"@core/utils/setId\";\n\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { getMonthNamesList } from \"../../utils\";\nimport { ViewMode } from \"../../enums\";\nimport { Navigation } from \"../Navigation\";\nimport { VisibilitySelectorActions } from \"../../types\";\n\nimport { staticClasses, useClasses } from \"./ComposedNavigation.styles\";\n\nexport { staticClasses as composedNavigationClasses };\n\nexport type HvComposedNavigationClasses = ExtractNames<typeof useClasses>;\n\nexport const HvComposedNavigation = ({\n classes: classesProp,\n id,\n locale,\n onChange,\n onViewModeChange,\n visibleYear,\n visibleMonth,\n ...others\n}: HvComposedNavigationProps) => {\n const { classes } = useClasses(classesProp);\n\n const listMonthNamesLong = getMonthNamesList(locale, \"long\");\n const monthName = listMonthNamesLong[visibleMonth - 1];\n\n return (\n <div className={classes.navigationContainer} {...others}>\n <div className={classes.navigationMonth}>\n <Navigation\n id={setId(id, \"navigation-month\")}\n navigationText={monthName}\n onNavigatePrevious={(event) => {\n onChange?.(event, \"previous_month\");\n }}\n onNavigateNext={(event) => {\n onChange?.(event, \"next_month\");\n }}\n onTextClick={() => {\n onViewModeChange(\"monthly\");\n }}\n className={classes.navigationMonth}\n />\n </div>\n\n <Navigation\n id={setId(id, \"navigation-year\")}\n navigationText={visibleYear.toString()}\n onNavigatePrevious={(event) => {\n onChange?.(event, \"previous_year\");\n }}\n onNavigateNext={(event) => {\n onChange?.(event, \"next_year\");\n }}\n />\n </div>\n );\n};\n\nexport interface HvComposedNavigationProps {\n /**\n * A Jss Object used to override or extend the component styles.\n */\n classes?: HvComposedNavigationClasses;\n /**\n * Identifier.\n */\n id?: string;\n /**\n * Locale to be used by the calendar.\n */\n locale?: string;\n /**\n * Callback to define the input date.\n */\n onChange?: (event: any, action: VisibilitySelectorActions) => void;\n /**\n * Callback to define the view mode.\n */\n onViewModeChange: (viewMode: ViewMode) => void;\n /**\n * Controls the visible month of the Calendar\n */\n visibleMonth: number;\n /**\n * Controls the visible month of the Calendar\n */\n visibleYear: number;\n}\n"],"names":["HvComposedNavigation","classes","classesProp","id","locale","onChange","onViewModeChange","visibleYear","visibleMonth","others","useClasses","listMonthNamesLong","getMonthNamesList","monthName","navigationContainer","jsx","navigationMonth","Navigation","setId","event","toString"],"mappings":";;;;;;;AAeO,MAAMA,uBAAuBA,CAAC;AAAA,EACnCC,SAASC;AAAAA,EACTC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACA,GAAGC;AACsB,MAAM;AACzB,QAAA;AAAA,IAAER;AAAAA,EAAAA,IAAYS,0BAAAA,WAAWR,WAAW;AAEpCS,QAAAA,qBAAqBC,MAAAA,kBAAkBR,QAAQ,MAAM;AACrDS,QAAAA,YAAYF,mBAAmBH,eAAe,CAAC;AAErD,yCACG,OAAI,EAAA,WAAWP,QAAQa,qBAAqB,GAAIL,QAC/C,UAAA;AAAA,IAAAM,2BAAA,IAAC,OAAI,EAAA,WAAWd,QAAQe,iBACtB,yCAACC,WACC,YAAA,EAAA,IAAIC,MAAMf,MAAAA,IAAI,kBAAkB,GAChC,gBAAgBU,WAChB,oBAAqBM,CAAU,UAAA;AAC7Bd,iBAAWc,OAAO,gBAAgB;AAAA,IAAA,GAEpC,gBAAiBA,CAAU,UAAA;AACzBd,iBAAWc,OAAO,YAAY;AAAA,IAChC,GACA,aAAa,MAAM;AACjBb,uBAAiB,SAAS;AAAA,IAE5B,GAAA,WAAWL,QAAQe,gBAAAA,CAAgB,EAEvC,CAAA;AAAA,IAECD,2BAAAA,IAAAE,WAAAA,YAAA,EACC,IAAIC,MAAAA,MAAMf,IAAI,iBAAiB,GAC/B,gBAAgBI,YAAYa,SAC5B,GAAA,oBAAqBD,CAAU,UAAA;AAC7Bd,iBAAWc,OAAO,eAAe;AAAA,IAAA,GAEnC,gBAAiBA,CAAU,UAAA;AACzBd,iBAAWc,OAAO,WAAW;AAAA,IAAA,GAC7B;AAAA,EAEN,EAAA,CAAA;AAEJ;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MonthSelector.cjs","sources":["../../../../../../src/components/Calendar/CalendarNavigation/MonthSelector/MonthSelector.tsx"],"sourcesContent":["import { isKey } from \"@core/utils/keyboardUtils\";\n\nimport { HvTypography } from \"@core/components/Typography\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { getMonthNamesList } from \"../../utils\";\nimport { ViewMode } from \"../../enums\";\nimport { DateRangeProp, VisibilitySelectorActions } from \"../../types\";\n\nimport { staticClasses, useClasses } from \"./MonthSelector.styles\";\n\nexport { staticClasses as monthSelectorClasses };\n\nexport type HvMonthSelectorClasses = ExtractNames<typeof useClasses>;\n\nexport const HvMonthSelector = ({\n classes: classesProp,\n id,\n locale,\n onChange,\n onViewModeChange,\n rangeMode,\n visibleMonth,\n ...others\n}: HvMonthSelectorProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n const listMonthNamesShort = getMonthNamesList(locale, \"short\");\n const onKeyDownHandler = (event, index) => {\n if (isKey(event, \"Enter\")) {\n onChange?.(event, \"month\", index + 1);\n onViewModeChange(\"calendar\");\n }\n };\n return (\n <div\n className={cx(classes.calendarMonthlyGrid, {\n [classes.rangeModeWidth]: rangeMode,\n [classes.normalWidth]: !rangeMode,\n })}\n >\n {listMonthNamesShort.map((monthName, index) => (\n <div\n className={classes.focusSelection}\n key={monthName}\n role=\"button\"\n onClick={(event) => {\n onChange?.(event, \"month\", index + 1);\n onViewModeChange(\"calendar\");\n }}\n onKeyDown={(event) => onKeyDownHandler(event, index)}\n tabIndex={0}\n {...others}\n >\n <HvTypography\n className={cx(classes.calendarMonthlyCell, {\n [classes.calendarMonthlyCellSelected]: index + 1 === visibleMonth,\n })}\n >\n {monthName}\n </HvTypography>\n </div>\n ))}\n </div>\n );\n};\n\nexport interface HvMonthSelectorProps {\n /**\n * A Jss Object used to override or extend the component styles.\n */\n classes?: HvMonthSelectorClasses;\n /**\n * Identifier.\n */\n id?: string;\n /**\n * Locale to be used by the calendar.\n */\n locale?: string;\n /**\n * Callback to define the input date.\n */\n onChange?: (\n event: any,\n action: VisibilitySelectorActions,\n value: Date | DateRangeProp | number\n ) => void;\n /**\n * Callback to define the input date.\n */\n onViewModeChange: (viewMode: ViewMode) => void;\n /**\n * Controls the visible month of the Calendar\n */\n visibleMonth: number;\n /**\n * Controls the visible month of the Calendar\n */\n visibleYear?: number;\n rangeMode?: boolean;\n}\n"],"names":["HvMonthSelector","classes","classesProp","id","locale","onChange","onViewModeChange","rangeMode","visibleMonth","others","cx","useClasses","listMonthNamesShort","getMonthNamesList","onKeyDownHandler","event","index","isKey","jsx","calendarMonthlyGrid","rangeModeWidth","normalWidth","map","monthName","focusSelection","HvTypography","calendarMonthlyCell","calendarMonthlyCellSelected"],"mappings":";;;;;;;AAeO,MAAMA,kBAAkBA,CAAC;AAAA,EAC9BC,SAASC;AAAAA,EACTC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACA,GAAGC;AACiB,MAAM;AACpB,QAAA;AAAA,IAAER;AAAAA,IAASS;AAAAA,EAAAA,IAAOC,qBAAAA,WAAWT,WAAW;AAExCU,QAAAA,sBAAsBC,MAAAA,kBAAkBT,QAAQ,OAAO;AACvDU,QAAAA,mBAAmBA,CAACC,
|
|
1
|
+
{"version":3,"file":"MonthSelector.cjs","sources":["../../../../../../src/components/Calendar/CalendarNavigation/MonthSelector/MonthSelector.tsx"],"sourcesContent":["import { isKey } from \"@core/utils/keyboardUtils\";\n\nimport { HvTypography } from \"@core/components/Typography\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { getMonthNamesList } from \"../../utils\";\nimport { ViewMode } from \"../../enums\";\nimport { DateRangeProp, VisibilitySelectorActions } from \"../../types\";\n\nimport { staticClasses, useClasses } from \"./MonthSelector.styles\";\n\nexport { staticClasses as monthSelectorClasses };\n\nexport type HvMonthSelectorClasses = ExtractNames<typeof useClasses>;\n\nexport const HvMonthSelector = ({\n classes: classesProp,\n id,\n locale,\n onChange,\n onViewModeChange,\n rangeMode,\n visibleMonth,\n ...others\n}: HvMonthSelectorProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n const listMonthNamesShort = getMonthNamesList(locale, \"short\");\n const onKeyDownHandler = (event: any, index: number) => {\n if (isKey(event, \"Enter\")) {\n onChange?.(event, \"month\", index + 1);\n onViewModeChange(\"calendar\");\n }\n };\n return (\n <div\n className={cx(classes.calendarMonthlyGrid, {\n [classes.rangeModeWidth]: rangeMode,\n [classes.normalWidth]: !rangeMode,\n })}\n >\n {listMonthNamesShort.map((monthName, index) => (\n <div\n className={classes.focusSelection}\n key={monthName}\n role=\"button\"\n onClick={(event) => {\n onChange?.(event, \"month\", index + 1);\n onViewModeChange(\"calendar\");\n }}\n onKeyDown={(event) => onKeyDownHandler(event, index)}\n tabIndex={0}\n {...others}\n >\n <HvTypography\n className={cx(classes.calendarMonthlyCell, {\n [classes.calendarMonthlyCellSelected]: index + 1 === visibleMonth,\n })}\n >\n {monthName}\n </HvTypography>\n </div>\n ))}\n </div>\n );\n};\n\nexport interface HvMonthSelectorProps {\n /**\n * A Jss Object used to override or extend the component styles.\n */\n classes?: HvMonthSelectorClasses;\n /**\n * Identifier.\n */\n id?: string;\n /**\n * Locale to be used by the calendar.\n */\n locale?: string;\n /**\n * Callback to define the input date.\n */\n onChange?: (\n event: any,\n action: VisibilitySelectorActions,\n value: Date | DateRangeProp | number\n ) => void;\n /**\n * Callback to define the input date.\n */\n onViewModeChange: (viewMode: ViewMode) => void;\n /**\n * Controls the visible month of the Calendar\n */\n visibleMonth: number;\n /**\n * Controls the visible month of the Calendar\n */\n visibleYear?: number;\n rangeMode?: boolean;\n}\n"],"names":["HvMonthSelector","classes","classesProp","id","locale","onChange","onViewModeChange","rangeMode","visibleMonth","others","cx","useClasses","listMonthNamesShort","getMonthNamesList","onKeyDownHandler","event","index","isKey","jsx","calendarMonthlyGrid","rangeModeWidth","normalWidth","map","monthName","focusSelection","HvTypography","calendarMonthlyCell","calendarMonthlyCellSelected"],"mappings":";;;;;;;AAeO,MAAMA,kBAAkBA,CAAC;AAAA,EAC9BC,SAASC;AAAAA,EACTC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACA,GAAGC;AACiB,MAAM;AACpB,QAAA;AAAA,IAAER;AAAAA,IAASS;AAAAA,EAAAA,IAAOC,qBAAAA,WAAWT,WAAW;AAExCU,QAAAA,sBAAsBC,MAAAA,kBAAkBT,QAAQ,OAAO;AACvDU,QAAAA,mBAAmBA,CAACC,OAAYC,UAAkB;AAClDC,QAAAA,cAAAA,MAAMF,OAAO,OAAO,GAAG;AACdA,iBAAAA,OAAO,SAASC,QAAQ,CAAC;AACpCV,uBAAiB,UAAU;AAAA,IAC7B;AAAA,EAAA;AAEF,SACGY,2BAAAA,IAAA,OAAA,EACC,WAAWR,GAAGT,QAAQkB,qBAAqB;AAAA,IACzC,CAAClB,QAAQmB,cAAc,GAAGb;AAAAA,IAC1B,CAACN,QAAQoB,WAAW,GAAG,CAACd;AAAAA,EAAAA,CACzB,GAEAK,UAAoBU,oBAAAA,IAAI,CAACC,WAAWP,UAClCE,+BAAA,OAAA,EACC,WAAWjB,QAAQuB,gBAEnB,MAAK,UACL,SAAUT,CAAU,UAAA;AACPA,eAAAA,OAAO,SAASC,QAAQ,CAAC;AACpCV,qBAAiB,UAAU;AAAA,EAAA,GAE7B,WAAYS,CAAAA,UAAUD,iBAAiBC,OAAOC,KAAK,GACnD,UAAU,GACNP,GAAAA,QAEJ,UAACS,2BAAAA,IAAAO,WAAA,cAAA,EACC,WAAWf,GAAGT,QAAQyB,qBAAqB;AAAA,IACzC,CAACzB,QAAQ0B,2BAA2B,GAAGX,QAAQ,MAAMR;AAAAA,EAAAA,CACtD,GAEAe,UAAAA,UACH,CAAA,EAhBKA,GAAAA,SAiBP,CACD,EACH,CAAA;AAEJ;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.cjs","sources":["../../../../src/components/Calendar/model.tsx"],"sourcesContent":["import { createDatesArray, isRange } from \"./utils\";\n\n/**\n * Calendar builder for a specific month and year.\n * Returns an array of date objects.\n */\nexport default class CalendarModel {\n month: any;\n\n year: any;\n\n dates: Date[] = [];\n\n constructor(month?: number, year?: number) {\n this.updateModel(month
|
|
1
|
+
{"version":3,"file":"model.cjs","sources":["../../../../src/components/Calendar/model.tsx"],"sourcesContent":["import { createDatesArray, isRange } from \"./utils\";\n\n/**\n * Calendar builder for a specific month and year.\n * Returns an array of date objects.\n */\nexport default class CalendarModel {\n month: any;\n\n year: any;\n\n dates: Date[] = [];\n\n constructor(month?: number, year?: number) {\n this.updateModel(month!, year!);\n }\n\n /**\n * Updates the model with the received month and year\n *\n * @param month - Number of the month (1 to 12).\n * @param year - Number of the year.\n * @memberOf CalendarModel\n */\n updateModel = (month: number, year: number) => {\n let validMonth = month;\n let validYear = year;\n if (!Number.isInteger(validMonth)) {\n validMonth = new Date().getMonth() + 1;\n }\n if (!Number.isInteger(validYear)) {\n validYear = new Date().getFullYear();\n }\n\n this.month = validMonth;\n this.year = validYear;\n this.dates = createDatesArray(validMonth, validYear);\n };\n}\n\nconst generateModelFromDate = (seedValue) => {\n let calendarModel;\n\n if (typeof seedValue === \"string\") {\n const today = new Date();\n calendarModel = new CalendarModel(\n today.getMonth() + 1,\n today.getFullYear()\n );\n } else if (isRange(seedValue)) {\n calendarModel = new CalendarModel(\n seedValue.startDate.getMonth() + 1,\n seedValue.startDate.getFullYear()\n );\n } else {\n calendarModel = new CalendarModel(\n seedValue.getMonth() + 1,\n seedValue.getFullYear()\n );\n }\n\n return calendarModel;\n};\n\nexport const generateCalendarModel = (\n seedValue: any,\n visibleMonth?: number,\n visibleYear?: number\n) => {\n let calendarModel;\n\n if (visibleMonth && visibleYear) {\n calendarModel = new CalendarModel(visibleMonth, visibleYear);\n } else if (visibleMonth && !visibleYear) {\n calendarModel = new CalendarModel(visibleMonth, seedValue.getFullYear());\n } else if (!visibleMonth && visibleYear) {\n calendarModel = new CalendarModel(1, visibleYear);\n } else {\n calendarModel = generateModelFromDate(seedValue);\n }\n\n return calendarModel;\n};\n"],"names":["CalendarModel","constructor","month","year","dates","updateModel","validMonth","validYear","Number","isInteger","Date","getMonth","getFullYear","createDatesArray","generateModelFromDate","seedValue","calendarModel","today","isRange","startDate","generateCalendarModel","visibleMonth","visibleYear"],"mappings":";;;AAMA,MAAqBA,cAAc;AAAA,EAOjCC,YAAYC,OAAgBC,MAAe;AAF3CC,SAAAA,QAAgB;AAaFC,SAAAA,cAAAA,CAACH,QAAeC,UAAiB;AAC7C,UAAIG,aAAaJ;AACjB,UAAIK,YAAYJ;AAChB,UAAI,CAACK,OAAOC,UAAUH,UAAU,GAAG;AACjCA,sBAAiBI,oBAAAA,KAAOC,GAAAA,SAAAA,IAAa;AAAA,MACvC;AACA,UAAI,CAACH,OAAOC,UAAUF,SAAS,GAAG;AACpB,qBAAA,oBAAIG,KAAK,GAAEE,YAAY;AAAA,MACrC;AAEA,WAAKV,QAAQI;AACb,WAAKH,OAAOI;AACPH,WAAAA,QAAQS,MAAAA,iBAAiBP,YAAYC,SAAS;AAAA,IAAA;AAtB9CF,SAAAA,YAAYH,OAAQC,IAAK;AAAA,EAChC;AAuBF;AAEA,MAAMW,wBAAyBC,CAAc,cAAA;AACvCC,MAAAA;AAEA,MAAA,OAAOD,cAAc,UAAU;AAC3BE,UAAAA,4BAAYP;AACF,oBAAA,IAAIV,cAClBiB,MAAMN,aAAa,GACnBM,MAAML,aACR;AAAA,EAAA,WACSM,MAAAA,QAAQH,SAAS,GAAG;AACb,oBAAA,IAAIf,cAClBe,UAAUI,UAAUR,aAAa,GACjCI,UAAUI,UAAUP,YACtB,CAAA;AAAA,EAAA,OACK;AACW,oBAAA,IAAIZ,cAClBe,UAAUJ,aAAa,GACvBI,UAAUH,aACZ;AAAA,EACF;AAEOI,SAAAA;AACT;AAEO,MAAMI,wBAAwBA,CACnCL,WACAM,cACAC,gBACG;AACCN,MAAAA;AAEJ,MAAIK,gBAAgBC,aAAa;AACf,oBAAA,IAAItB,cAAcqB,cAAcC,WAAW;AAAA,EAAA,WAClDD,gBAAgB,CAACC,aAAa;AACvCN,oBAAgB,IAAIhB,cAAcqB,cAAcN,UAAUH,YAAa,CAAA;AAAA,EAAA,WAC9D,CAACS,gBAAgBC,aAAa;AACvB,oBAAA,IAAItB,cAAc,GAAGsB,WAAW;AAAA,EAAA,OAC3C;AACLN,oBAAgBF,sBAAsBC,SAAS;AAAA,EACjD;AAEOC,SAAAA;AACT;;;"}
|
|
@@ -32,7 +32,7 @@ const HvFilterGroupRightPanel = ({
|
|
|
32
32
|
setFilterValues,
|
|
33
33
|
activeGroup
|
|
34
34
|
} = React.useContext(FilterGroupContext.HvFilterGroupContext);
|
|
35
|
-
const activeGroupOptions = React.useMemo(() => filterOptions[activeGroup]?.data.map((option) => option.id) || [], [filterOptions, activeGroup]);
|
|
35
|
+
const activeGroupOptions = React.useMemo(() => filterOptions[activeGroup]?.data.filter((option) => option.name.toLowerCase().includes(searchStr.toLowerCase())).map((option) => option.id) || [], [filterOptions, activeGroup, searchStr]);
|
|
36
36
|
const activeFilterValues = React.useMemo(() => filterValues[activeGroup]?.filter((value) => activeGroupOptions.includes(value)) || [], [filterValues, activeGroupOptions, activeGroup]);
|
|
37
37
|
const listValues = React.useMemo(() => filterOptions[activeGroup]?.data.map((option) => ({
|
|
38
38
|
...option,
|
|
@@ -57,9 +57,17 @@ const HvFilterGroupRightPanel = ({
|
|
|
57
57
|
};
|
|
58
58
|
const handleSelectAll = React.useCallback(() => {
|
|
59
59
|
const newFilterValues = cloneDeep__default.default(filterValues);
|
|
60
|
-
|
|
60
|
+
if (anySelected) {
|
|
61
|
+
if (searchStr !== "") {
|
|
62
|
+
newFilterValues[activeGroup] = filterValues[activeGroup]?.filter((value) => !activeGroupOptions.includes(value));
|
|
63
|
+
} else {
|
|
64
|
+
newFilterValues[activeGroup] = [];
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
newFilterValues[activeGroup] = [...filterValues[activeGroup], ...activeGroupOptions];
|
|
68
|
+
}
|
|
61
69
|
setFilterValues(newFilterValues);
|
|
62
|
-
}, [activeGroup, activeGroupOptions, anySelected, filterValues, setFilterValues]);
|
|
70
|
+
}, [activeGroup, activeGroupOptions, anySelected, filterValues, setFilterValues, searchStr]);
|
|
63
71
|
const SelectAll = React.useCallback(() => {
|
|
64
72
|
const nbrSelected = activeFilterValues?.length;
|
|
65
73
|
const defaultLabel = /* @__PURE__ */ jsxRuntime.jsx(Typography.HvTypography, { component: "span", children: nbrSelected > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RightPanel.cjs","sources":["../../../../../src/components/FilterGroup/RightPanel/RightPanel.tsx"],"sourcesContent":["import { useCallback, useContext, useEffect, useMemo, useState } from \"react\";\n\nimport cloneDeep from \"lodash/cloneDeep\";\n\nimport { HvCheckBox } from \"@core/components/CheckBox\";\nimport { HvInput } from \"@core/components/Input\";\nimport { HvList, HvListProps } from \"@core/components/List\";\nimport { HvPanel } from \"@core/components/Panel\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { setId } from \"@core/utils/setId\";\n\nimport { HvFilterGroupContext } from \"../FilterGroupContext\";\nimport { staticClasses, useClasses } from \"./RightPanel.styles\";\n\nexport { staticClasses as filterGroupRightPanelClasses };\n\nexport type HvFilterGroupRightPanelClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFilterGroupRightPanelProps {\n id?: string;\n className?: string;\n labels?: {\n searchBoxPlaceholder?: string;\n selectAll?: string;\n multiSelectionConjunction?: string;\n };\n emptyElement?: React.ReactNode;\n classes?: HvFilterGroupRightPanelClasses;\n}\n\nexport const HvFilterGroupRightPanel = ({\n id,\n className,\n labels,\n emptyElement,\n classes: classesProp,\n}: HvFilterGroupRightPanelProps) => {\n const { classes } = useClasses(classesProp);\n const [searchStr, setSearchStr] = useState<string>(\"\");\n const [allSelected, setAllSelected] = useState<boolean>(false);\n const [anySelected, setAnySelected] = useState<boolean>(false);\n\n const {\n filterOptions,\n filterValues = [],\n setFilterValues,\n activeGroup,\n } = useContext(HvFilterGroupContext);\n\n const activeGroupOptions = useMemo(\n () => filterOptions[activeGroup]?.data.map((option) => option.id) || [],\n [filterOptions, activeGroup]\n );\n\n const activeFilterValues = useMemo(\n () =>\n filterValues[activeGroup]?.filter((value) =>\n activeGroupOptions.includes(value)\n ) || [],\n [filterValues, activeGroupOptions, activeGroup]\n );\n\n const listValues = useMemo(\n () =>\n filterOptions[activeGroup]?.data.map((option) => ({\n ...option,\n label: option.name,\n selected: filterValues[activeGroup]?.includes(option.id),\n isHidden:\n option.name.toLowerCase().indexOf(searchStr.toLowerCase()) < 0,\n })) || [],\n [filterOptions, filterValues, activeGroup, searchStr]\n );\n\n const updateSelectAll = useCallback(() => {\n const nbrSelected = activeFilterValues?.length;\n const hasSelection = nbrSelected > 0;\n const allSelect = nbrSelected === activeGroupOptions.length;\n\n setAnySelected(hasSelection);\n setAllSelected(hasSelection && allSelect);\n }, [activeFilterValues, activeGroupOptions]);\n\n useEffect(() => {\n updateSelectAll();\n }, [activeFilterValues, updateSelectAll]);\n\n useEffect(() => setSearchStr(\"\"), [activeGroup]);\n\n const onChangeHandler: HvListProps[\"onChange\"] = (values) => {\n const newFilterValues = filterOptions.map((_, i) =>\n activeGroup === i\n ? values.filter((v) => v.selected).map((v) => v.id)\n : [...(filterValues[i] || [])]\n );\n setFilterValues(newFilterValues as any);\n };\n\n const handleSelectAll = useCallback(() => {\n const newFilterValues = cloneDeep(filterValues);\n newFilterValues[activeGroup] = anySelected ? [] : activeGroupOptions;\n\n setFilterValues(newFilterValues);\n }, [\n activeGroup,\n activeGroupOptions,\n anySelected,\n filterValues,\n setFilterValues,\n ]);\n\n /**\n * Create selectAll component.\n *\n * @returns {*}\n */\n const SelectAll = useCallback(() => {\n const nbrSelected = activeFilterValues?.length;\n\n const defaultLabel = (\n <HvTypography component=\"span\">\n {nbrSelected > 0 ? (\n <>\n <b>{nbrSelected}</b>\n {` ${labels?.multiSelectionConjunction} ${activeGroupOptions.length}`}\n </>\n ) : (\n <>\n <b>{labels?.selectAll}</b>\n {` (${activeGroupOptions.length})`}\n </>\n )}\n </HvTypography>\n );\n\n return (\n <div className={classes.selectAllContainer}>\n <HvCheckBox\n id={setId(id, \"select-all\")}\n label={defaultLabel}\n onChange={() => handleSelectAll()}\n className={classes.selectAll}\n indeterminate={anySelected && !allSelected}\n checked={allSelected}\n />\n </div>\n );\n }, [\n activeFilterValues?.length,\n activeGroupOptions.length,\n allSelected,\n anySelected,\n handleSelectAll,\n id,\n labels,\n classes?.selectAllContainer,\n classes?.selectAll,\n ]);\n\n return (\n <HvPanel id={setId(id, \"rightPanel\")} className={className}>\n {listValues.length > 0 ? (\n <>\n <HvInput\n id={setId(id, \"search\")}\n classes={{\n root: classes.search,\n }}\n type=\"search\"\n placeholder={labels?.searchBoxPlaceholder}\n value={searchStr}\n onChange={(_, str) => setSearchStr(str)}\n />\n <SelectAll />\n <HvList\n key={activeGroup}\n id={setId(id, \"list\")}\n values={listValues}\n className={classes.list}\n multiSelect\n useSelector\n showSelectAll={false}\n onChange={onChangeHandler}\n selectable\n condensed\n hasTooltips\n />\n </>\n ) : (\n emptyElement\n )}\n </HvPanel>\n );\n};\n"],"names":["HvFilterGroupRightPanel","id","className","labels","emptyElement","classes","classesProp","useClasses","searchStr","setSearchStr","useState","allSelected","setAllSelected","anySelected","setAnySelected","filterOptions","filterValues","setFilterValues","activeGroup","useContext","HvFilterGroupContext","activeGroupOptions","useMemo","data","map","option","activeFilterValues","filter","value","includes","listValues","label","name","selected","isHidden","toLowerCase","indexOf","updateSelectAll","useCallback","nbrSelected","length","hasSelection","allSelect","useEffect","onChangeHandler","values","newFilterValues","_","i","v","handleSelectAll","cloneDeep","SelectAll","defaultLabel","jsx","HvTypography","jsxs","Fragment","multiSelectionConjunction","selectAll","selectAllContainer","HvCheckBox","setId","HvPanel","HvInput","root","search","searchBoxPlaceholder","str","HvList","list"],"mappings":";;;;;;;;;;;;;;;AA+BO,MAAMA,0BAA0BA,CAAC;AAAA,EACtCC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,SAASC;AACmB,MAAM;AAC5B,QAAA;AAAA,IAAED;AAAAA,EAAAA,IAAYE,kBAAAA,WAAWD,WAAW;AAC1C,QAAM,CAACE,WAAWC,YAAY,IAAIC,eAAiB,EAAE;AACrD,QAAM,CAACC,aAAaC,cAAc,IAAIF,eAAkB,KAAK;AAC7D,QAAM,CAACG,aAAaC,cAAc,IAAIJ,eAAkB,KAAK;AAEvD,QAAA;AAAA,IACJK;AAAAA,IACAC,eAAe,CAAE;AAAA,IACjBC;AAAAA,IACAC;AAAAA,EAAAA,IACEC,MAAAA,WAAWC,mBAAAA,oBAAoB;AAEnC,QAAMC,qBAAqBC,MAAAA,QACzB,MAAMP,cAAcG,WAAW,GAAGK,KAAKC,IAAKC,CAAWA,WAAAA,OAAOxB,EAAE,KAAK,CAAA,GACrE,CAACc,eAAeG,WAAW,CAC7B;AAEA,QAAMQ,qBAAqBJ,MAAAA,QACzB,MACEN,aAAaE,WAAW,GAAGS,OAAQC,CACjCP,UAAAA,mBAAmBQ,SAASD,KAAK,CACnC,KAAK,CAAE,GACT,CAACZ,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AAA,MACPgE,MAAM5D,QAAQ6D;AAAAA,IAEhB,GAAA,MAAK,UACL,aAAa/D,QAAQgE,sBACrB,OAAO3D,WACP,UAAU,CAACuC,GAAGqB,QAAQ3D,aAAa2D,GAAG,EAAE,CAAA;AAAA,mCAEzC,WAAS,EAAA;AAAA,IACVd,2BAAAA,IAACe,KAAAA,QAEC,EAAA,IAAIP,MAAAA,MAAM7D,IAAI,MAAM,GACpB,QAAQ6B,YACR,WAAWzB,QAAQiE,MACnB,aAAW,MACX,aAAW,MACX,eAAe,OACf,UAAU1B,iBACV,YAAU,MACV,WAAS,MACT,aAAW,KAAA,GAVN1B,WAUM;AAAA,EAAA,GAEf,IAEAd,aAEJ,CAAA;AAEJ;;;"}
|
|
1
|
+
{"version":3,"file":"RightPanel.cjs","sources":["../../../../../src/components/FilterGroup/RightPanel/RightPanel.tsx"],"sourcesContent":["import { useCallback, useContext, useEffect, useMemo, useState } from \"react\";\n\nimport cloneDeep from \"lodash/cloneDeep\";\n\nimport { HvCheckBox } from \"@core/components/CheckBox\";\nimport { HvInput } from \"@core/components/Input\";\nimport { HvList, HvListProps } from \"@core/components/List\";\nimport { HvPanel } from \"@core/components/Panel\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { setId } from \"@core/utils/setId\";\n\nimport { HvFilterGroupContext } from \"../FilterGroupContext\";\nimport { staticClasses, useClasses } from \"./RightPanel.styles\";\n\nexport { staticClasses as filterGroupRightPanelClasses };\n\nexport type HvFilterGroupRightPanelClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvFilterGroupRightPanelProps {\n id?: string;\n className?: string;\n labels?: {\n searchBoxPlaceholder?: string;\n selectAll?: string;\n multiSelectionConjunction?: string;\n };\n emptyElement?: React.ReactNode;\n classes?: HvFilterGroupRightPanelClasses;\n}\n\nexport const HvFilterGroupRightPanel = ({\n id,\n className,\n labels,\n emptyElement,\n classes: classesProp,\n}: HvFilterGroupRightPanelProps) => {\n const { classes } = useClasses(classesProp);\n const [searchStr, setSearchStr] = useState<string>(\"\");\n const [allSelected, setAllSelected] = useState<boolean>(false);\n const [anySelected, setAnySelected] = useState<boolean>(false);\n\n const {\n filterOptions,\n filterValues = [],\n setFilterValues,\n activeGroup,\n } = useContext(HvFilterGroupContext);\n\n const activeGroupOptions = useMemo(\n () =>\n filterOptions[activeGroup]?.data\n .filter((option) =>\n option.name.toLowerCase().includes(searchStr.toLowerCase())\n )\n .map((option) => option.id) || [],\n [filterOptions, activeGroup, searchStr]\n );\n\n const activeFilterValues = useMemo(\n () =>\n filterValues[activeGroup]?.filter((value) =>\n activeGroupOptions.includes(value)\n ) || [],\n [filterValues, activeGroupOptions, activeGroup]\n );\n\n const listValues = useMemo(\n () =>\n filterOptions[activeGroup]?.data.map((option) => ({\n ...option,\n label: option.name,\n selected: filterValues[activeGroup]?.includes(option.id),\n isHidden:\n option.name.toLowerCase().indexOf(searchStr.toLowerCase()) < 0,\n })) || [],\n [filterOptions, filterValues, activeGroup, searchStr]\n );\n\n const updateSelectAll = useCallback(() => {\n const nbrSelected = activeFilterValues?.length;\n const hasSelection = nbrSelected > 0;\n const allSelect = nbrSelected === activeGroupOptions.length;\n\n setAnySelected(hasSelection);\n setAllSelected(hasSelection && allSelect);\n }, [activeFilterValues, activeGroupOptions]);\n\n useEffect(() => {\n updateSelectAll();\n }, [activeFilterValues, updateSelectAll]);\n\n useEffect(() => setSearchStr(\"\"), [activeGroup]);\n\n const onChangeHandler: HvListProps[\"onChange\"] = (values) => {\n const newFilterValues = filterOptions.map((_, i) =>\n activeGroup === i\n ? values.filter((v) => v.selected).map((v) => v.id)\n : [...(filterValues[i] || [])]\n );\n setFilterValues(newFilterValues as any);\n };\n\n const handleSelectAll = useCallback(() => {\n const newFilterValues = cloneDeep(filterValues);\n\n if (anySelected) {\n if (searchStr !== \"\") {\n newFilterValues[activeGroup] = filterValues[activeGroup]?.filter(\n (value) => !activeGroupOptions.includes(value)\n );\n } else {\n newFilterValues[activeGroup] = [];\n }\n } else {\n newFilterValues[activeGroup] = [\n ...filterValues[activeGroup],\n ...activeGroupOptions,\n ];\n }\n\n setFilterValues(newFilterValues);\n }, [\n activeGroup,\n activeGroupOptions,\n anySelected,\n filterValues,\n setFilterValues,\n searchStr,\n ]);\n\n /**\n * Create selectAll component.\n *\n * @returns {*}\n */\n const SelectAll = useCallback(() => {\n const nbrSelected = activeFilterValues?.length;\n\n const defaultLabel = (\n <HvTypography component=\"span\">\n {nbrSelected > 0 ? (\n <>\n <b>{nbrSelected}</b>\n {` ${labels?.multiSelectionConjunction} ${activeGroupOptions.length}`}\n </>\n ) : (\n <>\n <b>{labels?.selectAll}</b>\n {` (${activeGroupOptions.length})`}\n </>\n )}\n </HvTypography>\n );\n\n return (\n <div className={classes.selectAllContainer}>\n <HvCheckBox\n id={setId(id, \"select-all\")}\n label={defaultLabel}\n onChange={() => handleSelectAll()}\n className={classes.selectAll}\n indeterminate={anySelected && !allSelected}\n checked={allSelected}\n />\n </div>\n );\n }, [\n activeFilterValues?.length,\n activeGroupOptions.length,\n allSelected,\n anySelected,\n handleSelectAll,\n id,\n labels,\n classes?.selectAllContainer,\n classes?.selectAll,\n ]);\n\n return (\n <HvPanel id={setId(id, \"rightPanel\")} className={className}>\n {listValues.length > 0 ? (\n <>\n <HvInput\n id={setId(id, \"search\")}\n classes={{\n root: classes.search,\n }}\n type=\"search\"\n placeholder={labels?.searchBoxPlaceholder}\n value={searchStr}\n onChange={(_, str) => setSearchStr(str)}\n />\n <SelectAll />\n <HvList\n key={activeGroup}\n id={setId(id, \"list\")}\n values={listValues}\n className={classes.list}\n multiSelect\n useSelector\n showSelectAll={false}\n onChange={onChangeHandler}\n selectable\n condensed\n hasTooltips\n />\n </>\n ) : (\n emptyElement\n )}\n </HvPanel>\n );\n};\n"],"names":["HvFilterGroupRightPanel","id","className","labels","emptyElement","classes","classesProp","useClasses","searchStr","setSearchStr","useState","allSelected","setAllSelected","anySelected","setAnySelected","filterOptions","filterValues","setFilterValues","activeGroup","useContext","HvFilterGroupContext","activeGroupOptions","useMemo","data","filter","option","name","toLowerCase","includes","map","activeFilterValues","value","listValues","label","selected","isHidden","indexOf","updateSelectAll","useCallback","nbrSelected","length","hasSelection","allSelect","useEffect","onChangeHandler","values","newFilterValues","_","i","v","handleSelectAll","cloneDeep","SelectAll","defaultLabel","jsx","HvTypography","jsxs","Fragment","multiSelectionConjunction","selectAll","selectAllContainer","HvCheckBox","setId","HvPanel","HvInput","root","search","searchBoxPlaceholder","str","HvList","list"],"mappings":";;;;;;;;;;;;;;;AA+BO,MAAMA,0BAA0BA,CAAC;AAAA,EACtCC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,SAASC;AACmB,MAAM;AAC5B,QAAA;AAAA,IAAED;AAAAA,EAAAA,IAAYE,kBAAAA,WAAWD,WAAW;AAC1C,QAAM,CAACE,WAAWC,YAAY,IAAIC,eAAiB,EAAE;AACrD,QAAM,CAACC,aAAaC,cAAc,IAAIF,eAAkB,KAAK;AAC7D,QAAM,CAACG,aAAaC,cAAc,IAAIJ,eAAkB,KAAK;AAEvD,QAAA;AAAA,IACJK;AAAAA,IACAC,eAAe,CAAE;AAAA,IACjBC;AAAAA,IACAC;AAAAA,EAAAA,IACEC,MAAAA,WAAWC,mBAAAA,oBAAoB;AAEnC,QAAMC,qBAAqBC,MAAAA,QACzB,MACEP,cAAcG,WAAW,GAAGK,KACzBC,OAAQC,CACPA,WAAAA,OAAOC,KAAKC,cAAcC,SAASpB,UAAUmB,YAAa,CAAA,CAC5D,EACCE,IAAKJ,CAAAA,WAAWA,OAAOxB,EAAE,KAAK,CACnC,GAAA,CAACc,eAAeG,aAAaV,SAAS,CACxC;AAEA,QAAMsB,qBAAqBR,MAAAA,QACzB,MACEN,aAAaE,WAAW,GAAGM,OAAQO,CACjCV,UAAAA,mBAAmBO,SAASG,KAAK,CACnC,KAAK,CAAE,GACT,CAACf,cAAcK,oBAAoBH,WAAW,CAChD;AAE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,IAACS,MAAAA,SAAQ,EAAA,IAAID,MAAM7D,MAAAA,IAAI,YAAY,GAAG,WACnC+B,UAAAA,WAAWQ,SAAS,IAEjBgB,2BAAAA,KAAAC,WAAAA,UAAA,EAAA,UAAA;AAAA,IAAAH,2BAAA,IAACU,iBACC,IAAIF,MAAAA,MAAM7D,IAAI,QAAQ,GACtB,SAAS;AAAA,MACPgE,MAAM5D,QAAQ6D;AAAAA,IAEhB,GAAA,MAAK,UACL,aAAa/D,QAAQgE,sBACrB,OAAO3D,WACP,UAAU,CAACuC,GAAGqB,QAAQ3D,aAAa2D,GAAG,EAAE,CAAA;AAAA,mCAEzC,WAAS,EAAA;AAAA,IACVd,2BAAAA,IAACe,KAAAA,QAEC,EAAA,IAAIP,MAAAA,MAAM7D,IAAI,MAAM,GACpB,QAAQ+B,YACR,WAAW3B,QAAQiE,MACnB,aAAW,MACX,aAAW,MACX,eAAe,OACf,UAAU1B,iBACV,YAAU,MACV,WAAS,MACT,aAAW,KAAA,GAVN1B,WAUM;AAAA,EAAA,GAEf,IAEAd,aAEJ,CAAA;AAEJ;;;"}
|
|
@@ -4,8 +4,9 @@ const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const material = require("@mui/material");
|
|
6
6
|
const isString = require("lodash/isString");
|
|
7
|
-
const useDefaultProps = require("../../hooks/useDefaultProps.cjs");
|
|
8
7
|
const Grid_styles = require("./Grid.styles.cjs");
|
|
8
|
+
const useWidth = require("../../hooks/useWidth.cjs");
|
|
9
|
+
const useDefaultProps = require("../../hooks/useDefaultProps.cjs");
|
|
9
10
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
10
11
|
const isString__default = /* @__PURE__ */ _interopDefault(isString);
|
|
11
12
|
const BREAKPOINT_GUTTERS = {
|
|
@@ -53,8 +54,40 @@ function getNumberOfColumns(columns) {
|
|
|
53
54
|
}
|
|
54
55
|
return numberOfColumns;
|
|
55
56
|
}
|
|
57
|
+
function getContainerProps(spacing, rowSpacing, columnSpacing, columns) {
|
|
58
|
+
const containerProps = {
|
|
59
|
+
container: true
|
|
60
|
+
};
|
|
61
|
+
if (spacing != null) {
|
|
62
|
+
containerProps.spacing = getGridSpacing(spacing);
|
|
63
|
+
}
|
|
64
|
+
if (rowSpacing != null) {
|
|
65
|
+
containerProps.rowSpacing = getGridSpacing(rowSpacing);
|
|
66
|
+
}
|
|
67
|
+
if (columnSpacing != null) {
|
|
68
|
+
containerProps.columnSpacing = getGridSpacing(columnSpacing);
|
|
69
|
+
}
|
|
70
|
+
if (columns != null) {
|
|
71
|
+
containerProps.columns = getNumberOfColumns(columns);
|
|
72
|
+
}
|
|
73
|
+
return containerProps;
|
|
74
|
+
}
|
|
75
|
+
const WidthGrid = React.forwardRef((props, ref) => {
|
|
76
|
+
const {
|
|
77
|
+
container,
|
|
78
|
+
spacing,
|
|
79
|
+
rowSpacing,
|
|
80
|
+
columnSpacing,
|
|
81
|
+
columns,
|
|
82
|
+
...others
|
|
83
|
+
} = props;
|
|
84
|
+
const width = useWidth.useWidth();
|
|
85
|
+
const containerProps = container ? getContainerProps(spacing === "auto" ? width : spacing, rowSpacing === "auto" ? width : rowSpacing, columnSpacing === "auto" ? width : columnSpacing, columns) : {};
|
|
86
|
+
return /* @__PURE__ */ jsxRuntime.jsx(material.Grid, { ref, ...containerProps, ...others });
|
|
87
|
+
});
|
|
56
88
|
const HvGrid = React.forwardRef((props, ref) => {
|
|
57
89
|
const {
|
|
90
|
+
item,
|
|
58
91
|
container,
|
|
59
92
|
spacing = "auto",
|
|
60
93
|
rowSpacing,
|
|
@@ -66,23 +99,11 @@ const HvGrid = React.forwardRef((props, ref) => {
|
|
|
66
99
|
const {
|
|
67
100
|
classes
|
|
68
101
|
} = Grid_styles.useClasses(classesProp);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
containerProps.container = true;
|
|
72
|
-
if (spacing != null) {
|
|
73
|
-
containerProps.spacing = getGridSpacing(spacing);
|
|
74
|
-
}
|
|
75
|
-
if (rowSpacing != null) {
|
|
76
|
-
containerProps.rowSpacing = getGridSpacing(rowSpacing);
|
|
77
|
-
}
|
|
78
|
-
if (columnSpacing != null) {
|
|
79
|
-
containerProps.columnSpacing = getGridSpacing(columnSpacing);
|
|
80
|
-
}
|
|
81
|
-
if (columns != null) {
|
|
82
|
-
containerProps.columns = getNumberOfColumns(columns);
|
|
83
|
-
}
|
|
102
|
+
if (container && item && (spacing === "auto" || rowSpacing === "auto" || columnSpacing === "auto")) {
|
|
103
|
+
return /* @__PURE__ */ jsxRuntime.jsx(WidthGrid, { ref, classes, item, container, spacing, rowSpacing, columnSpacing, columns, ...others });
|
|
84
104
|
}
|
|
85
|
-
|
|
105
|
+
const containerProps = container ? getContainerProps(spacing, rowSpacing, columnSpacing, columns) : {};
|
|
106
|
+
return /* @__PURE__ */ jsxRuntime.jsx(material.Grid, { ref, classes, item, ...containerProps, ...others });
|
|
86
107
|
});
|
|
87
108
|
exports.gridClasses = Grid_styles.staticClasses;
|
|
88
109
|
exports.HvGrid = HvGrid;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Grid.cjs","sources":["../../../../src/components/Grid/Grid.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { Grid as MuiGrid, GridProps as MuiGridProps } from \"@mui/material\";\n\nimport isString from \"lodash/isString\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./Grid.styles\";\n\nexport { staticClasses as gridClasses };\n\nexport type HvGridClasses = ExtractNames<typeof useClasses>;\n\nconst BREAKPOINT_GUTTERS = {\n xs: 2,\n sm: 2,\n md: 4,\n lg: 4,\n xl: 4,\n};\n\nconst BREAKPOINT_COLUMNS = {\n xs: 4,\n sm: 8,\n md: 12,\n lg: 12,\n xl: 12,\n};\n\nexport type HvGridDirection =\n | \"row\"\n | \"row-reverse\"\n | \"column\"\n | \"column-reverse\";\n\nexport type HvGridSpacing =\n | \"xs\"\n | \"sm\"\n | \"md\"\n | \"lg\"\n | \"xl\"\n | \"auto\"\n | 1\n | 2\n | 3\n | 4\n | 5\n | 6\n | 7\n | 8\n | 9\n | 10;\n\nexport interface HvGridProps\n extends Omit<MuiGridProps, \"classes\" | \"columns\">,\n HvBaseProps<HTMLDivElement, \"color\"> {\n /**\n * If `true`, the component will have the flex *container* behavior.\n * You should be wrapping *items* with a *container*.\n */\n container?: boolean;\n /**\n * If `true`, the component will have the flex *item* behavior.\n * You should be wrapping *items* with a *container*.\n */\n item?: boolean;\n /**\n * Defines the space between the type item component. It can only be used on a type container component.\n * Based in the 8x factor defined in the theme, it allows the definition of this factor based on the factor\n * (number between 0 and 10), breakpoint or auto.\n */\n spacing?: HvGridSpacing | number;\n /**\n * Defines the vertical space between the type item component. It can only be used on a type container component.\n * Based in the 8x factor defined in the theme, it allows the definition of this factor based on the factor\n * (number between 0 and 10), breakpoint or auto.\n * It overrides the value of the spacing prop.\n */\n rowSpacing?: HvGridSpacing | number;\n /**\n * Defines the horizontal space between the type item component. It can only be used on a type container component.\n * Based in the 8x factor defined in the theme, it allows the definition of this factor based on the factor\n * (number between 0 and 10), breakpoint or auto.\n * It overrides the value of the spacing prop.\n */\n columnSpacing?: HvGridSpacing | number;\n /**\n * The number of columns.\n * Defaults to a 12-column grid.\n * The value \"auto\" implements the Design System directives in terms of variable number of columns.\n * @default 12\n */\n columns?: \"auto\" | MuiGridProps[\"columns\"];\n /**\n * Defines the `flex-direction` style property.\n * It is applied for all screen sizes.\n */\n direction?: HvGridDirection;\n /**\n * Defines the `justify-content` style property.\n * It is applied for all screen sizes.\n */\n justify?:\n | \"flex-start\"\n | \"center\"\n | \"flex-end\"\n | \"space-between\"\n | \"space-around\"\n | \"space-evenly\";\n /**\n * Defines the number of grids the component is going to use.\n * It's applied for all the screen sizes with the lowest priority.\n */\n xs?: number | boolean;\n /**\n * Defines the number of grids the component is going to use.\n * It's applied for the `sm` breakpoint and wider screens if not overridden.\n */\n sm?: number | boolean;\n /**\n * Defines the number of grids the component is going to use.\n * It's applied for the `md` breakpoint and wider screens if not overridden.\n */\n md?: number | boolean;\n /**\n * Defines the number of grids the component is going to use.\n * It's applied for the `lg` breakpoint and wider screens if not overridden.\n */\n lg?: number | boolean;\n /**\n * Defines the number of grids the component is going to use.\n * It's applied for the `xl` breakpoint and wider screens.\n */\n xl?: number | boolean;\n /**\n * Defines the `flex-wrap` style property.\n * It's applied for all screen sizes.\n */\n wrap?: \"nowrap\" | \"wrap\" | \"wrap-reverse\";\n /**\n * If `true`, it sets `min-width: 0` on the item.\n * Refer to the limitations section of the documentation to better understand the use case.\n */\n zeroMinWidth?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvGridClasses;\n}\n\nfunction getGridSpacing(spacing: HvGridProps[\"spacing\"]) {\n let gridSpacing: MuiGridProps[\"spacing\"];\n\n if (isString(spacing)) {\n if (spacing === \"auto\") {\n gridSpacing = BREAKPOINT_GUTTERS;\n } else {\n gridSpacing = BREAKPOINT_GUTTERS[spacing];\n }\n } else if (typeof spacing === \"object\") {\n gridSpacing = Object.keys(spacing).reduce(\n (acc, breakpoint) => ({\n ...acc,\n [breakpoint]:\n BREAKPOINT_GUTTERS[spacing[breakpoint]] ?? spacing[breakpoint],\n }),\n {}\n );\n } else if (spacing === 0) {\n gridSpacing = { xs: 0 };\n } else {\n gridSpacing = spacing;\n }\n\n return gridSpacing;\n}\n\nfunction getNumberOfColumns(columns: HvGridProps[\"columns\"]) {\n let numberOfColumns: MuiGridProps[\"columns\"];\n\n if (columns === \"auto\") {\n numberOfColumns = BREAKPOINT_COLUMNS;\n } else {\n numberOfColumns = columns;\n }\n\n return numberOfColumns;\n}\n\n/**\n * The grid creates visual consistency between layouts while allowing flexibility\n * across a wide variety of designs. This component is based on a 12-column grid layout.\n *\n * It's based on the [Material UI Grid](https://mui.com/material-ui/react-grid/).\n *\n * The definitions were set following the Design System directives:\n *\n * | Breakpoint | Width (in px) | Gutters (in px) | Number of columns |\n * | ---------- | ------------- | --------------- | ----------------- |\n * | xs | [0-600[ | 16 | 4 |\n * | sm | [600-960[ | 16 | 8 |\n * | md | [960-1270[ | 32 | 12 |\n * | lg | [1270-1920[ | 32 | 12 |\n * | xl | [1920-...[ | 32 | 12 |\n *\n * However, the number of columns is set to 12 for all breakpoints, as it serves most\n * of the use cases and simplifies the implementation.\n * To opt-in to the Design System directives, you can set the `columns` prop to `auto`.\n *\n * Also, the Design System specifications are omissive about the horizontal gutters.\n * The HvGrid sets them to the same value as the vertical gutters, depending on the breakpoint.\n * It can be overridden by setting the `rowSpacing` prop.\n */\nexport const HvGrid = forwardRef<HTMLDivElement, HvGridProps>((props, ref) => {\n const {\n container,\n spacing = \"auto\",\n rowSpacing,\n columnSpacing,\n columns,\n classes: classesProp,\n ...others\n } = useDefaultProps(\"HvGrid\", props);\n\n const { classes } = useClasses(classesProp);\n\n const containerProps: Pick<\n MuiGridProps,\n \"container\" | \"spacing\" | \"rowSpacing\" | \"columnSpacing\" | \"columns\"\n > = {};\n\n if (container) {\n containerProps.container = true;\n\n if (spacing != null) {\n containerProps.spacing = getGridSpacing(spacing);\n }\n if (rowSpacing != null) {\n containerProps.rowSpacing = getGridSpacing(rowSpacing);\n }\n if (columnSpacing != null) {\n containerProps.columnSpacing = getGridSpacing(columnSpacing);\n }\n if (columns != null) {\n containerProps.columns = getNumberOfColumns(columns);\n }\n }\n\n return (\n <MuiGrid ref={ref} classes={classes} {...containerProps} {...others} />\n );\n});\n"],"names":["BREAKPOINT_GUTTERS","xs","sm","md","lg","xl","BREAKPOINT_COLUMNS","getGridSpacing","spacing","gridSpacing","isString","Object","keys","reduce","acc","breakpoint","getNumberOfColumns","columns","numberOfColumns","HvGrid","forwardRef","props","ref","container","rowSpacing","columnSpacing","classes","classesProp","others","useDefaultProps","useClasses","containerProps","MuiGrid"],"mappings":";;;;;;;;;;AAeA,MA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AAW;AAE1C,QAAMI,iBAGF,CAAA;AAEJ,MAAIR,WAAW;AACbQ,mBAAeR,YAAY;AAE3B,QAAIf,WAAW,MAAM;AACJA,qBAAAA,UAAUD,eAAeC,OAAO;AAAA,IACjD;AACA,QAAIgB,cAAc,MAAM;AACPA,qBAAAA,aAAajB,eAAeiB,UAAU;AAAA,IACvD;AACA,QAAIC,iBAAiB,MAAM;AACVA,qBAAAA,gBAAgBlB,eAAekB,aAAa;AAAA,IAC7D;AACA,QAAIR,WAAW,MAAM;AACJA,qBAAAA,UAAUD,mBAAmBC,OAAO;AAAA,IACrD;AAAA,EACF;AAEA,wCACGe,SAAQ,MAAA,EAAA,KAAU,SAAsBD,GAAAA,gBAAgB,GAAIH,OAAU,CAAA;AAE3E,CAAC;;;"}
|
|
1
|
+
{"version":3,"file":"Grid.cjs","sources":["../../../../src/components/Grid/Grid.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { Grid as MuiGrid, GridProps as MuiGridProps } from \"@mui/material\";\n\nimport isString from \"lodash/isString\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useDefaultProps, useWidth } from \"@core/hooks\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./Grid.styles\";\n\nexport { staticClasses as gridClasses };\n\nexport type HvGridClasses = ExtractNames<typeof useClasses>;\n\nconst BREAKPOINT_GUTTERS = {\n xs: 2,\n sm: 2,\n md: 4,\n lg: 4,\n xl: 4,\n};\n\nconst BREAKPOINT_COLUMNS = {\n xs: 4,\n sm: 8,\n md: 12,\n lg: 12,\n xl: 12,\n};\n\nexport type HvGridDirection =\n | \"row\"\n | \"row-reverse\"\n | \"column\"\n | \"column-reverse\";\n\nexport type HvGridSpacing =\n | \"xs\"\n | \"sm\"\n | \"md\"\n | \"lg\"\n | \"xl\"\n | \"auto\"\n | 1\n | 2\n | 3\n | 4\n | 5\n | 6\n | 7\n | 8\n | 9\n | 10;\n\nexport interface HvGridProps\n extends Omit<MuiGridProps, \"classes\" | \"columns\">,\n HvBaseProps<HTMLDivElement, \"color\"> {\n /**\n * If `true`, the component will have the flex *container* behavior.\n * You should be wrapping *items* with a *container*.\n */\n container?: boolean;\n /**\n * If `true`, the component will have the flex *item* behavior.\n * You should be wrapping *items* with a *container*.\n */\n item?: boolean;\n /**\n * Defines the space between the type item component. It can only be used on a type container component.\n * Based in the 8x factor defined in the theme, it allows the definition of this factor based on the factor\n * (number between 0 and 10), breakpoint or auto.\n */\n spacing?: HvGridSpacing | number;\n /**\n * Defines the vertical space between the type item component. It can only be used on a type container component.\n * Based in the 8x factor defined in the theme, it allows the definition of this factor based on the factor\n * (number between 0 and 10), breakpoint or auto.\n * It overrides the value of the spacing prop.\n */\n rowSpacing?: HvGridSpacing | number;\n /**\n * Defines the horizontal space between the type item component. It can only be used on a type container component.\n * Based in the 8x factor defined in the theme, it allows the definition of this factor based on the factor\n * (number between 0 and 10), breakpoint or auto.\n * It overrides the value of the spacing prop.\n */\n columnSpacing?: HvGridSpacing | number;\n /**\n * The number of columns.\n * Defaults to a 12-column grid.\n * The value \"auto\" implements the Design System directives in terms of variable number of columns.\n * @default 12\n */\n columns?: \"auto\" | MuiGridProps[\"columns\"];\n /**\n * Defines the `flex-direction` style property.\n * It is applied for all screen sizes.\n */\n direction?: HvGridDirection;\n /**\n * Defines the `justify-content` style property.\n * It is applied for all screen sizes.\n */\n justify?:\n | \"flex-start\"\n | \"center\"\n | \"flex-end\"\n | \"space-between\"\n | \"space-around\"\n | \"space-evenly\";\n /**\n * Defines the number of grids the component is going to use.\n * It's applied for all the screen sizes with the lowest priority.\n */\n xs?: number | boolean;\n /**\n * Defines the number of grids the component is going to use.\n * It's applied for the `sm` breakpoint and wider screens if not overridden.\n */\n sm?: number | boolean;\n /**\n * Defines the number of grids the component is going to use.\n * It's applied for the `md` breakpoint and wider screens if not overridden.\n */\n md?: number | boolean;\n /**\n * Defines the number of grids the component is going to use.\n * It's applied for the `lg` breakpoint and wider screens if not overridden.\n */\n lg?: number | boolean;\n /**\n * Defines the number of grids the component is going to use.\n * It's applied for the `xl` breakpoint and wider screens.\n */\n xl?: number | boolean;\n /**\n * Defines the `flex-wrap` style property.\n * It's applied for all screen sizes.\n */\n wrap?: \"nowrap\" | \"wrap\" | \"wrap-reverse\";\n /**\n * If `true`, it sets `min-width: 0` on the item.\n * Refer to the limitations section of the documentation to better understand the use case.\n */\n zeroMinWidth?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvGridClasses;\n}\n\nfunction getGridSpacing(spacing: HvGridProps[\"spacing\"]) {\n let gridSpacing: MuiGridProps[\"spacing\"];\n\n if (isString(spacing)) {\n if (spacing === \"auto\") {\n gridSpacing = BREAKPOINT_GUTTERS;\n } else {\n gridSpacing = BREAKPOINT_GUTTERS[spacing];\n }\n } else if (typeof spacing === \"object\") {\n gridSpacing = Object.keys(spacing).reduce(\n (acc, breakpoint) => ({\n ...acc,\n [breakpoint]:\n BREAKPOINT_GUTTERS[spacing[breakpoint]] ?? spacing[breakpoint],\n }),\n {}\n );\n } else if (spacing === 0) {\n gridSpacing = { xs: 0 };\n } else {\n gridSpacing = spacing;\n }\n\n return gridSpacing;\n}\n\nfunction getNumberOfColumns(columns: HvGridProps[\"columns\"]) {\n let numberOfColumns: MuiGridProps[\"columns\"];\n\n if (columns === \"auto\") {\n numberOfColumns = BREAKPOINT_COLUMNS;\n } else {\n numberOfColumns = columns;\n }\n\n return numberOfColumns;\n}\n\nfunction getContainerProps(\n spacing: HvGridProps[\"spacing\"],\n rowSpacing: HvGridProps[\"rowSpacing\"],\n columnSpacing: HvGridProps[\"columnSpacing\"],\n columns: HvGridProps[\"columns\"]\n) {\n const containerProps: Pick<\n MuiGridProps,\n \"container\" | \"spacing\" | \"rowSpacing\" | \"columnSpacing\" | \"columns\"\n > = { container: true };\n\n if (spacing != null) {\n containerProps.spacing = getGridSpacing(spacing);\n }\n if (rowSpacing != null) {\n containerProps.rowSpacing = getGridSpacing(rowSpacing);\n }\n if (columnSpacing != null) {\n containerProps.columnSpacing = getGridSpacing(columnSpacing);\n }\n if (columns != null) {\n containerProps.columns = getNumberOfColumns(columns);\n }\n\n return containerProps;\n}\n\nconst WidthGrid = forwardRef<HTMLDivElement, HvGridProps>((props, ref) => {\n const { container, spacing, rowSpacing, columnSpacing, columns, ...others } =\n props;\n\n const width = useWidth();\n\n const containerProps = container\n ? getContainerProps(\n spacing === \"auto\" ? width : spacing,\n rowSpacing === \"auto\" ? width : rowSpacing,\n columnSpacing === \"auto\" ? width : columnSpacing,\n columns\n )\n : {};\n\n return <MuiGrid ref={ref} {...containerProps} {...others} />;\n});\n\n/**\n * The grid creates visual consistency between layouts while allowing flexibility\n * across a wide variety of designs. This component is based on a 12-column grid layout.\n *\n * It's based on the [Material UI Grid](https://mui.com/material-ui/react-grid/).\n *\n * The definitions were set following the Design System directives:\n *\n * | Breakpoint | Width (in px) | Gutters (in px) | Number of columns |\n * | ---------- | ------------- | --------------- | ----------------- |\n * | xs | [0-600[ | 16 | 4 |\n * | sm | [600-960[ | 16 | 8 |\n * | md | [960-1270[ | 32 | 12 |\n * | lg | [1270-1920[ | 32 | 12 |\n * | xl | [1920-...[ | 32 | 12 |\n *\n * However, the number of columns is set to 12 for all breakpoints, as it serves most\n * of the use cases and simplifies the implementation.\n * To opt-in to the Design System directives, you can set the `columns` prop to `auto`.\n *\n * Also, the Design System specifications are omissive about the horizontal gutters.\n * The HvGrid sets them to the same value as the vertical gutters, depending on the breakpoint.\n * It can be overridden by setting the `rowSpacing` prop.\n */\nexport const HvGrid = forwardRef<HTMLDivElement, HvGridProps>((props, ref) => {\n const {\n item,\n container,\n spacing = \"auto\",\n rowSpacing,\n columnSpacing,\n columns,\n classes: classesProp,\n ...others\n } = useDefaultProps(\"HvGrid\", props);\n\n const { classes } = useClasses(classesProp);\n\n // Fixes MUI error when using spacings as objects and the grid is an item and container\n // When set to \"auto\", the spacing changes depending on the screen's breakpoint\n // The condition avoids using useWidth and re-rendering the component unnecessarily\n if (\n container &&\n item &&\n (spacing === \"auto\" || rowSpacing === \"auto\" || columnSpacing === \"auto\")\n ) {\n return (\n <WidthGrid\n ref={ref}\n classes={classes}\n item={item}\n container={container}\n spacing={spacing}\n rowSpacing={rowSpacing}\n columnSpacing={columnSpacing}\n columns={columns}\n {...others}\n />\n );\n }\n\n const containerProps = container\n ? getContainerProps(spacing, rowSpacing, columnSpacing, columns)\n : {};\n\n return (\n <MuiGrid\n ref={ref}\n classes={classes}\n item={item}\n {...containerProps}\n {...others}\n />\n );\n});\n"],"names":["BREAKPOINT_GUTTERS","xs","sm","md","lg","xl","BREAKPOINT_COLUMNS","getGridSpacing","spacing","gridSpacing","isString","Object","keys","reduce","acc","breakpoint","getNumberOfColumns","columns","numberOfColumns","getContainerProps","rowSpacing","columnSpacing","containerProps","container","WidthGrid","forwardRef","props","ref","others","width","useWidth","MuiGrid","HvGrid","item","classes","classesProp","useDefaultProps","useClasses","jsx"],"mappings":";;;;;;;;;;;AAeA,MAAMA,qBAAqB;AAAA,EACzBC,IAAI;AAAA,EACJC,IAAI;AAAA,EACJC,IAAI;AAAA,EACJC,IAAI;AAAA,EACJC,IAAI;AACN;AAEA,MAAMC,qBAAqB;AAAA,EACzBL,IAAI;AAAA,EACJC,IAAI;AAAA,EACJC,IAAI;AAAA,EACJC,IAAI;AAAA,EACJC,IAAI;AACN;AAyHA,SAASE,eAAeC,SAAiC;AACnDC,MAAAA;AAEAC,MAAAA,kBAAAA,QAASF,OAAO,GAAG;AACrB,QAAIA,YAAY,QAAQ;AACRR,oBAAAA;AAAAA,IAAAA,OACT;AACLS,oBAAcT,mBAAmBQ,OAAO;AAAA,IAC1C;AAAA,EAAA,WACS,OAAOA,YAAY,UAAU;AACtCC,kBAAcE,OAAOC,KAAKJ,OAAO,EAAEK,OACjC,CAACC,KAAKC,gBAAgB;AAAA,MACpB,GAAGD;AAAAA,MACH,CAACC,UAAU,GACTf,mBAAmBQ,QAAQO,UAAU,CAAC,KAAKP,QAA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AAA;AAAA,IACJM;AAAAA,IACAV;AAAAA,IACAf,UAAU;AAAA,IACVY;AAAAA,IACAC;AAAAA,IACAJ;AAAAA,IACAiB,SAASC;AAAAA,IACT,GAAGP;AAAAA,EAAAA,IACDQ,gBAAgB,gBAAA,UAAUV,KAAK;AAE7B,QAAA;AAAA,IAAEQ;AAAAA,EAAAA,IAAYG,YAAAA,WAAWF,WAAW;AAK1C,MACEZ,aACAU,SACCzB,YAAY,UAAUY,eAAe,UAAUC,kBAAkB,SAClE;AAEE,WAAAiB,2BAAA,IAAC,WACC,EAAA,KACA,SACA,MACA,WACA,SACA,YACA,eACA,SACA,GAAIV,OACJ,CAAA;AAAA,EAEN;AAEMN,QAAAA,iBAAiBC,YACnBJ,kBAAkBX,SAASY,YAAYC,eAAeJ,OAAO,IAC7D;AAGF,SAAAqB,2BAAA,IAACP,iBACC,KACA,SACA,MACA,GAAIT,gBACJ,GAAIM,OACJ,CAAA;AAEN,CAAC;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Bar.cjs","sources":["../../../../../../src/components/Header/Navigation/MenuBar/Bar.tsx"],"sourcesContent":["import { useContext } from \"react\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { useDefaultProps } from \"@core/hooks\";\n\nimport { SelectionContext } from \"../utils/SelectionContext\";\nimport { staticClasses, useClasses } from \"./Bar.styles\";\nimport { HvHeaderNavigationItemProp } from \"../useSelectionPath\";\n\nexport { staticClasses as headerMenuBarClasses };\n\nexport type HvHeaderMenuBarClasses = ExtractNames<typeof useClasses>;\n\nexport interface BarProps extends HvBaseProps {\n data: HvHeaderNavigationItemProp[];\n type?:
|
|
1
|
+
{"version":3,"file":"Bar.cjs","sources":["../../../../../../src/components/Header/Navigation/MenuBar/Bar.tsx"],"sourcesContent":["import { useContext } from \"react\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { useDefaultProps } from \"@core/hooks\";\n\nimport { SelectionContext } from \"../utils/SelectionContext\";\nimport { staticClasses, useClasses } from \"./Bar.styles\";\nimport { HvHeaderNavigationItemProp } from \"../useSelectionPath\";\n\nexport { staticClasses as headerMenuBarClasses };\n\nexport type HvHeaderMenuBarClasses = ExtractNames<typeof useClasses>;\n\nexport interface BarProps extends HvBaseProps {\n data: HvHeaderNavigationItemProp[];\n type?: \"menubar\" | \"menu\";\n classes?: HvHeaderMenuBarClasses;\n}\n\nexport const Bar = (props: BarProps) => {\n const {\n id,\n data = [],\n type = \"menubar\",\n className,\n children,\n classes: classesProp,\n } = useDefaultProps(\"HvHeaderMenuBarBar\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const selectionPath = useContext(SelectionContext);\n\n const isMenu = type === \"menu\";\n\n const isActive =\n isMenu && data.filter((item) => item.id === selectionPath?.[1]).length > 0;\n\n return (\n <div\n className={cx(\n classes.root,\n classes[type],\n {\n [classes.hidden]: isMenu,\n [classes.active]: isActive,\n },\n className\n )}\n >\n <ul className={classes.list} id={id} onFocus={() => {}}>\n {children}\n </ul>\n </div>\n );\n};\n"],"names":["Bar","props","id","data","type","className","children","classes","classesProp","useDefaultProps","cx","useClasses","selectionPath","useContext","SelectionContext","isMenu","isActive","filter","item","length","jsx","root","hidden","active","list"],"mappings":";;;;;;;AAqBaA,MAAAA,MAAMA,CAACC,UAAoB;AAChC,QAAA;AAAA,IACJC;AAAAA,IACAC,OAAO,CAAE;AAAA,IACTC,OAAO;AAAA,IACPC;AAAAA,IACAC;AAAAA,IACAC,SAASC;AAAAA,EAAAA,IACPC,gBAAgB,gBAAA,sBAAsBR,KAAK;AACzC,QAAA;AAAA,IAAEM;AAAAA,IAASG;AAAAA,EAAAA,IAAOC,WAAAA,WAAWH,WAAW;AAExCI,QAAAA,gBAAgBC,iBAAWC,iBAAAA,gBAAgB;AAEjD,QAAMC,SAASX,SAAS;AAElBY,QAAAA,WACJD,UAAUZ,KAAKc,OAAQC,CAAAA,SAASA,KAAKhB,OAAOU,gBAAgB,CAAC,CAAC,EAAEO,SAAS;AAGzE,SAAAC,2BAAA,IAAC,SACC,WAAWV,GACTH,QAAQc,MACRd,QAAQH,IAAI,GACZ;AAAA,IACE,CAACG,QAAQe,MAAM,GAAGP;AAAAA,IAClB,CAACR,QAAQgB,MAAM,GAAGP;AAAAA,EACpB,GACAX,SACF,GAEA,UAACe,2BAAAA,IAAA,MAAA,EAAG,WAAWb,QAAQiB,MAAM,IAAQ,SAAS,MAAM;AAAA,EAAA,GACjDlB,UACH,EACF,CAAA;AAEJ;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuBar.cjs","sources":["../../../../../../src/components/Header/Navigation/MenuBar/MenuBar.tsx"],"sourcesContent":["import { MouseEvent } from \"react\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\n\nimport { useDefaultProps } from \"@core/hooks\";\n\nimport { HvHeaderMenuItem } from \"../MenuItem\";\nimport { HvHeaderNavigationItemProp } from \"../useSelectionPath\";\nimport { Bar, HvHeaderMenuBarClasses } from \"./Bar\";\n\nexport interface HvHeaderMenuBarProps\n extends HvBaseProps<HTMLDivElement, \"onClick\"> {\n data: HvHeaderNavigationItemProp[];\n type
|
|
1
|
+
{"version":3,"file":"MenuBar.cjs","sources":["../../../../../../src/components/Header/Navigation/MenuBar/MenuBar.tsx"],"sourcesContent":["import { MouseEvent } from \"react\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\n\nimport { useDefaultProps } from \"@core/hooks\";\n\nimport { HvHeaderMenuItem } from \"../MenuItem\";\nimport { HvHeaderNavigationItemProp } from \"../useSelectionPath\";\nimport { Bar, BarProps, HvHeaderMenuBarClasses } from \"./Bar\";\n\nexport interface HvHeaderMenuBarProps\n extends HvBaseProps<HTMLDivElement, \"onClick\"> {\n data: HvHeaderNavigationItemProp[];\n type?: BarProps[\"type\"];\n onClick?: (event: MouseEvent, selection: HvHeaderNavigationItemProp) => void;\n levels: number;\n currentLevel: number;\n classes?: HvHeaderMenuBarClasses;\n}\n\nexport const HvHeaderMenuBar = (props: HvHeaderMenuBarProps) => {\n const {\n data = [],\n onClick,\n type = \"menubar\",\n levels,\n currentLevel,\n classes,\n ...others\n } = useDefaultProps(\"HvHeaderMenuBar\", props);\n return (\n <Bar data={data} type={type} classes={classes} {...others}>\n {data.map((item: HvHeaderNavigationItemProp) => (\n <HvHeaderMenuItem\n key={item.id}\n item={item}\n type={type}\n onClick={onClick}\n levels={levels}\n currentLevel={currentLevel}\n />\n ))}\n </Bar>\n );\n};\n"],"names":["HvHeaderMenuBar","props","data","onClick","type","levels","currentLevel","classes","others","useDefaultProps","jsx","Bar","map","item","HvHeaderMenuItem","id"],"mappings":";;;;;;AAoBaA,MAAAA,kBAAkBA,CAACC,UAAgC;AACxD,QAAA;AAAA,IACJC,OAAO,CAAE;AAAA,IACTC;AAAAA,IACAC,OAAO;AAAA,IACPC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACA,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,gBAAA,mBAAmBR,KAAK;AAE1C,SAAAS,+BAACC,IAAAA,OAAI,MAAY,MAAY,SAAsBH,GAAAA,QAChDN,eAAKU,IAAI,CAACC,SACRH,2BAAA,IAAAI,2BAAA,EAEC,MACA,MACA,SACA,QACA,aALKD,GAAAA,KAAKE,EAKiB,CAE9B,EACH,CAAA;AAEJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuItem.cjs","sources":["../../../../../../src/components/Header/Navigation/MenuItem/MenuItem.tsx"],"sourcesContent":["import React, { MouseEvent, useContext } from \"react\";\n\nimport { HvTypography } from \"@core/components/Typography\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { isKey } from \"@core/utils/keyboardUtils\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { useDefaultProps } from \"@core/hooks\";\n\nimport { FocusContext } from \"../utils/FocusContext\";\nimport { SelectionContext } from \"../utils/SelectionContext\";\nimport { useClasses, staticClasses } from \"./MenuItem.styles\";\nimport { HvHeaderNavigationItemProp } from \"../useSelectionPath\";\nimport { Bar } from \"../MenuBar/Bar\";\n\nexport { staticClasses as headerMenuItemClasses };\n\nexport type HvHeaderMenuItemClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvHeaderMenuItemProps\n extends HvBaseProps<HTMLDivElement, \"onClick\"> {\n item: HvHeaderNavigationItemProp;\n type?: string;\n onClick?: (event: MouseEvent, selection: HvHeaderNavigationItemProp) => void;\n levels: number;\n currentLevel: number;\n classes?: HvHeaderMenuItemClasses;\n}\n\n// Traverse the tree of items and return the first href it finds\nconst traverseItem = (node: HvHeaderNavigationItemProp) => {\n let href;\n let target;\n\n if (node?.href) {\n href = node?.href;\n target = node?.target;\n } else if (node?.data != null && node?.data?.length > 0) {\n let i = 0;\n while (href == null && i < node.data.length) {\n const childNavItem = traverseItem(node?.data[i]);\n if (childNavItem?.href != null) {\n href = childNavItem?.href;\n target = childNavItem?.target;\n break;\n }\n\n i += 1;\n }\n }\n\n return { href, target };\n};\n\nexport const HvHeaderMenuItem = (props: HvHeaderMenuItemProps) => {\n const {\n id,\n item,\n type,\n onClick,\n levels,\n currentLevel,\n classes: classesProp,\n className,\n } = useDefaultProps(\"HvHeaderMenuItem\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const selectionPath = useContext(SelectionContext);\n\n const { dispatch } = useContext(FocusContext);\n\n const { data } = item;\n\n const hasSubLevel = data && data.length;\n\n const isMenu = type === \"menu\";\n\n const isSelected = selectionPath?.[isMenu ? 1 : 0] === item.id;\n\n // true: if the item is part of the selection path but is not the current page the user is seeing, i.e has more sub levels\n // page: used when the selected item is actually the current page the user is seeing\n const isCurrent = isSelected ? (hasSubLevel ? true : \"page\") : undefined;\n\n const actionHandler = (event: any) => {\n if (\n event.type === \"click\" ||\n isKey(event, \"Enter\") ||\n isKey(event, \"Space\")\n ) {\n if (event.type === \"click\") {\n event.currentTarget.blur();\n }\n\n onClick?.(event, item);\n }\n };\n\n const handleFocus = (event: React.FocusEvent) => {\n dispatch?.({ type: \"setItemFocused\", itemFocused: event.currentTarget });\n };\n\n const itemProps = {\n onClick: actionHandler,\n onKeyDown: actionHandler,\n onFocus: handleFocus,\n };\n\n const label = (\n <HvTypography\n component=\"span\"\n variant={isSelected ? \"label\" : \"body\"}\n data-text={item.label}\n >\n {item.label}\n </HvTypography>\n );\n\n let itemHref = item?.href;\n let itemTarget = item?.target;\n\n // apps should configure the href even on parent items without content\n // so the fallback logic is theirs, but if not we'll do our best to find a link\n if (item?.href == null) {\n const { href, target } = traverseItem(item);\n itemHref = href;\n itemTarget = target;\n }\n\n return (\n <li\n id={id}\n key={item.label}\n className={cx(\n classes.root,\n {\n [classes.menu]: isMenu,\n [classes.menubar]: !isMenu,\n [classes.selected]: !!isSelected,\n },\n className\n )}\n >\n {itemHref ? (\n <a\n className={classes.link}\n href={itemHref}\n target={itemTarget}\n {...itemProps}\n aria-current={isCurrent}\n // Fix for a possible bug in playwright where, even though hidden from screen readers and not appearing in the accessibility\n // tree, due to the styling duplication (span::after - using 'data-text'), locators have to double the name.\n aria-label={item.label}\n >\n {label}\n </a>\n ) : (\n // keeping this code path for backwards compatibility, but\n // shouldn't really be used as it's not accessible\n <div\n className={classes.button}\n role=\"button\"\n {...itemProps}\n tabIndex={0}\n aria-current={isCurrent}\n >\n {label}\n </div>\n )}\n {/* Limits levels to no more than 2. More than that is not expected and not in DS. */}\n {hasSubLevel && currentLevel < levels && currentLevel < 2 && (\n <Bar data={data} type=\"menu\">\n {data.map((itm: HvHeaderNavigationItemProp) => (\n <HvHeaderMenuItem\n key={itm.id}\n item={itm}\n type=\"menu\"\n onClick={onClick}\n levels={levels}\n currentLevel={currentLevel + 1}\n />\n ))}\n </Bar>\n )}\n </li>\n );\n};\n"],"names":["traverseItem","node","href","target","data","length","i","childNavItem","HvHeaderMenuItem","props","id","item","type","onClick","levels","currentLevel","classes","classesProp","className","useDefaultProps","cx","useClasses","selectionPath","useContext","SelectionContext","dispatch","FocusContext","hasSubLevel","isMenu","isSelected","isCurrent","undefined","actionHandler","event","isKey","currentTarget","blur","handleFocus","itemFocused","itemProps","onKeyDown","onFocus","label","jsx","HvTypography","itemHref","itemTarget","root","menu","menubar","selected","link","button","Bar","map","itm"],"mappings":";;;;;;;;;;;AA8BA,MAAMA,eAAeA,
|
|
1
|
+
{"version":3,"file":"MenuItem.cjs","sources":["../../../../../../src/components/Header/Navigation/MenuItem/MenuItem.tsx"],"sourcesContent":["import React, { MouseEvent, useContext } from \"react\";\n\nimport { HvTypography } from \"@core/components/Typography\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { isKey } from \"@core/utils/keyboardUtils\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { useDefaultProps } from \"@core/hooks\";\n\nimport { FocusContext } from \"../utils/FocusContext\";\nimport { SelectionContext } from \"../utils/SelectionContext\";\nimport { useClasses, staticClasses } from \"./MenuItem.styles\";\nimport { HvHeaderNavigationItemProp } from \"../useSelectionPath\";\nimport { Bar } from \"../MenuBar/Bar\";\n\nexport { staticClasses as headerMenuItemClasses };\n\nexport type HvHeaderMenuItemClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvHeaderMenuItemProps\n extends HvBaseProps<HTMLDivElement, \"onClick\"> {\n item: HvHeaderNavigationItemProp;\n type?: string;\n onClick?: (event: MouseEvent, selection: HvHeaderNavigationItemProp) => void;\n levels: number;\n currentLevel: number;\n classes?: HvHeaderMenuItemClasses;\n}\n\n// Traverse the tree of items and return the first href it finds\nconst traverseItem = (\n node: HvHeaderNavigationItemProp\n): { href?: string; target?: string } => {\n let href: string | undefined;\n let target: string | undefined;\n\n if (node?.href) {\n href = node?.href;\n target = node?.target;\n } else if (node?.data != null && node?.data?.length > 0) {\n let i = 0;\n while (href == null && i < node.data.length) {\n const childNavItem = traverseItem(node?.data[i]);\n if (childNavItem?.href != null) {\n href = childNavItem?.href;\n target = childNavItem?.target;\n break;\n }\n\n i += 1;\n }\n }\n\n return { href, target };\n};\n\nexport const HvHeaderMenuItem = (props: HvHeaderMenuItemProps) => {\n const {\n id,\n item,\n type,\n onClick,\n levels,\n currentLevel,\n classes: classesProp,\n className,\n } = useDefaultProps(\"HvHeaderMenuItem\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const selectionPath = useContext(SelectionContext);\n\n const { dispatch } = useContext(FocusContext);\n\n const { data } = item;\n\n const hasSubLevel = data && data.length;\n\n const isMenu = type === \"menu\";\n\n const isSelected = selectionPath?.[isMenu ? 1 : 0] === item.id;\n\n // true: if the item is part of the selection path but is not the current page the user is seeing, i.e has more sub levels\n // page: used when the selected item is actually the current page the user is seeing\n const isCurrent = isSelected ? (hasSubLevel ? true : \"page\") : undefined;\n\n const actionHandler = (event: any) => {\n if (\n event.type === \"click\" ||\n isKey(event, \"Enter\") ||\n isKey(event, \"Space\")\n ) {\n if (event.type === \"click\") {\n event.currentTarget.blur();\n }\n\n onClick?.(event, item);\n }\n };\n\n const handleFocus = (event: React.FocusEvent) => {\n dispatch?.({ type: \"setItemFocused\", itemFocused: event.currentTarget });\n };\n\n const itemProps = {\n onClick: actionHandler,\n onKeyDown: actionHandler,\n onFocus: handleFocus,\n };\n\n const label = (\n <HvTypography\n component=\"span\"\n variant={isSelected ? \"label\" : \"body\"}\n data-text={item.label}\n >\n {item.label}\n </HvTypography>\n );\n\n let itemHref = item?.href;\n let itemTarget = item?.target;\n\n // apps should configure the href even on parent items without content\n // so the fallback logic is theirs, but if not we'll do our best to find a link\n if (item?.href == null) {\n const { href, target } = traverseItem(item);\n itemHref = href;\n itemTarget = target;\n }\n\n return (\n <li\n id={id}\n key={item.label}\n className={cx(\n classes.root,\n {\n [classes.menu]: isMenu,\n [classes.menubar]: !isMenu,\n [classes.selected]: !!isSelected,\n },\n className\n )}\n >\n {itemHref ? (\n <a\n className={classes.link}\n href={itemHref}\n target={itemTarget}\n {...itemProps}\n aria-current={isCurrent}\n // Fix for a possible bug in playwright where, even though hidden from screen readers and not appearing in the accessibility\n // tree, due to the styling duplication (span::after - using 'data-text'), locators have to double the name.\n aria-label={item.label}\n >\n {label}\n </a>\n ) : (\n // keeping this code path for backwards compatibility, but\n // shouldn't really be used as it's not accessible\n <div\n className={classes.button}\n role=\"button\"\n {...itemProps}\n tabIndex={0}\n aria-current={isCurrent}\n >\n {label}\n </div>\n )}\n {/* Limits levels to no more than 2. More than that is not expected and not in DS. */}\n {hasSubLevel && currentLevel < levels && currentLevel < 2 && (\n <Bar data={data} type=\"menu\">\n {data.map((itm: HvHeaderNavigationItemProp) => (\n <HvHeaderMenuItem\n key={itm.id}\n item={itm}\n type=\"menu\"\n onClick={onClick}\n levels={levels}\n currentLevel={currentLevel + 1}\n />\n ))}\n </Bar>\n )}\n </li>\n );\n};\n"],"names":["traverseItem","node","href","target","data","length","i","childNavItem","HvHeaderMenuItem","props","id","item","type","onClick","levels","currentLevel","classes","classesProp","className","useDefaultProps","cx","useClasses","selectionPath","useContext","SelectionContext","dispatch","FocusContext","hasSubLevel","isMenu","isSelected","isCurrent","undefined","actionHandler","event","isKey","currentTarget","blur","handleFocus","itemFocused","itemProps","onKeyDown","onFocus","label","jsx","HvTypography","itemHref","itemTarget","root","menu","menubar","selected","link","button","Bar","map","itm"],"mappings":";;;;;;;;;;;AA8BA,MAAMA,eAAeA,CACnBC,SACuC;AACnCC,MAAAA;AACAC,MAAAA;AAEJ,MAAIF,MAAMC,MAAM;AACdA,WAAOD,MAAMC;AACbC,aAASF,MAAME;AAAAA,EAAAA,WACNF,MAAMG,QAAQ,QAAQH,MAAMG,MAAMC,SAAS,GAAG;AACvD,QAAIC,IAAI;AACR,WAAOJ,QAAQ,QAAQI,IAAIL,KAAKG,KAAKC,QAAQ;AAC3C,YAAME,eAAeP,aAAaC,MAAMG,KAAKE,CAAC,CAAC;AAC3CC,UAAAA,cAAcL,QAAQ,MAAM;AAC9BA,eAAOK,cAAcL;AACrBC,iBAASI,cAAcJ;AACvB;AAAA,MACF;AAEK,WAAA;AA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