@carbon/web-components 2.60.0 → 2.61.0-rc.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/custom-elements.json +1401 -361
- package/es/components/date-picker/date-picker-input.d.ts +13 -1
- package/es/components/date-picker/date-picker-input.d.ts.map +1 -1
- package/es/components/date-picker/date-picker-input.js +36 -16
- package/es/components/date-picker/date-picker-input.js.map +1 -1
- package/es/components/date-picker/date-picker.d.ts +6 -0
- package/es/components/date-picker/date-picker.d.ts.map +1 -1
- package/es/components/date-picker/date-picker.js +10 -2
- package/es/components/date-picker/date-picker.js.map +1 -1
- package/es/components/date-picker/date-picker.scss.js +1 -1
- package/es/components/date-picker/date-picker.scss.js.map +1 -1
- package/es/components/date-picker/defs.d.ts +18 -1
- package/es/components/date-picker/defs.d.ts.map +1 -1
- package/es/components/date-picker/defs.js +19 -1
- package/es/components/date-picker/defs.js.map +1 -1
- package/es/components/date-picker/next/adapters/web-component-adapter.d.ts +143 -0
- package/es/components/date-picker/next/adapters/web-component-adapter.d.ts.map +1 -0
- package/es/components/date-picker/next/adapters/web-component-adapter.js +215 -0
- package/es/components/date-picker/next/adapters/web-component-adapter.js.map +1 -0
- package/es/components/date-picker/next/components/calendar-renderer.d.ts +136 -0
- package/es/components/date-picker/next/components/calendar-renderer.d.ts.map +1 -0
- package/es/components/date-picker/next/components/calendar-renderer.js +278 -0
- package/es/components/date-picker/next/components/calendar-renderer.js.map +1 -0
- package/es/components/date-picker/next/components/date-picker-input-skeleton.d.ts +35 -0
- package/es/components/date-picker/next/components/date-picker-input-skeleton.d.ts.map +1 -0
- package/es/components/date-picker/next/components/date-picker-input-skeleton.js +73 -0
- package/es/components/date-picker/next/components/date-picker-input-skeleton.js.map +1 -0
- package/es/components/date-picker/next/components/date-picker-input.d.ts +196 -0
- package/es/components/date-picker/next/components/date-picker-input.d.ts.map +1 -0
- package/es/components/date-picker/next/components/date-picker-input.js +334 -0
- package/es/components/date-picker/next/components/date-picker-input.js.map +1 -0
- package/es/components/date-picker/next/components/date-picker.d.ts +329 -0
- package/es/components/date-picker/next/components/date-picker.d.ts.map +1 -0
- package/es/components/date-picker/next/components/date-picker.js +621 -0
- package/es/components/date-picker/next/components/date-picker.js.map +1 -0
- package/es/components/date-picker/next/components/date-picker.scss.js +14 -0
- package/es/components/date-picker/next/components/date-picker.scss.js.map +1 -0
- package/es/components/date-picker/next/index.d.ts +11 -0
- package/es/components/date-picker/next/index.d.ts.map +1 -0
- package/es/components/date-picker/next/index.js +11 -0
- package/es/components/dropdown/dropdown.d.ts +8 -0
- package/es/components/dropdown/dropdown.d.ts.map +1 -1
- package/es/components/dropdown/dropdown.js +4 -2
- package/es/components/dropdown/dropdown.js.map +1 -1
- package/es/components/fluid-date-picker/fluid-date-picker-input.d.ts +39 -0
- package/es/components/fluid-date-picker/fluid-date-picker-input.d.ts.map +1 -0
- package/es/components/fluid-date-picker/fluid-date-picker-input.js +59 -0
- package/es/components/fluid-date-picker/fluid-date-picker-input.js.map +1 -0
- package/es/components/fluid-date-picker/fluid-date-picker-skeleton.d.ts +20 -0
- package/es/components/fluid-date-picker/fluid-date-picker-skeleton.d.ts.map +1 -0
- package/es/components/fluid-date-picker/fluid-date-picker-skeleton.js +74 -0
- package/es/components/fluid-date-picker/fluid-date-picker-skeleton.js.map +1 -0
- package/es/components/fluid-date-picker/fluid-date-picker.d.ts +24 -0
- package/es/components/fluid-date-picker/fluid-date-picker.d.ts.map +1 -0
- package/es/components/fluid-date-picker/fluid-date-picker.js +51 -0
- package/es/components/fluid-date-picker/fluid-date-picker.js.map +1 -0
- package/es/components/fluid-date-picker/fluid-date-picker.scss.js +14 -0
- package/es/components/fluid-date-picker/fluid-date-picker.scss.js.map +1 -0
- package/es/components/fluid-date-picker/index.d.ts +10 -0
- package/es/components/fluid-date-picker/index.d.ts.map +1 -0
- package/es/components/fluid-date-picker/index.js +10 -0
- package/es/components/pagination/pagination.scss.js +1 -1
- package/es/components/password-input/password-input.d.ts.map +1 -1
- package/es/components/password-input/password-input.js +3 -2
- package/es/components/password-input/password-input.js.map +1 -1
- package/es/components/radio-button/radio-button.js +1 -1
- package/es/components/radio-button/radio-button.js.map +1 -1
- package/es/components/select/select.d.ts +8 -0
- package/es/components/select/select.d.ts.map +1 -1
- package/es/components/select/select.js +4 -2
- package/es/components/select/select.js.map +1 -1
- package/es/components/skip-to-content/skip-to-content.scss.js +1 -1
- package/es/components/text-input/text-input.d.ts +17 -0
- package/es/components/text-input/text-input.d.ts.map +1 -1
- package/es/components/text-input/text-input.js +28 -6
- package/es/components/text-input/text-input.js.map +1 -1
- package/es/components/textarea/textarea.d.ts.map +1 -1
- package/es/components/textarea/textarea.js +2 -1
- package/es/components/textarea/textarea.js.map +1 -1
- package/es/components/ui-shell/header.scss.js +1 -1
- package/es/components/ui-shell/header.scss.js.map +1 -1
- package/es/index.js +1 -1
- package/es-custom/components/date-picker/date-picker-input.d.ts +13 -1
- package/es-custom/components/date-picker/date-picker-input.d.ts.map +1 -1
- package/es-custom/components/date-picker/date-picker-input.js +36 -16
- package/es-custom/components/date-picker/date-picker-input.js.map +1 -1
- package/es-custom/components/date-picker/date-picker.d.ts +6 -0
- package/es-custom/components/date-picker/date-picker.d.ts.map +1 -1
- package/es-custom/components/date-picker/date-picker.js +10 -2
- package/es-custom/components/date-picker/date-picker.js.map +1 -1
- package/es-custom/components/date-picker/date-picker.scss.js +1 -1
- package/es-custom/components/date-picker/date-picker.scss.js.map +1 -1
- package/es-custom/components/date-picker/defs.d.ts +18 -1
- package/es-custom/components/date-picker/defs.d.ts.map +1 -1
- package/es-custom/components/date-picker/defs.js +19 -1
- package/es-custom/components/date-picker/defs.js.map +1 -1
- package/es-custom/components/date-picker/next/adapters/web-component-adapter.d.ts +143 -0
- package/es-custom/components/date-picker/next/adapters/web-component-adapter.d.ts.map +1 -0
- package/es-custom/components/date-picker/next/adapters/web-component-adapter.js +215 -0
- package/es-custom/components/date-picker/next/adapters/web-component-adapter.js.map +1 -0
- package/es-custom/components/date-picker/next/components/calendar-renderer.d.ts +136 -0
- package/es-custom/components/date-picker/next/components/calendar-renderer.d.ts.map +1 -0
- package/es-custom/components/date-picker/next/components/calendar-renderer.js +278 -0
- package/es-custom/components/date-picker/next/components/calendar-renderer.js.map +1 -0
- package/es-custom/components/date-picker/next/components/date-picker-input-skeleton.d.ts +35 -0
- package/es-custom/components/date-picker/next/components/date-picker-input-skeleton.d.ts.map +1 -0
- package/es-custom/components/date-picker/next/components/date-picker-input-skeleton.js +73 -0
- package/es-custom/components/date-picker/next/components/date-picker-input-skeleton.js.map +1 -0
- package/es-custom/components/date-picker/next/components/date-picker-input.d.ts +196 -0
- package/es-custom/components/date-picker/next/components/date-picker-input.d.ts.map +1 -0
- package/es-custom/components/date-picker/next/components/date-picker-input.js +334 -0
- package/es-custom/components/date-picker/next/components/date-picker-input.js.map +1 -0
- package/es-custom/components/date-picker/next/components/date-picker.d.ts +329 -0
- package/es-custom/components/date-picker/next/components/date-picker.d.ts.map +1 -0
- package/es-custom/components/date-picker/next/components/date-picker.js +621 -0
- package/es-custom/components/date-picker/next/components/date-picker.js.map +1 -0
- package/es-custom/components/date-picker/next/components/date-picker.scss.js +14 -0
- package/es-custom/components/date-picker/next/components/date-picker.scss.js.map +1 -0
- package/es-custom/components/date-picker/next/index.d.ts +11 -0
- package/es-custom/components/date-picker/next/index.d.ts.map +1 -0
- package/es-custom/components/date-picker/next/index.js +11 -0
- package/es-custom/components/dropdown/dropdown.d.ts +8 -0
- package/es-custom/components/dropdown/dropdown.d.ts.map +1 -1
- package/es-custom/components/dropdown/dropdown.js +4 -2
- package/es-custom/components/dropdown/dropdown.js.map +1 -1
- package/es-custom/components/fluid-date-picker/fluid-date-picker-input.d.ts +39 -0
- package/es-custom/components/fluid-date-picker/fluid-date-picker-input.d.ts.map +1 -0
- package/es-custom/components/fluid-date-picker/fluid-date-picker-input.js +59 -0
- package/es-custom/components/fluid-date-picker/fluid-date-picker-input.js.map +1 -0
- package/es-custom/components/fluid-date-picker/fluid-date-picker-skeleton.d.ts +20 -0
- package/es-custom/components/fluid-date-picker/fluid-date-picker-skeleton.d.ts.map +1 -0
- package/es-custom/components/fluid-date-picker/fluid-date-picker-skeleton.js +74 -0
- package/es-custom/components/fluid-date-picker/fluid-date-picker-skeleton.js.map +1 -0
- package/es-custom/components/fluid-date-picker/fluid-date-picker.d.ts +24 -0
- package/es-custom/components/fluid-date-picker/fluid-date-picker.d.ts.map +1 -0
- package/es-custom/components/fluid-date-picker/fluid-date-picker.js +51 -0
- package/es-custom/components/fluid-date-picker/fluid-date-picker.js.map +1 -0
- package/es-custom/components/fluid-date-picker/fluid-date-picker.scss.js +14 -0
- package/es-custom/components/fluid-date-picker/fluid-date-picker.scss.js.map +1 -0
- package/es-custom/components/fluid-date-picker/index.d.ts +10 -0
- package/es-custom/components/fluid-date-picker/index.d.ts.map +1 -0
- package/es-custom/components/fluid-date-picker/index.js +10 -0
- package/es-custom/components/pagination/pagination.scss.js +1 -1
- package/es-custom/components/password-input/password-input.d.ts.map +1 -1
- package/es-custom/components/password-input/password-input.js +3 -2
- package/es-custom/components/password-input/password-input.js.map +1 -1
- package/es-custom/components/radio-button/radio-button.js +1 -1
- package/es-custom/components/radio-button/radio-button.js.map +1 -1
- package/es-custom/components/select/select.d.ts +8 -0
- package/es-custom/components/select/select.d.ts.map +1 -1
- package/es-custom/components/select/select.js +4 -2
- package/es-custom/components/select/select.js.map +1 -1
- package/es-custom/components/skip-to-content/skip-to-content.scss.js +1 -1
- package/es-custom/components/text-input/text-input.d.ts +17 -0
- package/es-custom/components/text-input/text-input.d.ts.map +1 -1
- package/es-custom/components/text-input/text-input.js +28 -6
- package/es-custom/components/text-input/text-input.js.map +1 -1
- package/es-custom/components/textarea/textarea.d.ts.map +1 -1
- package/es-custom/components/textarea/textarea.js +2 -1
- package/es-custom/components/textarea/textarea.js.map +1 -1
- package/es-custom/components/ui-shell/header.scss.js +1 -1
- package/es-custom/components/ui-shell/header.scss.js.map +1 -1
- package/es-custom/index.js +1 -1
- package/lib/components/date-picker/date-picker-input.d.ts +13 -1
- package/lib/components/date-picker/date-picker-input.d.ts.map +1 -1
- package/lib/components/date-picker/date-picker.d.ts +6 -0
- package/lib/components/date-picker/date-picker.d.ts.map +1 -1
- package/lib/components/date-picker/defs.d.ts +18 -1
- package/lib/components/date-picker/defs.d.ts.map +1 -1
- package/lib/components/date-picker/defs.js +19 -0
- package/lib/components/date-picker/defs.js.map +1 -1
- package/lib/components/date-picker/next/adapters/web-component-adapter.d.ts +143 -0
- package/lib/components/date-picker/next/adapters/web-component-adapter.d.ts.map +1 -0
- package/lib/components/date-picker/next/components/calendar-renderer.d.ts +136 -0
- package/lib/components/date-picker/next/components/calendar-renderer.d.ts.map +1 -0
- package/lib/components/date-picker/next/components/date-picker-input-skeleton.d.ts +35 -0
- package/lib/components/date-picker/next/components/date-picker-input-skeleton.d.ts.map +1 -0
- package/lib/components/date-picker/next/components/date-picker-input.d.ts +196 -0
- package/lib/components/date-picker/next/components/date-picker-input.d.ts.map +1 -0
- package/lib/components/date-picker/next/components/date-picker.d.ts +329 -0
- package/lib/components/date-picker/next/components/date-picker.d.ts.map +1 -0
- package/lib/components/date-picker/next/index.d.ts +11 -0
- package/lib/components/date-picker/next/index.d.ts.map +1 -0
- package/lib/components/dropdown/dropdown.d.ts +8 -0
- package/lib/components/dropdown/dropdown.d.ts.map +1 -1
- package/lib/components/fluid-date-picker/fluid-date-picker-input.d.ts +39 -0
- package/lib/components/fluid-date-picker/fluid-date-picker-input.d.ts.map +1 -0
- package/lib/components/fluid-date-picker/fluid-date-picker-skeleton.d.ts +20 -0
- package/lib/components/fluid-date-picker/fluid-date-picker-skeleton.d.ts.map +1 -0
- package/lib/components/fluid-date-picker/fluid-date-picker.d.ts +24 -0
- package/lib/components/fluid-date-picker/fluid-date-picker.d.ts.map +1 -0
- package/lib/components/fluid-date-picker/index.d.ts +10 -0
- package/lib/components/fluid-date-picker/index.d.ts.map +1 -0
- package/lib/components/password-input/password-input.d.ts.map +1 -1
- package/lib/components/select/select.d.ts +8 -0
- package/lib/components/select/select.d.ts.map +1 -1
- package/lib/components/text-input/text-input.d.ts +17 -0
- package/lib/components/text-input/text-input.d.ts.map +1 -1
- package/lib/components/textarea/textarea.d.ts.map +1 -1
- package/package.json +10 -10
- package/scss/components/date-picker/date-picker.scss +6 -0
- package/scss/components/date-picker/next/components/date-picker.scss +124 -0
- package/scss/components/fluid-date-picker/fluid-date-picker.scss +282 -0
- package/scss/components/ui-shell/header.scss +14 -8
- package/telemetry.yml +29 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-component-adapter.js","names":[],"sources":["../../../../../src/components/date-picker/next/adapters/web-component-adapter.ts"],"sourcesContent":["/**\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { DatePickerStateMachine } from '@carbon/utilities/date-picker';\nimport {\n DatePickerState,\n DatePickerEvent,\n} from '@carbon/utilities/date-picker';\nimport { dateToPlainDate } from '@carbon/utilities/date-picker';\nimport type {\n DatePickerContext,\n StateTransition,\n DateSelectPayload,\n} from '@carbon/utilities/date-picker';\nimport type CDSDatePicker from '../components/date-picker';\n\n/**\n * Adapter configuration\n */\nexport interface AdapterConfig {\n /** The date picker component instance */\n component: CDSDatePicker;\n /** Initial context values */\n initialContext?: Partial<DatePickerContext>;\n /** Callback when state changes */\n onStateChange?: (transition: StateTransition) => void;\n /** Callback when the calendar should open */\n onCalendarOpen?: () => void;\n /** Callback when the calendar should close */\n onCalendarClose?: () => void;\n /** Callback when the date is selected */\n onDateSelect?: (context: DatePickerContext) => void;\n}\n\n/**\n * Web Component Adapter\n * Bridges the state machine with the Web Component implementation\n */\nexport class WebComponentAdapter {\n private machine: DatePickerStateMachine;\n private component: CDSDatePicker;\n private config: AdapterConfig;\n private unsubscribe?: () => void;\n\n /**\n * Create a new adapter\n *\n * @param {AdapterConfig} config - Adapter configuration\n */\n constructor(config: AdapterConfig) {\n this.config = config;\n this.component = config.component;\n this.machine = new DatePickerStateMachine(config.initialContext);\n\n // Subscribe to state changes\n this.unsubscribe = this.machine.subscribe((transition) => {\n this.handleStateChange(transition);\n });\n }\n\n /**\n * Send an event to the state machine\n *\n * @param {string} event - Event type\n * @param {unknown} payload - Event payload\n * @returns Updated context\n */\n public send(event: string, payload?: unknown): DatePickerContext {\n return this.machine.send(event, payload);\n }\n\n /**\n * Get the current state\n *\n * @returns Current state\n */\n public getState(): DatePickerState {\n return this.machine.getState();\n }\n\n /**\n * Get the current context\n *\n * @returns Current context\n */\n public getContext(): DatePickerContext {\n return this.machine.getContext();\n }\n\n /**\n * Update context directly\n *\n * @param {Partial<DatePickerContext>} updates - Context updates\n * @returns Updated context\n */\n public updateContext(updates: Partial<DatePickerContext>): DatePickerContext {\n return this.machine.updateContext(updates);\n }\n\n /**\n * Check if a transition is valid\n *\n * @param {string} event - Event type\n * @returns True if transition is valid\n */\n public canTransition(event: string): boolean {\n return this.machine.canTransition(event);\n }\n\n /**\n * Handle state changes\n *\n * @param {StateTransition} transition - State transition\n */\n private handleStateChange(transition: StateTransition): void {\n const { from, to, context } = transition;\n\n // Sync component properties with state machine context\n this.syncComponentProperties(context);\n\n // Handle specific state transitions\n this.handleTransitionEffects(from, to, context);\n\n // Call user callback\n if (this.config.onStateChange) {\n this.config.onStateChange(transition);\n }\n\n // Dispatch custom event\n (this.component as unknown as HTMLElement).dispatchEvent(\n new CustomEvent('cds-preview-date-picker-state-change', {\n detail: { transition },\n bubbles: true,\n composed: true,\n })\n );\n }\n\n /**\n * Sync component properties with context\n *\n * @param {DatePickerContext} context - Current context\n */\n private syncComponentProperties(context: DatePickerContext): void {\n // Sync open state\n if (this.component.open !== context.isOpen) {\n this.component.open = context.isOpen;\n }\n\n // Sync value\n if (this.component.value !== context.value) {\n this.component.value = context.value;\n }\n\n // Sync disabled state\n if (this.component.disabled !== context.isDisabled) {\n this.component.disabled = context.isDisabled;\n }\n\n // Sync readonly state\n if (this.component.readonly !== context.isReadonly) {\n this.component.readonly = context.isReadonly;\n }\n }\n\n /**\n * Handle transition-specific effects\n *\n * @param {string} from - Previous state\n * @param {string} to - New state\n * @param {DatePickerContext} context - Current context\n */\n private handleTransitionEffects(\n from: string,\n to: string,\n context: DatePickerContext\n ): void {\n // Handle calendar opening\n if (\n to === DatePickerState.CALENDAR_OPEN &&\n from !== DatePickerState.CALENDAR_OPEN\n ) {\n if (this.config.onCalendarOpen) {\n this.config.onCalendarOpen();\n }\n }\n\n // Handle calendar closing\n if (\n from === DatePickerState.CALENDAR_OPEN &&\n to !== DatePickerState.CALENDAR_OPEN\n ) {\n if (this.config.onCalendarClose) {\n this.config.onCalendarClose();\n }\n }\n\n // Handle date selection\n if (to === DatePickerState.DATE_SELECTED) {\n if (this.config.onDateSelect) {\n this.config.onDateSelect(context);\n }\n }\n }\n\n /**\n * Handle calendar date selection\n * Call this from the calendar's onChange callback\n *\n * @param {Date[]} selectedDates - Selected dates from calendar\n */\n public handleCalendarChange(selectedDates: Date[]): void {\n const context = this.getContext();\n\n if (context.mode === 'single' && selectedDates.length > 0) {\n const date = dateToPlainDate(selectedDates[0]);\n this.send(DatePickerEvent.DATE_SELECT, {\n date,\n } as DateSelectPayload);\n } else if (context.mode === 'range') {\n if (selectedDates.length === 1) {\n const date = dateToPlainDate(selectedDates[0]);\n this.send(DatePickerEvent.RANGE_START_SELECT, {\n date,\n } as DateSelectPayload);\n } else if (selectedDates.length === 2) {\n const date = dateToPlainDate(selectedDates[1]);\n this.send(DatePickerEvent.RANGE_END_SELECT, {\n date,\n } as DateSelectPayload);\n }\n }\n }\n\n /**\n * Handle calendar open event\n */\n public handleCalendarOpen(): void {\n const currentState = this.getState();\n if (currentState !== DatePickerState.CALENDAR_OPEN) {\n this.send(DatePickerEvent.CALENDAR_OPEN);\n }\n }\n\n /**\n * Handle calendar close event\n */\n public handleCalendarClose(): void {\n const currentState = this.getState();\n if (currentState === DatePickerState.CALENDAR_OPEN) {\n this.send(DatePickerEvent.CALENDAR_CLOSE);\n }\n }\n\n /**\n * Handle input focus\n *\n * @param {('from' | 'to')} inputType - Type of input ('from' or 'to')\n */\n public handleInputFocus(inputType: 'from' | 'to'): void {\n this.send(DatePickerEvent.INPUT_FOCUS, { inputType });\n }\n\n /**\n * Handle input blur\n */\n public handleInputBlur(): void {\n this.send(DatePickerEvent.INPUT_BLUR);\n }\n\n /**\n * Handle outside click\n */\n public handleOutsideClick(): void {\n this.send(DatePickerEvent.OUTSIDE_CLICK);\n }\n\n /**\n * Handle keyboard events\n *\n * @param {string} key - Key pressed\n * @param {boolean} shiftKey - Whether shift key was pressed\n */\n public handleKeyboard(key: string, shiftKey = false): void {\n switch (key) {\n case 'Escape':\n this.send(DatePickerEvent.ESCAPE_KEY);\n break;\n case 'Tab':\n if (shiftKey) {\n this.send(DatePickerEvent.SHIFT_TAB_KEY);\n } else {\n this.send(DatePickerEvent.TAB_KEY);\n }\n break;\n case 'Enter':\n this.send(DatePickerEvent.ENTER_KEY);\n break;\n default:\n break;\n }\n }\n\n /**\n * Reset the state machine\n *\n * @param {Partial<DatePickerContext>} initialContext - Optional new initial context\n */\n public reset(initialContext?: Partial<DatePickerContext>): void {\n this.machine.reset(initialContext);\n }\n\n /**\n * Cleanup and unsubscribe\n */\n public destroy(): void {\n if (this.unsubscribe) {\n this.unsubscribe();\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0CA,IAAa,sBAAb,MAAiC;;;;;;CAW/B,YAAY,QAAuB;EACjC,KAAK,SAAS;EACd,KAAK,YAAY,OAAO;EACxB,KAAK,UAAU,IAAI,uBAAuB,OAAO,cAAc;EAG/D,KAAK,cAAc,KAAK,QAAQ,WAAW,eAAe;GACxD,KAAK,kBAAkB,UAAU;EACnC,CAAC;CACH;;;;;;;;CASA,KAAY,OAAe,SAAsC;EAC/D,OAAO,KAAK,QAAQ,KAAK,OAAO,OAAO;CACzC;;;;;;CAOA,WAAm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
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { LitElement } from 'lit';
|
|
8
|
+
import type { PropertyValues } from 'lit';
|
|
9
|
+
/**
|
|
10
|
+
* Calendar renderer for date picker.
|
|
11
|
+
* Replaces Flatpickr's calendar UI with a lightweight, framework-agnostic implementation.
|
|
12
|
+
*
|
|
13
|
+
* @element cds-preview-date-picker-calendar
|
|
14
|
+
* @fires cds-preview-date-picker-calendar-date-select - Fired when a date is selected
|
|
15
|
+
* @fires cds-preview-date-picker-calendar-month-change - Fired when the month changes
|
|
16
|
+
*/
|
|
17
|
+
declare class CDSDatePickerCalendar extends LitElement {
|
|
18
|
+
/**
|
|
19
|
+
* The currently displayed month (Temporal.PlainYearMonth)
|
|
20
|
+
*/
|
|
21
|
+
private _currentMonth;
|
|
22
|
+
/**
|
|
23
|
+
* The selected date(s)
|
|
24
|
+
*/
|
|
25
|
+
selectedDates: Temporal.PlainDate[];
|
|
26
|
+
/**
|
|
27
|
+
* The view date from the state machine (used to sync calendar month)
|
|
28
|
+
*/
|
|
29
|
+
viewDate?: Temporal.PlainDate;
|
|
30
|
+
/**
|
|
31
|
+
* The focused date for keyboard navigation
|
|
32
|
+
*/
|
|
33
|
+
focusedDate?: Temporal.PlainDate | null;
|
|
34
|
+
/**
|
|
35
|
+
* The currently hovered date (for range preview)
|
|
36
|
+
*/
|
|
37
|
+
private _hoveredDate?;
|
|
38
|
+
/**
|
|
39
|
+
* The minimum selectable date
|
|
40
|
+
*/
|
|
41
|
+
minDate?: Temporal.PlainDate;
|
|
42
|
+
/**
|
|
43
|
+
* The maximum selectable date
|
|
44
|
+
*/
|
|
45
|
+
maxDate?: Temporal.PlainDate;
|
|
46
|
+
/**
|
|
47
|
+
* Whether range selection is enabled
|
|
48
|
+
*/
|
|
49
|
+
rangeMode: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* The date format for display
|
|
52
|
+
*/
|
|
53
|
+
dateFormat: string;
|
|
54
|
+
/**
|
|
55
|
+
* Locale for date formatting
|
|
56
|
+
*/
|
|
57
|
+
locale: string;
|
|
58
|
+
/**
|
|
59
|
+
* Navigate to previous month
|
|
60
|
+
*/
|
|
61
|
+
private _handlePrevMonth;
|
|
62
|
+
/**
|
|
63
|
+
* Navigate to next month
|
|
64
|
+
*/
|
|
65
|
+
private _handleNextMonth;
|
|
66
|
+
/**
|
|
67
|
+
* Handle date selection
|
|
68
|
+
* @param {Temporal.PlainDate} date - The date to select
|
|
69
|
+
*/
|
|
70
|
+
private _handleDateSelect;
|
|
71
|
+
/**
|
|
72
|
+
* Dispatch month change event
|
|
73
|
+
*/
|
|
74
|
+
private _dispatchMonthChange;
|
|
75
|
+
/**
|
|
76
|
+
* Check if a date is disabled
|
|
77
|
+
* @param {Temporal.PlainDate} date - The date to check
|
|
78
|
+
*/
|
|
79
|
+
private _isDateDisabled;
|
|
80
|
+
/**
|
|
81
|
+
* Check if previous month navigation should be disabled
|
|
82
|
+
*/
|
|
83
|
+
private _isPrevMonthDisabled;
|
|
84
|
+
/**
|
|
85
|
+
* Check if next month navigation should be disabled
|
|
86
|
+
*/
|
|
87
|
+
private _isNextMonthDisabled;
|
|
88
|
+
/**
|
|
89
|
+
* Check if a date is selected
|
|
90
|
+
* @param {Temporal.PlainDate} date - The date to check
|
|
91
|
+
*/
|
|
92
|
+
private _isDateSelected;
|
|
93
|
+
/**
|
|
94
|
+
* Check if a date is in range (for range mode)
|
|
95
|
+
* @param {Temporal.PlainDate} date - The date to check
|
|
96
|
+
*/
|
|
97
|
+
private _isDateInRange;
|
|
98
|
+
/**
|
|
99
|
+
* Check if a date is focused (for keyboard navigation)
|
|
100
|
+
* @param {Temporal.PlainDate} date - The date to check
|
|
101
|
+
*/
|
|
102
|
+
private _isDateFocused;
|
|
103
|
+
/**
|
|
104
|
+
* Handle mouse enter on a date
|
|
105
|
+
* @param {Temporal.PlainDate} date - The date being hovered
|
|
106
|
+
*/
|
|
107
|
+
private _handleDateMouseEnter;
|
|
108
|
+
/**
|
|
109
|
+
* Handle mouse leave on a date
|
|
110
|
+
*/
|
|
111
|
+
private _handleDateMouseLeave;
|
|
112
|
+
/**
|
|
113
|
+
* Render the calendar header with month/year and navigation
|
|
114
|
+
*/
|
|
115
|
+
private _renderHeader;
|
|
116
|
+
/**
|
|
117
|
+
* Render the weekday headers
|
|
118
|
+
*/
|
|
119
|
+
private _renderWeekdays;
|
|
120
|
+
/**
|
|
121
|
+
* Render the calendar days grid
|
|
122
|
+
*/
|
|
123
|
+
private _renderDays;
|
|
124
|
+
/**
|
|
125
|
+
* Lifecycle method called when properties change
|
|
126
|
+
* @param {PropertyValues} changedProperties - Changed properties
|
|
127
|
+
*/
|
|
128
|
+
updated(changedProperties: PropertyValues): void;
|
|
129
|
+
/**
|
|
130
|
+
* Renders the calendar component
|
|
131
|
+
*/
|
|
132
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
133
|
+
static styles: any;
|
|
134
|
+
}
|
|
135
|
+
export default CDSDatePickerCalendar;
|
|
136
|
+
//# sourceMappingURL=calendar-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-renderer.d.ts","sourceRoot":"","sources":["../../../../../src/components/date-picker/next/components/calendar-renderer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAC;AACvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAiB1C;;;;;;;GAOG;AACH,cACM,qBAAsB,SAAQ,UAAU;IAC5C;;OAEG;IAEH,OAAO,CAAC,aAAa,CAC4B;IAEjD;;OAEG;IAEH,aAAa,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAM;IAEzC;;OAEG;IAEH,QAAQ,C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.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import "../../../../globals/settings.js";
|
|
9
|
+
import { carbonElement } from "../../../../globals/decorators/carbon-element.js";
|
|
10
|
+
import __decorate from "../../../../_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/decorate.js";
|
|
11
|
+
import iconLoader from "../../../../globals/internal/icon-loader.js";
|
|
12
|
+
import date_picker_default from "./date-picker.scss.js";
|
|
13
|
+
import { LitElement, html } from "lit";
|
|
14
|
+
import { property, state } from "lit/decorators.js";
|
|
15
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
16
|
+
import ChevronRight16 from "@carbon/icons/es/chevron--right/16.js";
|
|
17
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
18
|
+
import ChevronLeft16 from "@carbon/icons/es/chevron--left/16.js";
|
|
19
|
+
import { generateCalendarGrid, getFullDateLabel, getMonthYearLabel, getWeekdayLabels } from "@carbon/utilities/date-picker";
|
|
20
|
+
//#region src/components/date-picker/next/components/calendar-renderer.ts
|
|
21
|
+
/**
|
|
22
|
+
* Copyright IBM Corp. 2026
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
25
|
+
* LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Calendar renderer for date picker.
|
|
29
|
+
* Replaces Flatpickr's calendar UI with a lightweight, framework-agnostic implementation.
|
|
30
|
+
*
|
|
31
|
+
* @element cds-preview-date-picker-calendar
|
|
32
|
+
* @fires cds-preview-date-picker-calendar-date-select - Fired when a date is selected
|
|
33
|
+
* @fires cds-preview-date-picker-calendar-month-change - Fired when the month changes
|
|
34
|
+
*/
|
|
35
|
+
let CDSDatePickerCalendar = class CDSDatePickerCalendar extends LitElement {
|
|
36
|
+
constructor(..._args) {
|
|
37
|
+
super(..._args);
|
|
38
|
+
this._currentMonth = Temporal.Now.plainDateISO().toPlainYearMonth();
|
|
39
|
+
this.selectedDates = [];
|
|
40
|
+
this.rangeMode = false;
|
|
41
|
+
this.dateFormat = "m/d/Y";
|
|
42
|
+
this.locale = "en-US";
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Navigate to previous month
|
|
46
|
+
*/
|
|
47
|
+
_handlePrevMonth() {
|
|
48
|
+
this._currentMonth = this._currentMonth.subtract({ months: 1 });
|
|
49
|
+
this._dispatchMonthChange();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Navigate to next month
|
|
53
|
+
*/
|
|
54
|
+
_handleNextMonth() {
|
|
55
|
+
this._currentMonth = this._currentMonth.add({ months: 1 });
|
|
56
|
+
this._dispatchMonthChange();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Handle date selection
|
|
60
|
+
* @param {Temporal.PlainDate} date - The date to select
|
|
61
|
+
*/
|
|
62
|
+
_handleDateSelect(date) {
|
|
63
|
+
if (this._isDateDisabled(date)) return;
|
|
64
|
+
this.dispatchEvent(new CustomEvent(`cds-preview-date-picker-calendar-date-select`, {
|
|
65
|
+
bubbles: true,
|
|
66
|
+
composed: true,
|
|
67
|
+
detail: { date }
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Dispatch month change event
|
|
72
|
+
*/
|
|
73
|
+
_dispatchMonthChange() {
|
|
74
|
+
this.dispatchEvent(new CustomEvent(`cds-preview-date-picker-calendar-month-change`, {
|
|
75
|
+
bubbles: true,
|
|
76
|
+
composed: true,
|
|
77
|
+
detail: { month: this._currentMonth }
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Check if a date is disabled
|
|
82
|
+
* @param {Temporal.PlainDate} date - The date to check
|
|
83
|
+
*/
|
|
84
|
+
_isDateDisabled(date) {
|
|
85
|
+
if (this.minDate && Temporal.PlainDate.compare(date, this.minDate) < 0) return true;
|
|
86
|
+
if (this.maxDate && Temporal.PlainDate.compare(date, this.maxDate) > 0) return true;
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Check if previous month navigation should be disabled
|
|
91
|
+
*/
|
|
92
|
+
_isPrevMonthDisabled() {
|
|
93
|
+
if (!this.minDate) return false;
|
|
94
|
+
const prevMonth = this._currentMonth.subtract({ months: 1 });
|
|
95
|
+
const prevMonthLastDay = prevMonth.toPlainDate({ day: prevMonth.daysInMonth });
|
|
96
|
+
return Temporal.PlainDate.compare(prevMonthLastDay, this.minDate) < 0;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Check if next month navigation should be disabled
|
|
100
|
+
*/
|
|
101
|
+
_isNextMonthDisabled() {
|
|
102
|
+
if (!this.maxDate) return false;
|
|
103
|
+
const nextMonthFirstDay = this._currentMonth.add({ months: 1 }).toPlainDate({ day: 1 });
|
|
104
|
+
return Temporal.PlainDate.compare(nextMonthFirstDay, this.maxDate) > 0;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Check if a date is selected
|
|
108
|
+
* @param {Temporal.PlainDate} date - The date to check
|
|
109
|
+
*/
|
|
110
|
+
_isDateSelected(date) {
|
|
111
|
+
return this.selectedDates.some((selected) => {
|
|
112
|
+
if (!selected || typeof selected !== "object" || !("year" in selected)) return false;
|
|
113
|
+
return Temporal.PlainDate.compare(selected, date) === 0;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Check if a date is in range (for range mode)
|
|
118
|
+
* @param {Temporal.PlainDate} date - The date to check
|
|
119
|
+
*/
|
|
120
|
+
_isDateInRange(date) {
|
|
121
|
+
if (!this.rangeMode) return false;
|
|
122
|
+
if (this.selectedDates.length === 2) {
|
|
123
|
+
const [start, end] = this.selectedDates.sort((a, b) => Temporal.PlainDate.compare(a, b));
|
|
124
|
+
return Temporal.PlainDate.compare(date, start) >= 0 && Temporal.PlainDate.compare(date, end) <= 0;
|
|
125
|
+
}
|
|
126
|
+
const previewDate = this._hoveredDate || this.focusedDate;
|
|
127
|
+
if (this.selectedDates.length === 1 && previewDate) {
|
|
128
|
+
if (this.minDate && Temporal.PlainDate.compare(previewDate, this.minDate) < 0 || this.maxDate && Temporal.PlainDate.compare(previewDate, this.maxDate) > 0) return false;
|
|
129
|
+
const [rangeStart, rangeEnd] = [this.selectedDates[0], previewDate].sort((a, b) => Temporal.PlainDate.compare(a, b));
|
|
130
|
+
return Temporal.PlainDate.compare(date, rangeStart) >= 0 && Temporal.PlainDate.compare(date, rangeEnd) <= 0;
|
|
131
|
+
}
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Check if a date is focused (for keyboard navigation)
|
|
136
|
+
* @param {Temporal.PlainDate} date - The date to check
|
|
137
|
+
*/
|
|
138
|
+
_isDateFocused(date) {
|
|
139
|
+
if (!this.focusedDate) return false;
|
|
140
|
+
return Temporal.PlainDate.compare(date, this.focusedDate) === 0;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Handle mouse enter on a date
|
|
144
|
+
* @param {Temporal.PlainDate} date - The date being hovered
|
|
145
|
+
*/
|
|
146
|
+
_handleDateMouseEnter(date) {
|
|
147
|
+
if (this.rangeMode && this.selectedDates.length === 1) this._hoveredDate = date;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Handle mouse leave on a date
|
|
151
|
+
*/
|
|
152
|
+
_handleDateMouseLeave() {
|
|
153
|
+
this._hoveredDate = void 0;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Render the calendar header with month/year and navigation
|
|
157
|
+
*/
|
|
158
|
+
_renderHeader() {
|
|
159
|
+
const monthName = getMonthYearLabel(this._currentMonth.toPlainDate({ day: 1 }), this.locale);
|
|
160
|
+
const isPrevDisabled = this._isPrevMonthDisabled();
|
|
161
|
+
const isNextDisabled = this._isNextMonthDisabled();
|
|
162
|
+
return html`
|
|
163
|
+
<div class="${"cds"}--date-picker__month">
|
|
164
|
+
<button
|
|
165
|
+
type="button"
|
|
166
|
+
class="${"cds"}--date-picker__month-nav ${"cds"}--date-picker__month-nav--prev"
|
|
167
|
+
tabindex="-1"
|
|
168
|
+
?disabled="${isPrevDisabled}"
|
|
169
|
+
@click="${this._handlePrevMonth}"
|
|
170
|
+
aria-label="Previous month">
|
|
171
|
+
${iconLoader(ChevronLeft16)}
|
|
172
|
+
</button>
|
|
173
|
+
<div class="${"cds"}--date-picker__current-month">
|
|
174
|
+
<span class="cur-month">${monthName}</span>
|
|
175
|
+
</div>
|
|
176
|
+
<button
|
|
177
|
+
type="button"
|
|
178
|
+
class="${"cds"}--date-picker__month-nav ${"cds"}--date-picker__month-nav--next"
|
|
179
|
+
tabindex="-1"
|
|
180
|
+
?disabled="${isNextDisabled}"
|
|
181
|
+
@click="${this._handleNextMonth}"
|
|
182
|
+
aria-label="Next month">
|
|
183
|
+
${iconLoader(ChevronRight16)}
|
|
184
|
+
</button>
|
|
185
|
+
</div>
|
|
186
|
+
`;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Render the weekday headers
|
|
190
|
+
*/
|
|
191
|
+
_renderWeekdays() {
|
|
192
|
+
return html`
|
|
193
|
+
<div class="${"cds"}--date-picker__weekdays">
|
|
194
|
+
${getWeekdayLabels(this.locale).map((day) => html`
|
|
195
|
+
<span class="${"cds"}--date-picker__weekday">${day}</span>
|
|
196
|
+
`)}
|
|
197
|
+
</div>
|
|
198
|
+
`;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Render the calendar days grid
|
|
202
|
+
*/
|
|
203
|
+
_renderDays() {
|
|
204
|
+
const currentMonthValue = this._currentMonth.month;
|
|
205
|
+
return html`
|
|
206
|
+
<div class="${"cds"}--date-picker__days" role="grid">
|
|
207
|
+
${generateCalendarGrid(this._currentMonth.toPlainDate({ day: 1 }), this.minDate ?? null, this.maxDate ?? null).flat().map(({ date, isCurrentMonth, isDisabled, isToday }) => {
|
|
208
|
+
const isSelected = this._isDateSelected(date);
|
|
209
|
+
const isInRange = this._isDateInRange(date);
|
|
210
|
+
const isFocused = this._isDateFocused(date);
|
|
211
|
+
return html`
|
|
212
|
+
<button
|
|
213
|
+
type="button"
|
|
214
|
+
class="${classMap({
|
|
215
|
+
[`cds--date-picker__day`]: true,
|
|
216
|
+
prevMonthDay: !isCurrentMonth && date.month < currentMonthValue,
|
|
217
|
+
nextMonthDay: !isCurrentMonth && date.month > currentMonthValue,
|
|
218
|
+
disabled: isDisabled,
|
|
219
|
+
selected: isSelected,
|
|
220
|
+
inRange: isInRange,
|
|
221
|
+
today: isToday && !isSelected,
|
|
222
|
+
"no-border": isToday && isSelected,
|
|
223
|
+
focused: isFocused
|
|
224
|
+
})}"
|
|
225
|
+
tabindex="-1"
|
|
226
|
+
?disabled="${isDisabled}"
|
|
227
|
+
@click="${() => this._handleDateSelect(date)}"
|
|
228
|
+
@mouseenter="${() => this._handleDateMouseEnter(date)}"
|
|
229
|
+
@mouseleave="${() => this._handleDateMouseLeave()}"
|
|
230
|
+
aria-label="${getFullDateLabel(date, this.locale)}"
|
|
231
|
+
aria-current="${ifDefined(isToday ? "date" : void 0)}">
|
|
232
|
+
${date.day}
|
|
233
|
+
</button>
|
|
234
|
+
`;
|
|
235
|
+
})}
|
|
236
|
+
</div>
|
|
237
|
+
`;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Lifecycle method called when properties change
|
|
241
|
+
* @param {PropertyValues} changedProperties - Changed properties
|
|
242
|
+
*/
|
|
243
|
+
updated(changedProperties) {
|
|
244
|
+
if (changedProperties.has("viewDate") && this.viewDate) this._currentMonth = Temporal.PlainYearMonth.from({
|
|
245
|
+
year: this.viewDate.year,
|
|
246
|
+
month: this.viewDate.month
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Renders the calendar component
|
|
251
|
+
*/
|
|
252
|
+
render() {
|
|
253
|
+
return html`
|
|
254
|
+
<div class="${"cds"}--date-picker__calendar" tabindex="0">
|
|
255
|
+
${this._renderHeader()} ${this._renderWeekdays()} ${this._renderDays()}
|
|
256
|
+
</div>
|
|
257
|
+
`;
|
|
258
|
+
}
|
|
259
|
+
static {
|
|
260
|
+
this.styles = date_picker_default;
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
__decorate([state()], CDSDatePickerCalendar.prototype, "_currentMonth", void 0);
|
|
264
|
+
__decorate([property({ type: Array })], CDSDatePickerCalendar.prototype, "selectedDates", void 0);
|
|
265
|
+
__decorate([property({ type: Object })], CDSDatePickerCalendar.prototype, "viewDate", void 0);
|
|
266
|
+
__decorate([property({ type: Object })], CDSDatePickerCalendar.prototype, "focusedDate", void 0);
|
|
267
|
+
__decorate([state()], CDSDatePickerCalendar.prototype, "_hoveredDate", void 0);
|
|
268
|
+
__decorate([property({ type: Object })], CDSDatePickerCalendar.prototype, "minDate", void 0);
|
|
269
|
+
__decorate([property({ type: Object })], CDSDatePickerCalendar.prototype, "maxDate", void 0);
|
|
270
|
+
__decorate([property({ type: Boolean })], CDSDatePickerCalendar.prototype, "rangeMode", void 0);
|
|
271
|
+
__decorate([property({ type: String })], CDSDatePickerCalendar.prototype, "dateFormat", void 0);
|
|
272
|
+
__decorate([property({ type: String })], CDSDatePickerCalendar.prototype, "locale", void 0);
|
|
273
|
+
CDSDatePickerCalendar = __decorate([carbonElement(`cds-preview-date-picker-calendar`)], CDSDatePickerCalendar);
|
|
274
|
+
var calendar_renderer_default = CDSDatePickerCalendar;
|
|
275
|
+
//#endregion
|
|
276
|
+
export { calendar_renderer_default as default };
|
|
277
|
+
|
|
278
|
+
//# sourceMappingURL=calendar-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-renderer.js","names":["end","styles","customElement"],"sources":["../../../../../src/components/date-picker/next/components/calendar-renderer.ts"],"sourcesContent":["/**\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { LitElement, html } from 'lit';\nimport type { PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { prefix } from '../../../../globals/settings';\nimport { carbonElement as customElement } from '../../../../globals/decorators/carbon-element';\nimport ChevronLeft16 from '@carbon/icons/es/chevron--left/16.js';\nimport ChevronRight16 from '@carbon/icons/es/chevron--right/16.js';\nimport { iconLoader } from '../../../../globals/internal/icon-loader';\nimport {\n generateCalendarGrid,\n getFullDateLabel,\n getMonthYearLabel,\n getWeekdayLabels,\n} from '@carbon/utilities/date-picker';\nimport styles from './date-picker.scss?lit';\n\n/**\n * Calendar renderer for date picker.\n * Replaces Flatpickr's calendar UI with a lightweight, framework-agnostic implementation.\n *\n * @element cds-preview-date-picker-calendar\n * @fires cds-preview-date-picker-calendar-date-select - Fired when a date is selected\n * @fires cds-preview-date-picker-calendar-month-change - Fired when the month changes\n */\n@customElement(`${prefix}-preview-date-picker-calendar`)\nclass CDSDatePickerCalendar extends LitElement {\n /**\n * The currently displayed month (Temporal.PlainYearMonth)\n */\n @state()\n private _currentMonth: Temporal.PlainYearMonth =\n Temporal.Now.plainDateISO().toPlainYearMonth();\n\n /**\n * The selected date(s)\n */\n @property({ type: Array })\n selectedDates: Temporal.PlainDate[] = [];\n\n /**\n * The view date from the state machine (used to sync calendar month)\n */\n @property({ type: Object })\n viewDate?: Temporal.PlainDate;\n\n /**\n * The focused date for keyboard navigation\n */\n @property({ type: Object })\n focusedDate?: Temporal.PlainDate | null;\n\n /**\n * The currently hovered date (for range preview)\n */\n @state()\n private _hoveredDate?: Temporal.PlainDate;\n\n /**\n * The minimum selectable date\n */\n @property({ type: Object })\n minDate?: Temporal.PlainDate;\n\n /**\n * The maximum selectable date\n */\n @property({ type: Object })\n maxDate?: Temporal.PlainDate;\n\n /**\n * Whether range selection is enabled\n */\n @property({ type: Boolean })\n rangeMode = false;\n\n /**\n * The date format for display\n */\n @property({ type: String })\n dateFormat = 'm/d/Y';\n\n /**\n * Locale for date formatting\n */\n @property({ type: String })\n locale = 'en-US';\n\n /**\n * Navigate to previous month\n */\n private _handlePrevMonth() {\n this._currentMonth = this._currentMonth.subtract({ months: 1 });\n this._dispatchMonthChange();\n }\n\n /**\n * Navigate to next month\n */\n private _handleNextMonth() {\n this._currentMonth = this._currentMonth.add({ months: 1 });\n this._dispatchMonthChange();\n }\n\n /**\n * Handle date selection\n * @param {Temporal.PlainDate} date - The date to select\n */\n private _handleDateSelect(date: Temporal.PlainDate) {\n if (this._isDateDisabled(date)) {\n return;\n }\n\n this.dispatchEvent(\n new CustomEvent(`${prefix}-preview-date-picker-calendar-date-select`, {\n bubbles: true,\n composed: true,\n detail: { date },\n })\n );\n }\n\n /**\n * Dispatch month change event\n */\n private _dispatchMonthChange() {\n this.dispatchEvent(\n new CustomEvent(`${prefix}-preview-date-picker-calendar-month-change`, {\n bubbles: true,\n composed: true,\n detail: { month: this._currentMonth },\n })\n );\n }\n\n /**\n * Check if a date is disabled\n * @param {Temporal.PlainDate} date - The date to check\n */\n private _isDateDisabled(date: Temporal.PlainDate): boolean {\n if (this.minDate && Temporal.PlainDate.compare(date, this.minDate) < 0) {\n return true;\n }\n if (this.maxDate && Temporal.PlainDate.compare(date, this.maxDate) > 0) {\n return true;\n }\n return false;\n }\n\n /**\n * Check if previous month navigation should be disabled\n */\n private _isPrevMonthDisabled(): boolean {\n if (!this.minDate) {\n return false;\n }\n // Disable if going to previous month would be before minDate's month\n const prevMonth = this._currentMonth.subtract({ months: 1 });\n const prevMonthLastDay = prevMonth.toPlainDate({\n day: prevMonth.daysInMonth,\n });\n return Temporal.PlainDate.compare(prevMonthLastDay, this.minDate) < 0;\n }\n\n /**\n * Check if next month navigation should be disabled\n */\n private _isNextMonthDisabled(): boolean {\n if (!this.maxDate) {\n return false;\n }\n // Disable if going to next month would be after maxDate's month\n const nextMonth = this._currentMonth.add({ months: 1 });\n const nextMonthFirstDay = nextMonth.toPlainDate({ day: 1 });\n return Temporal.PlainDate.compare(nextMonthFirstDay, this.maxDate) > 0;\n }\n\n /**\n * Check if a date is selected\n * @param {Temporal.PlainDate} date - The date to check\n */\n private _isDateSelected(date: Temporal.PlainDate): boolean {\n return this.selectedDates.some((selected) => {\n if (!selected || typeof selected !== 'object' || !('year' in selected)) {\n return false;\n }\n return Temporal.PlainDate.compare(selected, date) === 0;\n });\n }\n\n /**\n * Check if a date is in range (for range mode)\n * @param {Temporal.PlainDate} date - The date to check\n */\n private _isDateInRange(date: Temporal.PlainDate): boolean {\n if (!this.rangeMode) {\n return false;\n }\n\n // Case 1: Both dates are selected (final range)\n if (this.selectedDates.length === 2) {\n const [start, end] = this.selectedDates.sort((a, b) =>\n Temporal.PlainDate.compare(a, b)\n );\n\n return (\n Temporal.PlainDate.compare(date, start) >= 0 &&\n Temporal.PlainDate.compare(date, end) <= 0\n );\n }\n\n // Case 2: One date selected, show preview range with hovered or focused date\n const previewDate = this._hoveredDate || this.focusedDate;\n if (this.selectedDates.length === 1 && previewDate) {\n // Don't show range preview if the preview date is disabled\n const isPreviewDisabled =\n (this.minDate &&\n Temporal.PlainDate.compare(previewDate, this.minDate) < 0) ||\n (this.maxDate &&\n Temporal.PlainDate.compare(previewDate, this.maxDate) > 0);\n\n if (isPreviewDisabled) {\n return false;\n }\n\n const start = this.selectedDates[0];\n const end = previewDate;\n\n // Sort to handle both forward and backward selection\n const [rangeStart, rangeEnd] = [start, end].sort((a, b) =>\n Temporal.PlainDate.compare(a, b)\n );\n\n return (\n Temporal.PlainDate.compare(date, rangeStart) >= 0 &&\n Temporal.PlainDate.compare(date, rangeEnd) <= 0\n );\n }\n\n return false;\n }\n\n /**\n * Check if a date is focused (for keyboard navigation)\n * @param {Temporal.PlainDate} date - The date to check\n */\n private _isDateFocused(date: Temporal.PlainDate): boolean {\n if (!this.focusedDate) {\n return false;\n }\n return Temporal.PlainDate.compare(date, this.focusedDate) === 0;\n }\n\n /**\n * Handle mouse enter on a date\n * @param {Temporal.PlainDate} date - The date being hovered\n */\n private _handleDateMouseEnter(date: Temporal.PlainDate) {\n // Only track hover in range mode when selecting end date\n if (this.rangeMode && this.selectedDates.length === 1) {\n this._hoveredDate = date;\n }\n }\n\n /**\n * Handle mouse leave on a date\n */\n private _handleDateMouseLeave() {\n // Clear hovered date\n this._hoveredDate = undefined;\n }\n\n /**\n * Render the calendar header with month/year and navigation\n */\n private _renderHeader() {\n const monthName = getMonthYearLabel(\n this._currentMonth.toPlainDate({ day: 1 }),\n this.locale\n );\n\n const isPrevDisabled = this._isPrevMonthDisabled();\n const isNextDisabled = this._isNextMonthDisabled();\n\n return html`\n <div class=\"${prefix}--date-picker__month\">\n <button\n type=\"button\"\n class=\"${prefix}--date-picker__month-nav ${prefix}--date-picker__month-nav--prev\"\n tabindex=\"-1\"\n ?disabled=\"${isPrevDisabled}\"\n @click=\"${this._handlePrevMonth}\"\n aria-label=\"Previous month\">\n ${iconLoader(ChevronLeft16)}\n </button>\n <div class=\"${prefix}--date-picker__current-month\">\n <span class=\"cur-month\">${monthName}</span>\n </div>\n <button\n type=\"button\"\n class=\"${prefix}--date-picker__month-nav ${prefix}--date-picker__month-nav--next\"\n tabindex=\"-1\"\n ?disabled=\"${isNextDisabled}\"\n @click=\"${this._handleNextMonth}\"\n aria-label=\"Next month\">\n ${iconLoader(ChevronRight16)}\n </button>\n </div>\n `;\n }\n\n /**\n * Render the weekday headers\n */\n private _renderWeekdays() {\n const weekdays = getWeekdayLabels(this.locale);\n\n return html`\n <div class=\"${prefix}--date-picker__weekdays\">\n ${weekdays.map(\n (day) => html`\n <span class=\"${prefix}--date-picker__weekday\">${day}</span>\n `\n )}\n </div>\n `;\n }\n\n /**\n * Render the calendar days grid\n */\n private _renderDays() {\n const currentMonthValue = this._currentMonth.month;\n\n const days = generateCalendarGrid(\n this._currentMonth.toPlainDate({ day: 1 }),\n this.minDate ?? null,\n this.maxDate ?? null\n ).flat();\n\n return html`\n <div class=\"${prefix}--date-picker__days\" role=\"grid\">\n ${days.map(({ date, isCurrentMonth, isDisabled, isToday }) => {\n const isSelected = this._isDateSelected(date);\n const isInRange = this._isDateInRange(date);\n const isFocused = this._isDateFocused(date);\n\n const dayClasses = classMap({\n [`${prefix}--date-picker__day`]: true,\n prevMonthDay: !isCurrentMonth && date.month < currentMonthValue,\n nextMonthDay: !isCurrentMonth && date.month > currentMonthValue,\n disabled: isDisabled,\n selected: isSelected,\n inRange: isInRange,\n today: isToday && !isSelected,\n 'no-border': isToday && isSelected,\n focused: isFocused,\n });\n\n return html`\n <button\n type=\"button\"\n class=\"${dayClasses}\"\n tabindex=\"-1\"\n ?disabled=\"${isDisabled}\"\n @click=\"${() => this._handleDateSelect(date)}\"\n @mouseenter=\"${() => this._handleDateMouseEnter(date)}\"\n @mouseleave=\"${() => this._handleDateMouseLeave()}\"\n aria-label=\"${getFullDateLabel(date, this.locale)}\"\n aria-current=\"${ifDefined(isToday ? 'date' : undefined)}\">\n ${date.day}\n </button>\n `;\n })}\n </div>\n `;\n }\n\n /**\n * Lifecycle method called when properties change\n * @param {PropertyValues} changedProperties - Changed properties\n */\n updated(changedProperties: PropertyValues) {\n // Sync calendar month with viewDate from state machine\n if (changedProperties.has('viewDate') && this.viewDate) {\n // Create PlainYearMonth from PlainDate\n this._currentMonth = Temporal.PlainYearMonth.from({\n year: this.viewDate.year,\n month: this.viewDate.month,\n });\n }\n }\n\n /**\n * Renders the calendar component\n */\n render() {\n return html`\n <div class=\"${prefix}--date-picker__calendar\" tabindex=\"0\">\n ${this._renderHeader()} ${this._renderWeekdays()} ${this._renderDays()}\n </div>\n `;\n }\n\n static styles = styles;\n}\n\nexport default CDSDatePickerCalendar;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAA,wBAAA,MACM,8BAA8B,WAAW;;;uBAM3C,SAAS,IAAI,aAAa,CAAC,CAAC,iBAAiB;uBAMT,CAAC;mBAoC3B;oBAMC;gBAMJ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AAA,4BAAe"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { LitElement } from 'lit';
|
|
8
|
+
import { DATE_PICKER_INPUT_KIND } from '../../defs';
|
|
9
|
+
/**
|
|
10
|
+
* Skeleton version of the input box for date picker.
|
|
11
|
+
*/
|
|
12
|
+
declare class CDSDatePickerInputSkeleton extends LitElement {
|
|
13
|
+
/**
|
|
14
|
+
* Specify whether the label should be hidden, or not
|
|
15
|
+
*/
|
|
16
|
+
hideLabel: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* * @deprecated use `range` instead
|
|
19
|
+
* Date picker input kind. Corresponds to the attribute with the same name.
|
|
20
|
+
*/
|
|
21
|
+
kind: DATE_PICKER_INPUT_KIND;
|
|
22
|
+
/**
|
|
23
|
+
* Specify whether the skeleton should be of range date picker.
|
|
24
|
+
*/
|
|
25
|
+
range: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Renders the component template.
|
|
28
|
+
*
|
|
29
|
+
* @returns {TemplateResult} The template result
|
|
30
|
+
*/
|
|
31
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
32
|
+
static styles: any;
|
|
33
|
+
}
|
|
34
|
+
export default CDSDatePickerInputSkeleton;
|
|
35
|
+
//# sourceMappingURL=date-picker-input-skeleton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-picker-input-skeleton.d.ts","sourceRoot":"","sources":["../../../../../src/components/date-picker/next/components/date-picker-input-skeleton.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAC;AAGvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAIpD;;GAEG;AACH,cACM,0BAA2B,SAAQ,UAAU;IACjD;;OAEG;IAEH,SAAS,UAAS;IAElB;;;OAGG;IAEH,IAAI,yBAAiC;IAErC;;OAEG;IAEH,KAAK,UAAS;IAEd;;;;OAIG;IACH,MAAM;IAqBN,MAAM,CAAC,MAAM,MAAU;CACxB;AAED,eAAe,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2026
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import "../../../../globals/settings.js";
|
|
9
|
+
import { carbonElement } from "../../../../globals/decorators/carbon-element.js";
|
|
10
|
+
import __decorate from "../../../../_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/decorate.js";
|
|
11
|
+
import "../../defs.js";
|
|
12
|
+
import date_picker_default from "./date-picker.scss.js";
|
|
13
|
+
import { LitElement, html } from "lit";
|
|
14
|
+
import { property } from "lit/decorators.js";
|
|
15
|
+
//#region src/components/date-picker/next/components/date-picker-input-skeleton.ts
|
|
16
|
+
/**
|
|
17
|
+
* Copyright IBM Corp. 2026
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
20
|
+
* LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Skeleton version of the input box for date picker.
|
|
24
|
+
*/
|
|
25
|
+
let CDSDatePickerInputSkeleton = class CDSDatePickerInputSkeleton extends LitElement {
|
|
26
|
+
constructor(..._args) {
|
|
27
|
+
super(..._args);
|
|
28
|
+
this.hideLabel = false;
|
|
29
|
+
this.kind = "simple";
|
|
30
|
+
this.range = false;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Renders the component template.
|
|
34
|
+
*
|
|
35
|
+
* @returns {TemplateResult} The template result
|
|
36
|
+
*/
|
|
37
|
+
render() {
|
|
38
|
+
const { hideLabel, range } = this;
|
|
39
|
+
return html`
|
|
40
|
+
<div class="${"cds"}--date-picker-input-skeleton-container">
|
|
41
|
+
${!hideLabel ? html`<span class="${"cds"}--label"></span>` : null}
|
|
42
|
+
<div class="${"cds"}--date-picker__input ${"cds"}--skeleton"></div>
|
|
43
|
+
</div>
|
|
44
|
+
${range ? html`
|
|
45
|
+
<div class="${"cds"}--date-picker-input-skeleton-container">
|
|
46
|
+
${!hideLabel ? html`<span class="${"cds"}--label"></span>` : null}
|
|
47
|
+
<div
|
|
48
|
+
class="${"cds"}--date-picker__input ${"cds"}--skeleton"></div>
|
|
49
|
+
</div>
|
|
50
|
+
` : null}
|
|
51
|
+
`;
|
|
52
|
+
}
|
|
53
|
+
static {
|
|
54
|
+
this.styles = date_picker_default;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
__decorate([property({
|
|
58
|
+
type: Boolean,
|
|
59
|
+
reflect: true,
|
|
60
|
+
attribute: "hide-label"
|
|
61
|
+
})], CDSDatePickerInputSkeleton.prototype, "hideLabel", void 0);
|
|
62
|
+
__decorate([property({ reflect: true })], CDSDatePickerInputSkeleton.prototype, "kind", void 0);
|
|
63
|
+
__decorate([property({
|
|
64
|
+
type: Boolean,
|
|
65
|
+
reflect: true,
|
|
66
|
+
attribute: "range"
|
|
67
|
+
})], CDSDatePickerInputSkeleton.prototype, "range", void 0);
|
|
68
|
+
CDSDatePickerInputSkeleton = __decorate([carbonElement(`cds-preview-date-picker-input-skeleton`)], CDSDatePickerInputSkeleton);
|
|
69
|
+
var date_picker_input_skeleton_default = CDSDatePickerInputSkeleton;
|
|
70
|
+
//#endregion
|
|
71
|
+
export { date_picker_input_skeleton_default as default };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=date-picker-input-skeleton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-picker-input-skeleton.js","names":["styles","customElement"],"sources":["../../../../../src/components/date-picker/next/components/date-picker-input-skeleton.ts"],"sourcesContent":["/**\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { LitElement, html } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { prefix } from '../../../../globals/settings';\nimport { DATE_PICKER_INPUT_KIND } from '../../defs';\nimport styles from './date-picker.scss?lit';\nimport { carbonElement as customElement } from '../../../../globals/decorators/carbon-element';\n\n/**\n * Skeleton version of the input box for date picker.\n */\n@customElement(`${prefix}-preview-date-picker-input-skeleton`)\nclass CDSDatePickerInputSkeleton extends LitElement {\n /**\n * Specify whether the label should be hidden, or not\n */\n @property({ type: Boolean, reflect: true, attribute: 'hide-label' })\n hideLabel = false;\n\n /**\n * * @deprecated use `range` instead\n * Date picker input kind. Corresponds to the attribute with the same name.\n */\n @property({ reflect: true })\n kind = DATE_PICKER_INPUT_KIND.SIMPLE;\n\n /**\n * Specify whether the skeleton should be of range date picker.\n */\n @property({ type: Boolean, reflect: true, attribute: 'range' })\n range = false;\n\n /**\n * Renders the component template.\n *\n * @returns {TemplateResult} The template result\n */\n render() {\n const { hideLabel, range } = this;\n return html`\n <div class=\"${prefix}--date-picker-input-skeleton-container\">\n ${!hideLabel ? html`<span class=\"${prefix}--label\"></span>` : null}\n <div class=\"${prefix}--date-picker__input ${prefix}--skeleton\"></div>\n </div>\n ${range\n ? html`\n <div class=\"${prefix}--date-picker-input-skeleton-container\">\n ${!hideLabel\n ? html`<span class=\"${prefix}--label\"></span>`\n : null}\n <div\n class=\"${prefix}--date-picker__input ${prefix}--skeleton\"></div>\n </div>\n `\n : null}\n `;\n }\n\n static styles = styles;\n}\n\nexport default CDSDatePickerInputSkeleton;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAiBA,IAAA,6BAAA,MACM,mCAAmC,WAAW;;;mBAKtC;;eAaJ;;;;;;;CAOR,SAAS;EACP,MAAM,EAAE,WAAW,UAAU;EAC7B,OAAO,IAAI;0BACY;UACjB,CAAC,YAAY,IAAI,gBAAA,MAAuB,oBAAoB,KAAK;4BAC9C,uBAAA,MAA8B;;QAEnD,QACE,IAAI;gCACmB;gBACjB,CAAC,YACC,IAAI,gBAAA,MAAuB,oBAC3B,KAAK;;+BAES,uBAAA,MAA8B;;cAGpD,KAAK;;CAEb;;gBAEgBA;;AAClB;YA3CG,SAAS;CAAE,MAAM;CAAS,SAAS;CAAM,WAAW;AAAa,CAAC,CAAA,GAAA,2BAAA,WAAA,aAAA,KAAA,CAAA;YAOlE,SAAS,EAAE,SAAS,KAAK,CAAC,CAAA,GAAA,2BAAA,WAAA,QAAA,KAAA,CAAA;YAM1B,SAAS;CAAE,MAAM;CAAS,SAAS;CAAM,WAAW;AAAQ,CAAC,CAAA,GAAA,2BAAA,WAAA,SAAA,KAAA,CAAA;yCAlB/DC,cAAc,wCAA8C,CAAA,GAAA,0BAAA;AAkD7D,IAAA,qCAAe"}
|