@frontify/fondue 13.1.4 → 13.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/DatePicker/DatePicker.es.js.map +1 -1
- package/dist/components/DatePicker/DatePickerTrigger.es.js.map +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.umd.js.map +1 -1
- package/dist/packages/components/style.css +1 -1
- package/dist/packages/rte/style.css +1 -1
- package/dist/tools/codemod/index.js +4 -0
- package/dist/tools/internal/index.js +4 -4
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.es.js","sources":["../../../src/components/DatePicker/DatePicker.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport './styles.css';\n\nimport { offset, shift } from '@floating-ui/dom';\nimport { IconCaretLeft, IconCaretLeftDouble, IconCaretRight, IconCaretRightDouble } from '@frontify/fondue-icons';\nimport { format, getYear } from 'date-fns';\nimport { forwardRef, useRef, useState, type KeyboardEvent, type ReactNode } from 'react';\nimport ReactDatePicker from 'react-datepicker';\nimport { createPortal } from 'react-dom';\n\nimport { Button } from '@components/Button/Button';\nimport { ButtonEmphasis, ButtonSize, ButtonStyle } from '@components/Button/ButtonTypes';\nimport { merge } from '@utilities/merge';\nimport { Validation } from '@utilities/validation';\n\nimport { DatePickerTrigger } from './DatePickerTrigger';\n\n// Needed because of https://github.com/Hacker0x01/react-datepicker/issues/3834\nconst ReactDatePickerComponent =\n (ReactDatePicker as unknown as { default: typeof ReactDatePicker }).default ?? ReactDatePicker;\n\ntype SingleDatePickerProps = {\n variant?: 'single';\n onChange: (date: Date | null) => void;\n startDate?: null;\n endDate?: null;\n};\n\ntype RangeDatePickerProps = {\n variant: 'range';\n onChange: (date: [Date | null, Date | null] | null) => void;\n startDate: Date | null;\n endDate: Date | null;\n};\n\nexport type DatePickerProps = {\n placeHolder?: string;\n isClearable?: boolean;\n shouldCloseOnSelect?: boolean;\n dateFormat?: string;\n /** @description when the variant is of type 'range', the value should be the startDate */\n value?: Date | null;\n minDate?: Date;\n maxDate?: Date;\n validation?: Validation;\n customTrigger?: ReactNode;\n customHeader?: ReactNode;\n children?: ReactNode;\n hasPopperArrow?: boolean;\n preventOpenOnFocus?: boolean;\n inline?: boolean;\n filterDate?: (date: Date) => boolean;\n fixedHeight?: boolean;\n /**\n * @description When false, stretches to 100% of container width.\n * @default true\n */\n hugWidth?: boolean;\n onOpen?: () => void;\n onClose?: () => void;\n onBlur?: () => void;\n onKeyDown?: (event: KeyboardEvent<HTMLDivElement>) => void;\n triggerAriaLabel?: string;\n 'data-test-id'?: string;\n} & (SingleDatePickerProps | RangeDatePickerProps);\n\nconst getDayClasses = (variant: DatePickerProps['variant'], date: Date) => {\n if (variant === 'single') {\n return date < new Date() ? 'past-date' : 'future-date';\n }\n return 'range-day';\n};\n\nexport type ReactDatePickerRef = ReactDatePicker<boolean, undefined>;\n\nexport const DatePicker = forwardRef<ReactDatePickerRef, DatePickerProps>(\n (\n {\n placeHolder = 'Select a date',\n isClearable,\n shouldCloseOnSelect,\n onChange,\n onOpen,\n onClose,\n onBlur,\n onKeyDown,\n dateFormat = 'MMM dd, yyyy',\n value,\n startDate,\n endDate,\n minDate,\n maxDate,\n validation = Validation.Default,\n customTrigger,\n customHeader,\n children,\n fixedHeight = true,\n hasPopperArrow = true,\n preventOpenOnFocus = false,\n inline = false,\n filterDate = () => true,\n variant = 'single',\n hugWidth = true,\n 'data-test-id': dataTestId = 'date-picker',\n triggerAriaLabel = 'Open or close the date picker',\n },\n ref,\n ) => {\n const calendarCustomHeaderRef = useRef<HTMLDivElement>(null);\n const [isCalendarOpen, setIsCalendarOpen] = useState<boolean>(false);\n\n const handleOpen = () => {\n setIsCalendarOpen(true);\n onOpen?.();\n\n queueMicrotask(handleFocus);\n };\n\n const handleFocus = () => {\n calendarCustomHeaderRef.current?.querySelector<HTMLElement>('button')?.focus();\n };\n\n const handleClose = () => {\n setIsCalendarOpen(false);\n onClose?.();\n };\n\n return (\n <div data-test-id={dataTestId} className={hugWidth ? 'tw-w-auto' : 'tw-w-full'}>\n <ReactDatePickerComponent\n wrapperClassName={hugWidth ? 'tw-w-auto' : 'tw-w-full'}\n calendarClassName={merge([\n 'react-datepicker-wrap tw-pointer-events-auto',\n inline && 'react-datepicker-inline',\n ])}\n inline={inline}\n selected={value}\n startDate={startDate}\n endDate={endDate}\n minDate={minDate}\n maxDate={maxDate}\n calendarStartDay={1}\n onChange={onChange}\n onKeyDown={isCalendarOpen ? undefined : onKeyDown}\n onBlur={onBlur}\n selectsRange={variant === 'range'}\n showPopperArrow={hasPopperArrow}\n preventOpenOnFocus={preventOpenOnFocus}\n filterDate={filterDate}\n fixedHeight={fixedHeight}\n customInput={\n customTrigger ?? (\n <DatePickerTrigger\n isCalendarOpen={isCalendarOpen}\n isClearable={isClearable}\n placeHolder={placeHolder}\n validation={validation}\n onDateChanged={onChange}\n hugWidth={hugWidth}\n aria-haspopup=\"dialog\"\n aria-expanded={isCalendarOpen}\n aria-label={triggerAriaLabel}\n />\n )\n }\n ref={ref}\n formatWeekDay={(day) => day.slice(0, 1)}\n isClearable={isClearable}\n dateFormat={dateFormat}\n onCalendarClose={handleClose}\n onCalendarOpen={handleOpen}\n shouldCloseOnSelect={shouldCloseOnSelect}\n dayClassName={(date) => getDayClasses(variant, date)}\n popperProps={{\n strategy: 'fixed',\n }}\n popperContainer={({ children }) => createPortal(children, document.body)}\n popperModifiers={[shift({ padding: 8 }), offset(8)]}\n renderCustomHeader={({ date, decreaseMonth, increaseMonth, increaseYear, decreaseYear }) => (\n <div\n className=\"tw-flex tw-flex-col tw-gap-3\"\n ref={calendarCustomHeaderRef}\n data-test-id=\"date-picker-header\"\n >\n {customHeader}\n <div className=\"tw-flex tw-justify-between tw-pb-4 tw-px-0\">\n <Button\n style={ButtonStyle.Default}\n size={ButtonSize.Medium}\n onClick={decreaseYear}\n emphasis={ButtonEmphasis.Weak}\n icon={<IconCaretLeftDouble size={20} />}\n />\n <Button\n style={ButtonStyle.Default}\n size={ButtonSize.Medium}\n onClick={decreaseMonth}\n emphasis={ButtonEmphasis.Weak}\n icon={<IconCaretLeft size={20} />}\n />\n <p className=\"tw-font-sans tw-font-semibold tw-grow tw-self-center\">\n {format(date, 'MMMM')} {getYear(date)}\n </p>\n <Button\n style={ButtonStyle.Default}\n size={ButtonSize.Medium}\n onClick={increaseMonth}\n emphasis={ButtonEmphasis.Weak}\n icon={<IconCaretRight size={20} />}\n />\n <Button\n style={ButtonStyle.Default}\n size={ButtonSize.Medium}\n onClick={increaseYear}\n emphasis={ButtonEmphasis.Weak}\n icon={<IconCaretRightDouble size={20} />}\n />\n </div>\n </div>\n )}\n >\n {children}\n </ReactDatePickerComponent>\n </div>\n );\n },\n);\n\nDatePicker.displayName = 'FondueDatePicker';\n"],"names":["ReactDatePickerComponent","ReactDatePicker","getDayClasses","variant","date","DatePicker","forwardRef","placeHolder","isClearable","shouldCloseOnSelect","onChange","onOpen","onClose","onBlur","onKeyDown","dateFormat","value","startDate","endDate","minDate","maxDate","validation","Validation","customTrigger","customHeader","children","fixedHeight","hasPopperArrow","preventOpenOnFocus","inline","filterDate","hugWidth","dataTestId","triggerAriaLabel","ref","calendarCustomHeaderRef","useRef","isCalendarOpen","setIsCalendarOpen","useState","handleOpen","handleFocus","_b","_a","handleClose","jsx","merge","DatePickerTrigger","day","createPortal","shift","offset","decreaseMonth","increaseMonth","increaseYear","decreaseYear","jsxs","Button","ButtonStyle","ButtonSize","ButtonEmphasis","IconCaretLeftDouble","IconCaretLeft","format","getYear","IconCaretRight","IconCaretRightDouble"],"mappings":";;;;;;;;;;;;;AAmBA,MAAMA,KACDC,EAAmE,WAAWA,GA+C7EC,KAAgB,CAACC,GAAqCC,MACpDD,MAAY,WACLC,IAAO,oBAAI,KAAA,IAAS,cAAc,gBAEtC,aAKEC,KAAaC;AAAA,EACtB,CACI;AAAA,IACI,aAAA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;AAEApB,GAAW,cAAc;"}
|
|
1
|
+
{"version":3,"file":"DatePicker.es.js","sources":["../../../src/components/DatePicker/DatePicker.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport './styles.css';\n\nimport { offset, shift } from '@floating-ui/dom';\nimport { IconCaretLeft, IconCaretLeftDouble, IconCaretRight, IconCaretRightDouble } from '@frontify/fondue-icons';\nimport { format, getYear } from 'date-fns';\nimport { forwardRef, useRef, useState, type KeyboardEvent, type ReactNode } from 'react';\nimport ReactDatePicker from 'react-datepicker';\nimport { createPortal } from 'react-dom';\n\nimport { Button } from '@components/Button/Button';\nimport { ButtonEmphasis, ButtonSize, ButtonStyle } from '@components/Button/ButtonTypes';\nimport { merge } from '@utilities/merge';\nimport { Validation } from '@utilities/validation';\n\nimport { DatePickerTrigger } from './DatePickerTrigger';\n\n// Needed because of https://github.com/Hacker0x01/react-datepicker/issues/3834\nconst ReactDatePickerComponent =\n (ReactDatePicker as unknown as { default: typeof ReactDatePicker }).default ?? ReactDatePicker;\n\ntype SingleDatePickerProps = {\n variant?: 'single';\n onChange: (date: Date | null) => void;\n startDate?: null;\n endDate?: null;\n};\n\ntype RangeDatePickerProps = {\n variant: 'range';\n onChange: (date: [Date | null, Date | null] | null) => void;\n startDate: Date | null;\n endDate: Date | null;\n};\n\n/**\n * @deprecated Use `DatePicker` from `@frontify/fondue/components` instead.\n */\nexport type DatePickerProps = {\n placeHolder?: string;\n isClearable?: boolean;\n shouldCloseOnSelect?: boolean;\n dateFormat?: string;\n /** @description when the variant is of type 'range', the value should be the startDate */\n value?: Date | null;\n minDate?: Date;\n maxDate?: Date;\n validation?: Validation;\n customTrigger?: ReactNode;\n customHeader?: ReactNode;\n children?: ReactNode;\n hasPopperArrow?: boolean;\n preventOpenOnFocus?: boolean;\n inline?: boolean;\n filterDate?: (date: Date) => boolean;\n fixedHeight?: boolean;\n /**\n * @description When false, stretches to 100% of container width.\n * @default true\n */\n hugWidth?: boolean;\n onOpen?: () => void;\n onClose?: () => void;\n onBlur?: () => void;\n onKeyDown?: (event: KeyboardEvent<HTMLDivElement>) => void;\n triggerAriaLabel?: string;\n 'data-test-id'?: string;\n} & (SingleDatePickerProps | RangeDatePickerProps);\n\nconst getDayClasses = (variant: DatePickerProps['variant'], date: Date) => {\n if (variant === 'single') {\n return date < new Date() ? 'past-date' : 'future-date';\n }\n return 'range-day';\n};\n\n/**\n * @deprecated Use `DatePicker` from `@frontify/fondue/components` instead.\n */\nexport type ReactDatePickerRef = ReactDatePicker<boolean, undefined>;\n\n/**\n * @deprecated Use `DatePicker` from `@frontify/fondue/components` instead.\n */\nexport const DatePicker = forwardRef<ReactDatePickerRef, DatePickerProps>(\n (\n {\n placeHolder = 'Select a date',\n isClearable,\n shouldCloseOnSelect,\n onChange,\n onOpen,\n onClose,\n onBlur,\n onKeyDown,\n dateFormat = 'MMM dd, yyyy',\n value,\n startDate,\n endDate,\n minDate,\n maxDate,\n validation = Validation.Default,\n customTrigger,\n customHeader,\n children,\n fixedHeight = true,\n hasPopperArrow = true,\n preventOpenOnFocus = false,\n inline = false,\n filterDate = () => true,\n variant = 'single',\n hugWidth = true,\n 'data-test-id': dataTestId = 'date-picker',\n triggerAriaLabel = 'Open or close the date picker',\n },\n ref,\n ) => {\n const calendarCustomHeaderRef = useRef<HTMLDivElement>(null);\n const [isCalendarOpen, setIsCalendarOpen] = useState<boolean>(false);\n\n const handleOpen = () => {\n setIsCalendarOpen(true);\n onOpen?.();\n\n queueMicrotask(handleFocus);\n };\n\n const handleFocus = () => {\n calendarCustomHeaderRef.current?.querySelector<HTMLElement>('button')?.focus();\n };\n\n const handleClose = () => {\n setIsCalendarOpen(false);\n onClose?.();\n };\n\n return (\n <div data-test-id={dataTestId} className={hugWidth ? 'tw-w-auto' : 'tw-w-full'}>\n <ReactDatePickerComponent\n wrapperClassName={hugWidth ? 'tw-w-auto' : 'tw-w-full'}\n calendarClassName={merge([\n 'react-datepicker-wrap tw-pointer-events-auto',\n inline && 'react-datepicker-inline',\n ])}\n inline={inline}\n selected={value}\n startDate={startDate}\n endDate={endDate}\n minDate={minDate}\n maxDate={maxDate}\n calendarStartDay={1}\n onChange={onChange}\n onKeyDown={isCalendarOpen ? undefined : onKeyDown}\n onBlur={onBlur}\n selectsRange={variant === 'range'}\n showPopperArrow={hasPopperArrow}\n preventOpenOnFocus={preventOpenOnFocus}\n filterDate={filterDate}\n fixedHeight={fixedHeight}\n customInput={\n customTrigger ?? (\n <DatePickerTrigger\n isCalendarOpen={isCalendarOpen}\n isClearable={isClearable}\n placeHolder={placeHolder}\n validation={validation}\n onDateChanged={onChange}\n hugWidth={hugWidth}\n aria-haspopup=\"dialog\"\n aria-expanded={isCalendarOpen}\n aria-label={triggerAriaLabel}\n />\n )\n }\n ref={ref}\n formatWeekDay={(day) => day.slice(0, 1)}\n isClearable={isClearable}\n dateFormat={dateFormat}\n onCalendarClose={handleClose}\n onCalendarOpen={handleOpen}\n shouldCloseOnSelect={shouldCloseOnSelect}\n dayClassName={(date) => getDayClasses(variant, date)}\n popperProps={{\n strategy: 'fixed',\n }}\n popperContainer={({ children }) => createPortal(children, document.body)}\n popperModifiers={[shift({ padding: 8 }), offset(8)]}\n renderCustomHeader={({ date, decreaseMonth, increaseMonth, increaseYear, decreaseYear }) => (\n <div\n className=\"tw-flex tw-flex-col tw-gap-3\"\n ref={calendarCustomHeaderRef}\n data-test-id=\"date-picker-header\"\n >\n {customHeader}\n <div className=\"tw-flex tw-justify-between tw-pb-4 tw-px-0\">\n <Button\n style={ButtonStyle.Default}\n size={ButtonSize.Medium}\n onClick={decreaseYear}\n emphasis={ButtonEmphasis.Weak}\n icon={<IconCaretLeftDouble size={20} />}\n />\n <Button\n style={ButtonStyle.Default}\n size={ButtonSize.Medium}\n onClick={decreaseMonth}\n emphasis={ButtonEmphasis.Weak}\n icon={<IconCaretLeft size={20} />}\n />\n <p className=\"tw-font-sans tw-font-semibold tw-grow tw-self-center\">\n {format(date, 'MMMM')} {getYear(date)}\n </p>\n <Button\n style={ButtonStyle.Default}\n size={ButtonSize.Medium}\n onClick={increaseMonth}\n emphasis={ButtonEmphasis.Weak}\n icon={<IconCaretRight size={20} />}\n />\n <Button\n style={ButtonStyle.Default}\n size={ButtonSize.Medium}\n onClick={increaseYear}\n emphasis={ButtonEmphasis.Weak}\n icon={<IconCaretRightDouble size={20} />}\n />\n </div>\n </div>\n )}\n >\n {children}\n </ReactDatePickerComponent>\n </div>\n );\n },\n);\n\nDatePicker.displayName = 'FondueDatePicker';\n"],"names":["ReactDatePickerComponent","ReactDatePicker","getDayClasses","variant","date","DatePicker","forwardRef","placeHolder","isClearable","shouldCloseOnSelect","onChange","onOpen","onClose","onBlur","onKeyDown","dateFormat","value","startDate","endDate","minDate","maxDate","validation","Validation","customTrigger","customHeader","children","fixedHeight","hasPopperArrow","preventOpenOnFocus","inline","filterDate","hugWidth","dataTestId","triggerAriaLabel","ref","calendarCustomHeaderRef","useRef","isCalendarOpen","setIsCalendarOpen","useState","handleOpen","handleFocus","_b","_a","handleClose","jsx","merge","DatePickerTrigger","day","createPortal","shift","offset","decreaseMonth","increaseMonth","increaseYear","decreaseYear","jsxs","Button","ButtonStyle","ButtonSize","ButtonEmphasis","IconCaretLeftDouble","IconCaretLeft","format","getYear","IconCaretRight","IconCaretRightDouble"],"mappings":";;;;;;;;;;;;;AAmBA,MAAMA,KACDC,EAAmE,WAAWA,GAkD7EC,KAAgB,CAACC,GAAqCC,MACpDD,MAAY,WACLC,IAAO,oBAAI,KAAA,IAAS,cAAc,gBAEtC,aAWEC,KAAaC;AAAA,EACtB,CACI;AAAA,IACI,aAAAC,IAAc;AAAA,IACd,aAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,UAAAC;AAAA,IACA,QAAAC;AAAA,IACA,SAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAAC;AAAA,IACA,YAAAC,IAAa;AAAA,IACb,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,SAAAC;AAAA,IACA,S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A,gBAAA;AAAA,gBAEzC,gBAAAhB;AAAA,kBAACY;AAAA,kBAAA;AAAA,oBACG,OAAOC,EAAY;AAAA,oBACnB,MAAMC,EAAW;AAAA,oBACjB,SAASP;AAAA,oBACT,UAAUQ,EAAe;AAAA,oBACzB,MAAM,gBAAAf,EAACiB,GAAA,EAAc,MAAM,GAAA,CAAI;AAAA,kBAAA;AAAA,gBAAA;AAAA,gBAEnC,gBAAAN,EAAC,KAAA,EAAE,WAAU,wDACR,UAAA;AAAA,kBAAAO,EAAO3D,GAAM,MAAM;AAAA,kBAAE;AAAA,kBAAE4D,EAAQ5D,CAAI;AAAA,gBAAA,GACxC;AAAA,gBACA,gBAAAyC;AAAA,kBAACY;AAAA,kBAAA;AAAA,oBACG,OAAOC,EAAY;AAAA,oBACnB,MAAMC,EAAW;AAAA,oBACjB,SAASN;AAAA,oBACT,UAAUO,EAAe;AAAA,oBACzB,MAAM,gBAAAf,EAACoB,GAAA,EAAe,MAAM,GAAA,CAAI;AAAA,kBAAA;AAAA,gBAAA;AAAA,gBAEpC,gBAAApB;AAAA,kBAACY;AAAA,kBAAA;AAAA,oBACG,OAAOC,EAAY;AAAA,oBACnB,MAAMC,EAAW;AAAA,oBACjB,SAASL;AAAA,oBACT,UAAUM,EAAe;AAAA,oBACzB,MAAM,gBAAAf,EAACqB,GAAA,EAAqB,MAAM,GAAA,CAAI;AAAA,kBAAA;AAAA,gBAAA;AAAA,cAC1C,EAAA,CACJ;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,QAIP,UAAAzC;AAAA,MAAA;AAAA,IAAA,GAET;AAAA,EAER;AACJ;AAEApB,GAAW,cAAc;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePickerTrigger.es.js","sources":["../../../src/components/DatePicker/DatePickerTrigger.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCalendar, IconCaretDown, IconCaretUp } from '@frontify/fondue-icons';\nimport { forwardRef } from 'react';\n\nimport { TextInput } from '@components/TextInput/TextInput';\nimport { merge } from '@utilities/merge';\nimport { Validation } from '@utilities/validation';\n\ntype DatePickerTriggerProps = {\n placeHolder?: string;\n value?: string;\n isClearable?: boolean;\n isCalendarOpen?: boolean;\n onClick?: () => void;\n validation?: Validation;\n onDateChanged?: ((date: [Date | null, Date | null] | null) => void) | ((date: Date | null) => void);\n hugWidth?: boolean;\n 'aria-label': string;\n};\n\nexport const DatePickerTrigger = forwardRef<HTMLDivElement, DatePickerTriggerProps>(\n (\n {\n value,\n onClick,\n isClearable,\n placeHolder,\n isCalendarOpen,\n validation = Validation.Default,\n onDateChanged,\n hugWidth = true,\n 'aria-label': ariaLabel,\n },\n ref,\n ) => {\n const isWarningOrErrorValidationState = validation === Validation.Error || validation === Validation.Warning;\n\n const twoSlotsAwayFromRightEdge = 'tw-right-14';\n const oneSlotAwayFromRightEdge = 'tw-right-8';\n const zeroSlotsAwayFromRightEdge = 'tw-right-4';\n\n const carrotRightSideTWPositionClassByOffset = (slotsOffsetFromRighSide: number): string => {\n switch (slotsOffsetFromRighSide) {\n case 0:\n return zeroSlotsAwayFromRightEdge;\n case 1:\n return oneSlotAwayFromRightEdge;\n case 2:\n return twoSlotsAwayFromRightEdge;\n }\n return '';\n };\n\n const carrotOffsetForClearButton = value && isClearable ? 1 : 0;\n const carrotOffsetForValidationErrorIcon = isWarningOrErrorValidationState ? 1 : 0;\n\n const carrotRightSideTWPositionClass = carrotRightSideTWPositionClassByOffset(\n carrotOffsetForClearButton + carrotOffsetForValidationErrorIcon,\n );\n\n return (\n <div ref={ref} className={hugWidth ? 'tw-w-auto' : 'tw-w-full'}>\n <div\n className={merge([\n 'tw-absolute tw-top-2 tw-text-black-60 tw-z-[1]',\n carrotRightSideTWPositionClass,\n ])}\n >\n {isCalendarOpen ? <IconCaretUp size={20} /> : <IconCaretDown size={20} />}\n </div>\n <div\n className={merge([\n 'tw-absolute tw-top-0 tw-left-0 tw-bottom-0 tw-z-10',\n carrotRightSideTWPositionClass,\n ])}\n onClick={onClick}\n role=\"button\"\n tabIndex={0}\n onKeyDown={(event) => {\n if (event.key === 'Enter' || event.key === ' ') {\n onClick?.();\n }\n }}\n aria-label={ariaLabel}\n data-test-id=\"open-close-click-zone\"\n ></div>\n <TextInput\n decorator={<IconCalendar />}\n placeholder={placeHolder}\n value={value}\n clearable={isClearable}\n onEnterPressed={onClick}\n onClear={() => {\n if (onDateChanged) {\n onDateChanged(null);\n }\n }}\n validation={validation}\n />\n </div>\n );\n },\n);\n\nDatePickerTrigger.displayName = 'FondueDatePickerTrigger';\n"],"names":["DatePickerTrigger","forwardRef","value","onClick","isClearable","placeHolder","isCalendarOpen","validation","Validation","onDateChanged","hugWidth","ariaLabel","ref","isWarningOrErrorValidationState","twoSlotsAwayFromRightEdge","oneSlotAwayFromRightEdge","zeroSlotsAwayFromRightEdge","carrotRightSideTWPositionClass","slotsOffsetFromRighSide","jsx","merge","IconCaretUp","IconCaretDown","event","TextInput","IconCalendar"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"DatePickerTrigger.es.js","sources":["../../../src/components/DatePicker/DatePickerTrigger.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCalendar, IconCaretDown, IconCaretUp } from '@frontify/fondue-icons';\nimport { forwardRef } from 'react';\n\nimport { TextInput } from '@components/TextInput/TextInput';\nimport { merge } from '@utilities/merge';\nimport { Validation } from '@utilities/validation';\n\ntype DatePickerTriggerProps = {\n placeHolder?: string;\n value?: string;\n isClearable?: boolean;\n isCalendarOpen?: boolean;\n onClick?: () => void;\n validation?: Validation;\n onDateChanged?: ((date: [Date | null, Date | null] | null) => void) | ((date: Date | null) => void);\n hugWidth?: boolean;\n 'aria-label': string;\n};\n\n/**\n * @deprecated Use `DatePickerInput` from `@frontify/fondue/components` instead.\n */\nexport const DatePickerTrigger = forwardRef<HTMLDivElement, DatePickerTriggerProps>(\n (\n {\n value,\n onClick,\n isClearable,\n placeHolder,\n isCalendarOpen,\n validation = Validation.Default,\n onDateChanged,\n hugWidth = true,\n 'aria-label': ariaLabel,\n },\n ref,\n ) => {\n const isWarningOrErrorValidationState = validation === Validation.Error || validation === Validation.Warning;\n\n const twoSlotsAwayFromRightEdge = 'tw-right-14';\n const oneSlotAwayFromRightEdge = 'tw-right-8';\n const zeroSlotsAwayFromRightEdge = 'tw-right-4';\n\n const carrotRightSideTWPositionClassByOffset = (slotsOffsetFromRighSide: number): string => {\n switch (slotsOffsetFromRighSide) {\n case 0:\n return zeroSlotsAwayFromRightEdge;\n case 1:\n return oneSlotAwayFromRightEdge;\n case 2:\n return twoSlotsAwayFromRightEdge;\n }\n return '';\n };\n\n const carrotOffsetForClearButton = value && isClearable ? 1 : 0;\n const carrotOffsetForValidationErrorIcon = isWarningOrErrorValidationState ? 1 : 0;\n\n const carrotRightSideTWPositionClass = carrotRightSideTWPositionClassByOffset(\n carrotOffsetForClearButton + carrotOffsetForValidationErrorIcon,\n );\n\n return (\n <div ref={ref} className={hugWidth ? 'tw-w-auto' : 'tw-w-full'}>\n <div\n className={merge([\n 'tw-absolute tw-top-2 tw-text-black-60 tw-z-[1]',\n carrotRightSideTWPositionClass,\n ])}\n >\n {isCalendarOpen ? <IconCaretUp size={20} /> : <IconCaretDown size={20} />}\n </div>\n <div\n className={merge([\n 'tw-absolute tw-top-0 tw-left-0 tw-bottom-0 tw-z-10',\n carrotRightSideTWPositionClass,\n ])}\n onClick={onClick}\n role=\"button\"\n tabIndex={0}\n onKeyDown={(event) => {\n if (event.key === 'Enter' || event.key === ' ') {\n onClick?.();\n }\n }}\n aria-label={ariaLabel}\n data-test-id=\"open-close-click-zone\"\n ></div>\n <TextInput\n decorator={<IconCalendar />}\n placeholder={placeHolder}\n value={value}\n clearable={isClearable}\n onEnterPressed={onClick}\n onClear={() => {\n if (onDateChanged) {\n onDateChanged(null);\n }\n }}\n validation={validation}\n />\n </div>\n );\n },\n);\n\nDatePickerTrigger.displayName = 'FondueDatePickerTrigger';\n"],"names":["DatePickerTrigger","forwardRef","value","onClick","isClearable","placeHolder","isCalendarOpen","validation","Validation","onDateChanged","hugWidth","ariaLabel","ref","isWarningOrErrorValidationState","twoSlotsAwayFromRightEdge","oneSlotAwayFromRightEdge","zeroSlotsAwayFromRightEdge","carrotRightSideTWPositionClass","slotsOffsetFromRighSide","jsx","merge","IconCaretUp","IconCaretDown","event","TextInput","IconCalendar"],"mappings":";;;;;;AAwBO,MAAMA,IAAoBC;AAAA,EAC7B,CACI;AAAA,IACI,OAAAC;AAAA,IACA,SAAAC;AAAA,IACA,aAAAC;AAAA,IACA,aAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,YAAAC,IAAaC,EAAW;AAAA,IACxB,eAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,cAAcC;AAAA,EAAA,GAElBC,MACC;AACD,UAAMC,IAAkCN,MAAeC,EAAW,SAASD,MAAeC,EAAW,SAE/FM,IAA4B,eAC5BC,IAA2B,cAC3BC,IAA6B,cAiB7BC,KAfyC,CAACC,MAA4C;AACxF,cAAQA,GAAA;AAAA,QACJ,KAAK;AACD,iBAAOF;AAAA,QACX,KAAK;AACD,iBAAOD;AAAA,QACX,KAAK;AACD,iBAAOD;AAAA,MAAA;AAEf,aAAO;AAAA,IACX;AAAA,OAEmCZ,KAASE,IAAc,IAAI,MACnBS,IAAkC,IAAI;AAAA,IAGhD;AAGjC,6BACK,OAAA,EAAI,KAAAD,GAAU,WAAWF,IAAW,cAAc,aAC/C,UAAA;AAAA,MAAA,gBAAAS;AAAA,QAAC;AAAA,QAAA;AAAA,UACG,WAAWC,EAAM;AAAA,YACb;AAAA,YACAH;AAAA,UAAA,CACH;AAAA,UAEA,UAAAX,sBAAkBe,GAAA,EAAY,MAAM,IAAI,IAAK,gBAAAF,EAACG,GAAA,EAAc,MAAM,GAAA,CAAI;AAAA,QAAA;AAAA,MAAA;AAAA,MAE3E,gBAAAH;AAAA,QAAC;AAAA,QAAA;AAA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