@keenthemes/ktui 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -27
- package/dist/ktui.js +6790 -14063
- package/dist/ktui.min.js +1 -1
- package/dist/ktui.min.js.map +1 -1
- package/dist/styles.css +1132 -2705
- package/lib/cjs/components/datatable/__tests__/pagination-reset.test.js +596 -0
- package/lib/cjs/components/datatable/__tests__/pagination-reset.test.js.map +1 -0
- package/lib/cjs/components/datatable/__tests__/race-conditions.test.js +548 -0
- package/lib/cjs/components/datatable/__tests__/race-conditions.test.js.map +1 -0
- package/lib/cjs/components/datatable/__tests__/setup.js +63 -0
- package/lib/cjs/components/datatable/__tests__/setup.js.map +1 -0
- package/lib/cjs/components/datatable/datatable.js +92 -30
- package/lib/cjs/components/datatable/datatable.js.map +1 -1
- package/lib/cjs/index.js +1 -10
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/components/datatable/__tests__/pagination-reset.test.js +594 -0
- package/lib/esm/components/datatable/__tests__/pagination-reset.test.js.map +1 -0
- package/lib/esm/components/datatable/__tests__/race-conditions.test.js +546 -0
- package/lib/esm/components/datatable/__tests__/race-conditions.test.js.map +1 -0
- package/lib/esm/components/datatable/__tests__/setup.js +58 -0
- package/lib/esm/components/datatable/__tests__/setup.js.map +1 -0
- package/lib/esm/components/datatable/datatable.js +92 -30
- package/lib/esm/components/datatable/datatable.js.map +1 -1
- package/lib/esm/index.js +0 -7
- package/lib/esm/index.js.map +1 -1
- package/package.json +7 -9
- package/src/components/alert/alert.css +188 -429
- package/src/components/datatable/__tests__/pagination-reset.test.ts +657 -0
- package/src/components/datatable/__tests__/race-conditions.test.ts +455 -0
- package/src/components/datatable/__tests__/setup.ts +67 -0
- package/src/components/datatable/datatable.ts +66 -11
- package/src/components/input/input.css +0 -1
- package/src/components/select/select.css +0 -1
- package/src/components/select/variants.css +4 -0
- package/src/components/textarea/textarea.css +0 -1
- package/src/index.ts +0 -10
- package/styles.css +0 -1
- package/lib/cjs/components/alert/alert.js +0 -1025
- package/lib/cjs/components/alert/alert.js.map +0 -1
- package/lib/cjs/components/alert/index.js +0 -20
- package/lib/cjs/components/alert/index.js.map +0 -1
- package/lib/cjs/components/alert/templates.js +0 -120
- package/lib/cjs/components/alert/templates.js.map +0 -1
- package/lib/cjs/components/alert/types.js +0 -7
- package/lib/cjs/components/alert/types.js.map +0 -1
- package/lib/cjs/components/datepicker/config/config.js +0 -42
- package/lib/cjs/components/datepicker/config/config.js.map +0 -1
- package/lib/cjs/components/datepicker/config/index.js +0 -24
- package/lib/cjs/components/datepicker/config/index.js.map +0 -1
- package/lib/cjs/components/datepicker/config/interfaces.js +0 -7
- package/lib/cjs/components/datepicker/config/interfaces.js.map +0 -1
- package/lib/cjs/components/datepicker/config/types.js +0 -7
- package/lib/cjs/components/datepicker/config/types.js.map +0 -1
- package/lib/cjs/components/datepicker/core/event-manager.js +0 -135
- package/lib/cjs/components/datepicker/core/event-manager.js.map +0 -1
- package/lib/cjs/components/datepicker/core/focus-manager.js +0 -167
- package/lib/cjs/components/datepicker/core/focus-manager.js.map +0 -1
- package/lib/cjs/components/datepicker/core/helpers.js +0 -219
- package/lib/cjs/components/datepicker/core/helpers.js.map +0 -1
- package/lib/cjs/components/datepicker/core/index.js +0 -25
- package/lib/cjs/components/datepicker/core/index.js.map +0 -1
- package/lib/cjs/components/datepicker/core/unified-state-manager.js +0 -394
- package/lib/cjs/components/datepicker/core/unified-state-manager.js.map +0 -1
- package/lib/cjs/components/datepicker/datepicker.js +0 -2252
- package/lib/cjs/components/datepicker/datepicker.js.map +0 -1
- package/lib/cjs/components/datepicker/index.js +0 -24
- package/lib/cjs/components/datepicker/index.js.map +0 -1
- package/lib/cjs/components/datepicker/ui/index.js +0 -23
- package/lib/cjs/components/datepicker/ui/index.js.map +0 -1
- package/lib/cjs/components/datepicker/ui/input/dropdown.js +0 -489
- package/lib/cjs/components/datepicker/ui/input/dropdown.js.map +0 -1
- package/lib/cjs/components/datepicker/ui/input/index.js +0 -23
- package/lib/cjs/components/datepicker/ui/input/index.js.map +0 -1
- package/lib/cjs/components/datepicker/ui/input/segmented-input.js +0 -640
- package/lib/cjs/components/datepicker/ui/input/segmented-input.js.map +0 -1
- package/lib/cjs/components/datepicker/ui/renderers/calendar.js +0 -446
- package/lib/cjs/components/datepicker/ui/renderers/calendar.js.map +0 -1
- package/lib/cjs/components/datepicker/ui/renderers/footer.js +0 -42
- package/lib/cjs/components/datepicker/ui/renderers/footer.js.map +0 -1
- package/lib/cjs/components/datepicker/ui/renderers/header.js +0 -32
- package/lib/cjs/components/datepicker/ui/renderers/header.js.map +0 -1
- package/lib/cjs/components/datepicker/ui/renderers/index.js +0 -25
- package/lib/cjs/components/datepicker/ui/renderers/index.js.map +0 -1
- package/lib/cjs/components/datepicker/ui/renderers/time-picker.js +0 -384
- package/lib/cjs/components/datepicker/ui/renderers/time-picker.js.map +0 -1
- package/lib/cjs/components/datepicker/ui/templates/index.js +0 -22
- package/lib/cjs/components/datepicker/ui/templates/index.js.map +0 -1
- package/lib/cjs/components/datepicker/ui/templates/templates.js +0 -253
- package/lib/cjs/components/datepicker/ui/templates/templates.js.map +0 -1
- package/lib/cjs/components/datepicker/utils/date-formatters.js +0 -88
- package/lib/cjs/components/datepicker/utils/date-formatters.js.map +0 -1
- package/lib/cjs/components/datepicker/utils/date-utils.js +0 -194
- package/lib/cjs/components/datepicker/utils/date-utils.js.map +0 -1
- package/lib/cjs/components/datepicker/utils/index.js +0 -24
- package/lib/cjs/components/datepicker/utils/index.js.map +0 -1
- package/lib/cjs/components/datepicker/utils/time-utils.js +0 -213
- package/lib/cjs/components/datepicker/utils/time-utils.js.map +0 -1
- package/lib/esm/components/alert/alert.js +0 -1022
- package/lib/esm/components/alert/alert.js.map +0 -1
- package/lib/esm/components/alert/index.js +0 -4
- package/lib/esm/components/alert/index.js.map +0 -1
- package/lib/esm/components/alert/templates.js +0 -112
- package/lib/esm/components/alert/templates.js.map +0 -1
- package/lib/esm/components/alert/types.js +0 -6
- package/lib/esm/components/alert/types.js.map +0 -1
- package/lib/esm/components/datepicker/config/config.js +0 -39
- package/lib/esm/components/datepicker/config/config.js.map +0 -1
- package/lib/esm/components/datepicker/config/index.js +0 -8
- package/lib/esm/components/datepicker/config/index.js.map +0 -1
- package/lib/esm/components/datepicker/config/interfaces.js +0 -6
- package/lib/esm/components/datepicker/config/interfaces.js.map +0 -1
- package/lib/esm/components/datepicker/config/types.js +0 -6
- package/lib/esm/components/datepicker/config/types.js.map +0 -1
- package/lib/esm/components/datepicker/core/event-manager.js +0 -133
- package/lib/esm/components/datepicker/core/event-manager.js.map +0 -1
- package/lib/esm/components/datepicker/core/focus-manager.js +0 -164
- package/lib/esm/components/datepicker/core/focus-manager.js.map +0 -1
- package/lib/esm/components/datepicker/core/helpers.js +0 -211
- package/lib/esm/components/datepicker/core/helpers.js.map +0 -1
- package/lib/esm/components/datepicker/core/index.js +0 -9
- package/lib/esm/components/datepicker/core/index.js.map +0 -1
- package/lib/esm/components/datepicker/core/unified-state-manager.js +0 -391
- package/lib/esm/components/datepicker/core/unified-state-manager.js.map +0 -1
- package/lib/esm/components/datepicker/datepicker.js +0 -2248
- package/lib/esm/components/datepicker/datepicker.js.map +0 -1
- package/lib/esm/components/datepicker/index.js +0 -7
- package/lib/esm/components/datepicker/index.js.map +0 -1
- package/lib/esm/components/datepicker/ui/index.js +0 -7
- package/lib/esm/components/datepicker/ui/index.js.map +0 -1
- package/lib/esm/components/datepicker/ui/input/dropdown.js +0 -486
- package/lib/esm/components/datepicker/ui/input/dropdown.js.map +0 -1
- package/lib/esm/components/datepicker/ui/input/index.js +0 -7
- package/lib/esm/components/datepicker/ui/input/index.js.map +0 -1
- package/lib/esm/components/datepicker/ui/input/segmented-input.js +0 -637
- package/lib/esm/components/datepicker/ui/input/segmented-input.js.map +0 -1
- package/lib/esm/components/datepicker/ui/renderers/calendar.js +0 -443
- package/lib/esm/components/datepicker/ui/renderers/calendar.js.map +0 -1
- package/lib/esm/components/datepicker/ui/renderers/footer.js +0 -39
- package/lib/esm/components/datepicker/ui/renderers/footer.js.map +0 -1
- package/lib/esm/components/datepicker/ui/renderers/header.js +0 -29
- package/lib/esm/components/datepicker/ui/renderers/header.js.map +0 -1
- package/lib/esm/components/datepicker/ui/renderers/index.js +0 -9
- package/lib/esm/components/datepicker/ui/renderers/index.js.map +0 -1
- package/lib/esm/components/datepicker/ui/renderers/time-picker.js +0 -381
- package/lib/esm/components/datepicker/ui/renderers/time-picker.js.map +0 -1
- package/lib/esm/components/datepicker/ui/templates/index.js +0 -6
- package/lib/esm/components/datepicker/ui/templates/index.js.map +0 -1
- package/lib/esm/components/datepicker/ui/templates/templates.js +0 -242
- package/lib/esm/components/datepicker/ui/templates/templates.js.map +0 -1
- package/lib/esm/components/datepicker/utils/date-formatters.js +0 -83
- package/lib/esm/components/datepicker/utils/date-formatters.js.map +0 -1
- package/lib/esm/components/datepicker/utils/date-utils.js +0 -184
- package/lib/esm/components/datepicker/utils/date-utils.js.map +0 -1
- package/lib/esm/components/datepicker/utils/index.js +0 -8
- package/lib/esm/components/datepicker/utils/index.js.map +0 -1
- package/lib/esm/components/datepicker/utils/time-utils.js +0 -201
- package/lib/esm/components/datepicker/utils/time-utils.js.map +0 -1
- package/src/components/alert/alert.ts +0 -990
- package/src/components/alert/index.ts +0 -4
- package/src/components/alert/templates.ts +0 -110
- package/src/components/alert/tests/accessibility/aria-roles.test.ts +0 -19
- package/src/components/alert/tests/accessibility/focus-management.test.ts +0 -19
- package/src/components/alert/tests/accessibility/keyboard-nav.test.ts +0 -22
- package/src/components/alert/tests/actions/confirm-cancel.test.ts +0 -122
- package/src/components/alert/tests/actions/input-field.test.ts +0 -180
- package/src/components/alert/tests/alert.basic.test.ts +0 -126
- package/src/components/alert/tests/alert.config.test.ts +0 -75
- package/src/components/alert/tests/alert.templates.test.ts +0 -17
- package/src/components/alert/tests/config/attribute-config.test.ts +0 -94
- package/src/components/alert/tests/config/json-config.test.ts +0 -119
- package/src/components/alert/tests/config/merging.test.ts +0 -89
- package/src/components/alert/tests/dismissal/auto-dismiss.test.ts +0 -96
- package/src/components/alert/tests/dismissal/escape-key-dismiss.test.ts +0 -105
- package/src/components/alert/tests/dismissal/manual-dismiss.test.ts +0 -90
- package/src/components/alert/tests/dismissal/outside-click-dismiss.test.ts +0 -91
- package/src/components/alert/tests/edge-cases/invalid-config.test.ts +0 -19
- package/src/components/alert/tests/edge-cases/multiple-alerts.test.ts +0 -19
- package/src/components/alert/tests/rendering/custom-content.test.ts +0 -81
- package/src/components/alert/tests/rendering/info-alert.test.ts +0 -84
- package/src/components/alert/tests/rendering/success-alert.test.ts +0 -100
- package/src/components/alert/tests/templates/default-templates.test.ts +0 -16
- package/src/components/alert/tests/templates/user-templates.test.ts +0 -16
- package/src/components/alert/types.ts +0 -145
- package/src/components/datepicker/__tests__/datepicker-events.test.ts +0 -356
- package/src/components/datepicker/__tests__/datepicker-init.test.ts +0 -343
- package/src/components/datepicker/__tests__/datepicker-integration.test.ts +0 -435
- package/src/components/datepicker/__tests__/datepicker-timezone.test.ts +0 -220
- package/src/components/datepicker/__tests__/segmented-input-focus.test.ts +0 -380
- package/src/components/datepicker/__tests__/selective-state-updates.test.ts +0 -400
- package/src/components/datepicker/__tests__/state-manager.test.ts +0 -421
- package/src/components/datepicker/__tests__/time-preservation.test.ts +0 -387
- package/src/components/datepicker/config/config.ts +0 -40
- package/src/components/datepicker/config/index.ts +0 -8
- package/src/components/datepicker/config/interfaces.ts +0 -82
- package/src/components/datepicker/config/types.ts +0 -188
- package/src/components/datepicker/core/event-manager.ts +0 -159
- package/src/components/datepicker/core/focus-manager.ts +0 -201
- package/src/components/datepicker/core/helpers.ts +0 -231
- package/src/components/datepicker/core/index.ts +0 -9
- package/src/components/datepicker/core/unified-state-manager.ts +0 -459
- package/src/components/datepicker/datepicker.css +0 -435
- package/src/components/datepicker/datepicker.ts +0 -2548
- package/src/components/datepicker/index.ts +0 -8
- package/src/components/datepicker/ui/index.ts +0 -7
- package/src/components/datepicker/ui/input/dropdown.ts +0 -552
- package/src/components/datepicker/ui/input/index.ts +0 -7
- package/src/components/datepicker/ui/input/segmented-input.ts +0 -638
- package/src/components/datepicker/ui/renderers/__tests__/calendar-optimizations.test.ts +0 -611
- package/src/components/datepicker/ui/renderers/calendar.ts +0 -530
- package/src/components/datepicker/ui/renderers/footer.ts +0 -43
- package/src/components/datepicker/ui/renderers/header.ts +0 -33
- package/src/components/datepicker/ui/renderers/index.ts +0 -9
- package/src/components/datepicker/ui/renderers/time-picker.ts +0 -438
- package/src/components/datepicker/ui/templates/index.ts +0 -6
- package/src/components/datepicker/ui/templates/templates.ts +0 -306
- package/src/components/datepicker/utils/__tests__/date-formatters.test.ts +0 -160
- package/src/components/datepicker/utils/__tests__/date-utils-keys.test.ts +0 -86
- package/src/components/datepicker/utils/__tests__/date-utils-timezone.test.ts +0 -215
- package/src/components/datepicker/utils/date-formatters.ts +0 -85
- package/src/components/datepicker/utils/date-utils.ts +0 -172
- package/src/components/datepicker/utils/index.ts +0 -8
- package/src/components/datepicker/utils/time-utils.ts +0 -221
|
@@ -1,381 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* time-picker.ts - Time picker renderer for KTDatepicker
|
|
3
|
-
* Provides time picker UI components with increment/decrement controls.
|
|
4
|
-
* Uses unified template system for consistent rendering.
|
|
5
|
-
*/
|
|
6
|
-
var __assign = (this && this.__assign) || function () {
|
|
7
|
-
__assign = Object.assign || function(t) {
|
|
8
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
9
|
-
s = arguments[i];
|
|
10
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
11
|
-
t[p] = s[p];
|
|
12
|
-
}
|
|
13
|
-
return t;
|
|
14
|
-
};
|
|
15
|
-
return __assign.apply(this, arguments);
|
|
16
|
-
};
|
|
17
|
-
import { formatTime, validateTime } from '../../utils/time-utils';
|
|
18
|
-
import { createTemplateRenderer } from '../../ui/templates/templates';
|
|
19
|
-
/**
|
|
20
|
-
* Render time picker component
|
|
21
|
-
* @param container Container element
|
|
22
|
-
* @param options Time picker options
|
|
23
|
-
* @returns Object with cleanup function and update function
|
|
24
|
-
*/
|
|
25
|
-
export function renderTimePicker(container, options) {
|
|
26
|
-
var time = options.time, granularity = options.granularity, format = options.format, minTime = options.minTime, maxTime = options.maxTime, _a = options.timeStep, timeStep = _a === void 0 ? 1 : _a, _b = options.disabled, disabled = _b === void 0 ? false : _b, onChange = options.onChange, templates = options.templates;
|
|
27
|
-
// Initialize template renderer
|
|
28
|
-
var templateRenderer = createTemplateRenderer(templates || {});
|
|
29
|
-
// Clear container
|
|
30
|
-
container.innerHTML = '';
|
|
31
|
-
// Current time state (will be updated)
|
|
32
|
-
var currentTime = __assign({}, time);
|
|
33
|
-
// Store references to updateable elements
|
|
34
|
-
var updateableElements = {};
|
|
35
|
-
// Create increment/decrement buttons for each time unit
|
|
36
|
-
var timeUnits = getTimeUnits(granularity);
|
|
37
|
-
// Build time units HTML using templates
|
|
38
|
-
var timeUnitsHtml = '';
|
|
39
|
-
timeUnits.forEach(function (unit, index) {
|
|
40
|
-
// Render time unit using template
|
|
41
|
-
var unitHtml = templateRenderer.renderTemplateString({
|
|
42
|
-
templateKey: 'timeUnit',
|
|
43
|
-
data: {
|
|
44
|
-
unitType: unit,
|
|
45
|
-
upButton: templateRenderer.renderTemplateString({
|
|
46
|
-
templateKey: 'timeUpButton',
|
|
47
|
-
data: {
|
|
48
|
-
unitType: unit,
|
|
49
|
-
disabled: disabled ? 'disabled' : ''
|
|
50
|
-
}
|
|
51
|
-
}),
|
|
52
|
-
valueDisplay: templateRenderer.renderTemplateString({
|
|
53
|
-
templateKey: 'timeValue',
|
|
54
|
-
data: {
|
|
55
|
-
value: getTimeUnitValue(currentTime, unit, format)
|
|
56
|
-
}
|
|
57
|
-
}),
|
|
58
|
-
downButton: templateRenderer.renderTemplateString({
|
|
59
|
-
templateKey: 'timeDownButton',
|
|
60
|
-
data: {
|
|
61
|
-
unitType: unit,
|
|
62
|
-
disabled: disabled ? 'disabled' : ''
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
timeUnitsHtml += unitHtml;
|
|
68
|
-
// Add separator between units (except after last unit)
|
|
69
|
-
if (index < timeUnits.length - 1) {
|
|
70
|
-
timeUnitsHtml += templateRenderer.renderTemplateString({
|
|
71
|
-
templateKey: 'timeSeparator',
|
|
72
|
-
data: { separator: ':' }
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
// Render time controls with units
|
|
77
|
-
var timeControlsHtml = templateRenderer.renderTemplateString({
|
|
78
|
-
templateKey: 'timeControls',
|
|
79
|
-
data: {
|
|
80
|
-
timeUnits: timeUnitsHtml,
|
|
81
|
-
ampmControl: format === '12h' ? templateRenderer.renderTemplateString({
|
|
82
|
-
templateKey: 'ampmControl',
|
|
83
|
-
data: {
|
|
84
|
-
ampmButton: templateRenderer.renderTemplateString({
|
|
85
|
-
templateKey: 'ampmButton',
|
|
86
|
-
data: {
|
|
87
|
-
ampmValue: currentTime.hour >= 12 ? 'PM' : 'AM',
|
|
88
|
-
disabled: disabled ? 'disabled' : ''
|
|
89
|
-
}
|
|
90
|
-
})
|
|
91
|
-
}
|
|
92
|
-
}) : ''
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
// Render time display
|
|
96
|
-
var timeDisplayHtml = templateRenderer.renderTemplateString({
|
|
97
|
-
templateKey: 'timeDisplay',
|
|
98
|
-
data: {
|
|
99
|
-
timeValue: formatTime(currentTime, granularity, format)
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
// Render complete time picker wrapper
|
|
103
|
-
var timePickerHtml = templateRenderer.renderTemplateString({
|
|
104
|
-
templateKey: 'timePickerWrapper',
|
|
105
|
-
data: {
|
|
106
|
-
timeDisplay: timeDisplayHtml,
|
|
107
|
-
timeControls: timeControlsHtml
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
// Insert rendered HTML into container
|
|
111
|
-
container.innerHTML = timePickerHtml;
|
|
112
|
-
// Get references to elements for event handling
|
|
113
|
-
var timeDisplay = container.querySelector('[data-kt-datepicker-time-display]');
|
|
114
|
-
// Add event listeners to time unit buttons
|
|
115
|
-
timeUnits.forEach(function (unit) {
|
|
116
|
-
var upButton = container.querySelector("[data-kt-datepicker-time-up][aria-label=\"Increment ".concat(unit, "\"]"));
|
|
117
|
-
var downButton = container.querySelector("[data-kt-datepicker-time-down][aria-label=\"Decrement ".concat(unit, "\"]"));
|
|
118
|
-
var valueDisplay = container.querySelector("[data-kt-datepicker-time-unit=\"".concat(unit, "\"] [data-kt-datepicker-time-value]"));
|
|
119
|
-
// Store reference for updates
|
|
120
|
-
updateableElements["".concat(unit, "Value")] = valueDisplay;
|
|
121
|
-
// Add event listeners with UI update
|
|
122
|
-
upButton.addEventListener('click', function () {
|
|
123
|
-
if (!disabled && onChange) {
|
|
124
|
-
var newTime = incrementTimeUnit(currentTime, unit, timeStep, format);
|
|
125
|
-
var validation = validateTime(newTime, minTime, maxTime);
|
|
126
|
-
if (validation.isValid) {
|
|
127
|
-
// Update current time state
|
|
128
|
-
currentTime = newTime;
|
|
129
|
-
// Update UI immediately
|
|
130
|
-
updateTimeDisplay(currentTime, updateableElements, timeDisplay, granularity, format);
|
|
131
|
-
// Call onChange callback
|
|
132
|
-
onChange(currentTime);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
downButton.addEventListener('click', function () {
|
|
137
|
-
if (!disabled && onChange) {
|
|
138
|
-
var newTime = decrementTimeUnit(currentTime, unit, timeStep, format);
|
|
139
|
-
var validation = validateTime(newTime, minTime, maxTime);
|
|
140
|
-
if (validation.isValid) {
|
|
141
|
-
// Update current time state
|
|
142
|
-
currentTime = newTime;
|
|
143
|
-
// Update UI immediately
|
|
144
|
-
updateTimeDisplay(currentTime, updateableElements, timeDisplay, granularity, format);
|
|
145
|
-
// Call onChange callback
|
|
146
|
-
onChange(currentTime);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
// Add AM/PM toggle for 12-hour format
|
|
152
|
-
if (format === '12h') {
|
|
153
|
-
var ampmButton_1 = container.querySelector('[data-kt-datepicker-ampm-button]');
|
|
154
|
-
ampmButton_1.addEventListener('click', function () {
|
|
155
|
-
if (!disabled && onChange) {
|
|
156
|
-
var newTime = __assign({}, currentTime);
|
|
157
|
-
if (newTime.hour >= 12) {
|
|
158
|
-
newTime.hour = newTime.hour - 12;
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
newTime.hour = newTime.hour + 12;
|
|
162
|
-
}
|
|
163
|
-
if (validateTime(newTime, minTime, maxTime).isValid) {
|
|
164
|
-
// Update current time state
|
|
165
|
-
currentTime = newTime;
|
|
166
|
-
// Update UI immediately
|
|
167
|
-
updateTimeDisplay(currentTime, updateableElements, timeDisplay, granularity, format);
|
|
168
|
-
// Update AM/PM button text
|
|
169
|
-
ampmButton_1.textContent = currentTime.hour >= 12 ? 'PM' : 'AM';
|
|
170
|
-
// Call onChange callback
|
|
171
|
-
onChange(currentTime);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
// Add keyboard navigation for time picker
|
|
177
|
-
container.addEventListener('keydown', function (e) {
|
|
178
|
-
if (disabled)
|
|
179
|
-
return;
|
|
180
|
-
// Handle arrow up/down for time units
|
|
181
|
-
if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
|
182
|
-
e.preventDefault();
|
|
183
|
-
e.stopPropagation();
|
|
184
|
-
// Find the currently focused time unit
|
|
185
|
-
var focusedElement_1 = document.activeElement;
|
|
186
|
-
if (!focusedElement_1 || !container.contains(focusedElement_1))
|
|
187
|
-
return;
|
|
188
|
-
// Determine which time unit is focused
|
|
189
|
-
var focusedUnit_1 = null;
|
|
190
|
-
timeUnits.forEach(function (unit) {
|
|
191
|
-
var unitElement = container.querySelector("[data-kt-datepicker-time-unit=\"".concat(unit, "\"]"));
|
|
192
|
-
if (unitElement && unitElement.contains(focusedElement_1)) {
|
|
193
|
-
focusedUnit_1 = unit;
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
// If no specific unit is focused, focus the first one
|
|
197
|
-
if (!focusedUnit_1 && timeUnits.length > 0) {
|
|
198
|
-
focusedUnit_1 = timeUnits[0];
|
|
199
|
-
}
|
|
200
|
-
if (focusedUnit_1 && onChange) {
|
|
201
|
-
var newTime = void 0;
|
|
202
|
-
if (e.key === 'ArrowUp') {
|
|
203
|
-
newTime = incrementTimeUnit(currentTime, focusedUnit_1, timeStep, format);
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
newTime = decrementTimeUnit(currentTime, focusedUnit_1, timeStep, format);
|
|
207
|
-
}
|
|
208
|
-
var validation = validateTime(newTime, minTime, maxTime);
|
|
209
|
-
if (validation.isValid) {
|
|
210
|
-
// Update current time state
|
|
211
|
-
currentTime = newTime;
|
|
212
|
-
// Update UI immediately
|
|
213
|
-
updateTimeDisplay(currentTime, updateableElements, timeDisplay, granularity, format);
|
|
214
|
-
// Call onChange callback
|
|
215
|
-
onChange(currentTime);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
// Handle Tab navigation between time units
|
|
220
|
-
if (e.key === 'Tab') {
|
|
221
|
-
var timeUnitElements = timeUnits.map(function (unit) {
|
|
222
|
-
return container.querySelector("[data-kt-datepicker-time-unit=\"".concat(unit, "\"]"));
|
|
223
|
-
}).filter(Boolean);
|
|
224
|
-
if (timeUnitElements.length > 0) {
|
|
225
|
-
var currentIndex = timeUnitElements.findIndex(function (el) { return el.contains(document.activeElement); });
|
|
226
|
-
var nextIndex = currentIndex;
|
|
227
|
-
if (e.shiftKey) {
|
|
228
|
-
// Shift+Tab: move to previous
|
|
229
|
-
nextIndex = currentIndex > 0 ? currentIndex - 1 : timeUnitElements.length - 1;
|
|
230
|
-
}
|
|
231
|
-
else {
|
|
232
|
-
// Tab: move to next
|
|
233
|
-
nextIndex = currentIndex < timeUnitElements.length - 1 ? currentIndex + 1 : 0;
|
|
234
|
-
}
|
|
235
|
-
if (nextIndex >= 0 && nextIndex < timeUnitElements.length) {
|
|
236
|
-
timeUnitElements[nextIndex].focus();
|
|
237
|
-
e.preventDefault();
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
// Make time units focusable
|
|
243
|
-
timeUnits.forEach(function (unit) {
|
|
244
|
-
var unitElement = container.querySelector("[data-kt-datepicker-time-unit=\"".concat(unit, "\"]"));
|
|
245
|
-
if (unitElement) {
|
|
246
|
-
unitElement.tabIndex = 0;
|
|
247
|
-
unitElement.setAttribute('role', 'spinbutton');
|
|
248
|
-
unitElement.setAttribute('aria-label', "".concat(unit, " value"));
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
// Update function to sync with external state changes
|
|
252
|
-
var update = function (newTime) {
|
|
253
|
-
currentTime = __assign({}, newTime);
|
|
254
|
-
updateTimeDisplay(currentTime, updateableElements, timeDisplay, granularity, format);
|
|
255
|
-
// Update AM/PM button if it exists
|
|
256
|
-
if (format === '12h') {
|
|
257
|
-
var ampmButton = container.querySelector('.kt-datepicker-time-ampm-button');
|
|
258
|
-
if (ampmButton) {
|
|
259
|
-
ampmButton.textContent = currentTime.hour >= 12 ? 'PM' : 'AM';
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
// Return cleanup function and update function
|
|
264
|
-
return {
|
|
265
|
-
cleanup: function () {
|
|
266
|
-
container.innerHTML = '';
|
|
267
|
-
},
|
|
268
|
-
update: update
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Update time picker display elements with new time values
|
|
273
|
-
* @param time New time state
|
|
274
|
-
* @param updateableElements Object containing references to updateable DOM elements
|
|
275
|
-
* @param timeDisplay Main time display element
|
|
276
|
-
* @param granularity Time granularity
|
|
277
|
-
* @param format Time format
|
|
278
|
-
*/
|
|
279
|
-
function updateTimeDisplay(time, updateableElements, timeDisplay, granularity, format) {
|
|
280
|
-
// Update main time display
|
|
281
|
-
var mainDisplayText = formatTime(time, granularity, format);
|
|
282
|
-
timeDisplay.textContent = mainDisplayText;
|
|
283
|
-
// Update individual time unit displays
|
|
284
|
-
var timeUnits = getTimeUnits(granularity);
|
|
285
|
-
timeUnits.forEach(function (unit) {
|
|
286
|
-
var elementKey = "".concat(unit, "Value");
|
|
287
|
-
var element = updateableElements[elementKey];
|
|
288
|
-
if (element) {
|
|
289
|
-
var unitValue = getTimeUnitValue(time, unit, format);
|
|
290
|
-
element.textContent = unitValue;
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Get time units based on granularity
|
|
296
|
-
* @param granularity Time granularity
|
|
297
|
-
* @returns Array of time unit names
|
|
298
|
-
*/
|
|
299
|
-
function getTimeUnits(granularity) {
|
|
300
|
-
switch (granularity) {
|
|
301
|
-
case 'hour':
|
|
302
|
-
return ['hour'];
|
|
303
|
-
case 'minute':
|
|
304
|
-
return ['hour', 'minute'];
|
|
305
|
-
case 'second':
|
|
306
|
-
return ['hour', 'minute', 'second'];
|
|
307
|
-
default:
|
|
308
|
-
return ['hour', 'minute'];
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* Get display value for time unit
|
|
313
|
-
* @param time TimeState object
|
|
314
|
-
* @param unit Time unit
|
|
315
|
-
* @param format Time format
|
|
316
|
-
* @returns Formatted unit value
|
|
317
|
-
*/
|
|
318
|
-
function getTimeUnitValue(time, unit, format) {
|
|
319
|
-
switch (unit) {
|
|
320
|
-
case 'hour':
|
|
321
|
-
var hour = time.hour;
|
|
322
|
-
if (format === '12h') {
|
|
323
|
-
hour = hour % 12;
|
|
324
|
-
hour = hour === 0 ? 12 : hour;
|
|
325
|
-
}
|
|
326
|
-
return hour.toString().padStart(2, '0');
|
|
327
|
-
case 'minute':
|
|
328
|
-
return time.minute.toString().padStart(2, '0');
|
|
329
|
-
case 'second':
|
|
330
|
-
return time.second.toString().padStart(2, '0');
|
|
331
|
-
default:
|
|
332
|
-
return '';
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* Increment time unit
|
|
337
|
-
* @param time Current time
|
|
338
|
-
* @param unit Time unit to increment
|
|
339
|
-
* @param step Step increment
|
|
340
|
-
* @param format Time format
|
|
341
|
-
* @returns New time state
|
|
342
|
-
*/
|
|
343
|
-
function incrementTimeUnit(time, unit, step, format) {
|
|
344
|
-
var newTime = __assign({}, time);
|
|
345
|
-
switch (unit) {
|
|
346
|
-
case 'hour':
|
|
347
|
-
newTime.hour = (newTime.hour + step) % 24;
|
|
348
|
-
break;
|
|
349
|
-
case 'minute':
|
|
350
|
-
newTime.minute = (newTime.minute + step) % 60;
|
|
351
|
-
break;
|
|
352
|
-
case 'second':
|
|
353
|
-
newTime.second = (newTime.second + step) % 60;
|
|
354
|
-
break;
|
|
355
|
-
}
|
|
356
|
-
return newTime;
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* Decrement time unit
|
|
360
|
-
* @param time Current time
|
|
361
|
-
* @param unit Time unit to decrement
|
|
362
|
-
* @param step Step increment
|
|
363
|
-
* @param format Time format
|
|
364
|
-
* @returns New time state
|
|
365
|
-
*/
|
|
366
|
-
function decrementTimeUnit(time, unit, step, format) {
|
|
367
|
-
var newTime = __assign({}, time);
|
|
368
|
-
switch (unit) {
|
|
369
|
-
case 'hour':
|
|
370
|
-
newTime.hour = (newTime.hour - step + 24) % 24;
|
|
371
|
-
break;
|
|
372
|
-
case 'minute':
|
|
373
|
-
newTime.minute = (newTime.minute - step + 60) % 60;
|
|
374
|
-
break;
|
|
375
|
-
case 'second':
|
|
376
|
-
newTime.second = (newTime.second - step + 60) % 60;
|
|
377
|
-
break;
|
|
378
|
-
}
|
|
379
|
-
return newTime;
|
|
380
|
-
}
|
|
381
|
-
//# sourceMappingURL=time-picker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"time-picker.js","sourceRoot":"","sources":["../../../../../../src/components/datepicker/ui/renderers/time-picker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;;;;;;;;AAGH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAkBtE;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAsB,EAAE,OAA0B;IACzE,IAAA,IAAI,GAAiG,OAAO,KAAxG,EAAE,WAAW,GAAoF,OAAO,YAA3F,EAAE,MAAM,GAA4E,OAAO,OAAnF,EAAE,OAAO,GAAmE,OAAO,QAA1E,EAAE,OAAO,GAA0D,OAAO,QAAjE,EAAE,KAAwD,OAAO,SAAnD,EAAZ,QAAQ,mBAAG,CAAC,KAAA,EAAE,KAA0C,OAAO,SAAjC,EAAhB,QAAQ,mBAAG,KAAK,KAAA,EAAE,QAAQ,GAAgB,OAAO,SAAvB,EAAE,SAAS,GAAK,OAAO,UAAZ,CAAa;IAErH,+BAA+B;IAC/B,IAAM,gBAAgB,GAAG,sBAAsB,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;IAEjE,kBAAkB;IAClB,SAAS,CAAC,SAAS,GAAG,EAAE,CAAC;IAEzB,uCAAuC;IACvC,IAAI,WAAW,gBAAQ,IAAI,CAAE,CAAC;IAE9B,0CAA0C;IAC1C,IAAM,kBAAkB,GAAmC,EAAE,CAAC;IAE9D,wDAAwD;IACxD,IAAM,SAAS,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;IAE5C,wCAAwC;IACxC,IAAI,aAAa,GAAG,EAAE,CAAC;IACvB,SAAS,CAAC,OAAO,CAAC,UAAC,IAAI,EAAE,KAAK;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,CAAC;YAC/C,MAAM;QACR,KAAK,QAAQ;YACX,OAAO,CAAC,MAAM,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;YACnD,MAAM;QACR,KAAK,QAAQ;YACX,OAAO,CAAC,MAAM,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;YACnD,MAAM;IACV,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/components/datepicker/ui/templates/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,aAAa,CAAC"}
|
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* templates.ts - Unified template system for KTDatepicker
|
|
3
|
-
* Consolidates all template functionality including default templates, merging logic,
|
|
4
|
-
* rendering utilities, and template management into a single, unified system.
|
|
5
|
-
*/
|
|
6
|
-
var __assign = (this && this.__assign) || function () {
|
|
7
|
-
__assign = Object.assign || function(t) {
|
|
8
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
9
|
-
s = arguments[i];
|
|
10
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
11
|
-
t[p] = s[p];
|
|
12
|
-
}
|
|
13
|
-
return t;
|
|
14
|
-
};
|
|
15
|
-
return __assign.apply(this, arguments);
|
|
16
|
-
};
|
|
17
|
-
// Default template strings for all UI fragments
|
|
18
|
-
export var defaultTemplates = {
|
|
19
|
-
// Add role="dialog" and aria-modal to the dropdown container
|
|
20
|
-
container: "<div data-kt-datepicker-container {{class}}></div>",
|
|
21
|
-
header: "<div data-kt-datepicker-header {{class}}\">{{prevButton}}<span data-kt-datepicker-month-year>{{month}} {{year}}</span>{{nextButton}}</div>",
|
|
22
|
-
footer: "<div data-kt-datepicker-footer {{class}}\">{{todayButton}} {{clearButton}} {{applyButton}}</div>",
|
|
23
|
-
// Add role="grid" and aria-label to the calendar grid
|
|
24
|
-
calendarGrid: "<table data-kt-datepicker-calendar-grid role=\"grid\" aria-label=\"Calendar\" aria-readonly=\"true\" {{class}}>{{calendar}}</table>",
|
|
25
|
-
// Add role="gridcell" to dayCell, aria-selected, and tabindex for keyboard nav
|
|
26
|
-
dayCell: "<td data-kt-datepicker-day role=\"gridcell\" {{attributes}} {{class}}><button type=\"button\" data-day=\"{{day}}\" aria-label=\"Select {{day}}\" tabindex=\"-1\">{{day}}</button></td>",
|
|
27
|
-
// Month/year selectors (add aria-live for dynamic updates)
|
|
28
|
-
monthYearSelect: "<div data-kt-datepicker-monthyear-select aria-live=\"polite\" {{class}}>{{monthSelect}} {{yearSelect}}</div>",
|
|
29
|
-
monthSelection: "<div data-kt-datepicker-month-selection {{class}}>{{months}}</div>",
|
|
30
|
-
yearSelection: "<div data-kt-datepicker-year-selection {{class}}>{{years}}</div>",
|
|
31
|
-
inputWrapper: "<div data-kt-datepicker-input-wrapper class=\"flex items-center {{class}}\">{{input}} {{icon}}</div>",
|
|
32
|
-
segmentedDateInput: "<div data-kt-datepicker-segmented-input class=\"flex items-center {{class}}\">{{segments}}</div>",
|
|
33
|
-
segmentedDateRangeInput: "<div data-kt-datepicker-segmented-range-input class=\"flex items-center {{class}}\">{{start}}{{separator}}{{end}}</div>",
|
|
34
|
-
/**
|
|
35
|
-
* Template for a single date segment (e.g., day, month, year)
|
|
36
|
-
* Placeholders: segmentType, segmentValue, ariaLabel, ariaValueNow, ariaValueText, ariaValueMin, ariaValueMax, tabindex, contenteditable
|
|
37
|
-
*/
|
|
38
|
-
dateSegment: "<span data-segment=\"{{segmentType}}\" role=\"spinbutton\" aria-label=\"{{ariaLabel}}\" aria-valuenow=\"{{ariaValueNow}}\" aria-valuetext=\"{{ariaValueText}}\" aria-valuemin=\"{{ariaValueMin}}\" aria-valuemax=\"{{ariaValueMax}}\" tabindex=\"{{tabindex}}\" contenteditable=\"{{contenteditable}}\" {{class}}>{{segmentValue}}</span>",
|
|
39
|
-
/**
|
|
40
|
-
* Template for a segment separator (e.g., / or space)
|
|
41
|
-
* Placeholders: separator
|
|
42
|
-
*/
|
|
43
|
-
segmentSeparator: "<span data-segment-separator {{class}}>{{separator}}</span>",
|
|
44
|
-
placeholder: "<span data-kt-datepicker-placeholder {{class}}>{{placeholder}}</span>",
|
|
45
|
-
displayWrapper: "<div data-kt-datepicker-display-wrapper {{class}}>{{value}}</div>",
|
|
46
|
-
displayElement: "<span data-kt-datepicker-display-element {{class}}>{{value}}</span>",
|
|
47
|
-
timePanel: "<div data-kt-datepicker-time-panel {{class}}>{{hours}}:{{minutes}}:{{seconds}} {{amPm}}</div>",
|
|
48
|
-
multiDateTag: "<span data-kt-datepicker-multidate-tag {{class}}>{{date}} <button>{{removeButton}}</button></span>",
|
|
49
|
-
emptyState: "<div data-kt-datepicker-empty {{class}}>{{message}}</div>",
|
|
50
|
-
// Add aria-haspopup and aria-expanded to calendar button
|
|
51
|
-
calendarButton: "<button type=\"button\" data-kt-datepicker-calendar-btn aria-label=\"Open calendar\" aria-haspopup=\"dialog\" aria-expanded=\"false\" {{class}}>\n <svg width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <rect x=\"3\" y=\"4\" width=\"18\" height=\"18\" rx=\"2\"/>\n <path d=\"M16 2v4M8 2v4M3 10h18\"/>\n </svg>\n </button>",
|
|
52
|
-
// Add role="dialog" and aria-modal to dropdown
|
|
53
|
-
dropdown: "<div data-kt-datepicker-dropdown role=\"dialog\" aria-modal=\"true\" aria-label=\"Date picker\" class=\"hidden {{class}}\"></div>",
|
|
54
|
-
prevButton: "<button type=\"button\" data-kt-datepicker-prev aria-label=\"Previous month\" {{class}}>\n <svg width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path d=\"m15 18-6-6 6-6\"/>\n </svg>\n </button>",
|
|
55
|
-
nextButton: "<button type=\"button\" data-kt-datepicker-next aria-label=\"Next month\" {{class}}>\n <svg width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path d=\"m9 18 6-6-6-6\"/>\n </svg>\n </button>",
|
|
56
|
-
// Add role="row" to calendar table rows
|
|
57
|
-
calendarTable: "<table data-kt-datepicker-calendar-table role=\"grid\" aria-label=\"Calendar\" aria-readonly=\"true\" {{class}}><thead><tr role=\"row\">\n <th class=\"py-1 px-1 text-xs font-semibold text-gray-500 dark:text-gray-400\">{{sunday}}</th>\n <th class=\"py-1 px-1 text-xs font-semibold text-gray-500 dark:text-gray-400\">{{monday}}</th>\n <th class=\"py-1 px-1 text-xs font-semibold text-gray-500 dark:text-gray-400\">{{tuesday}}</th>\n <th class=\"py-1 px-1 text-xs font-semibold text-gray-500 dark:text-gray-400\">{{wednesday}}</th>\n <th class=\"py-1 px-1 text-xs font-semibold text-gray-500 dark:text-gray-400\">{{thursday}}</th>\n <th class=\"py-1 px-1 text-xs font-semibold text-gray-500 dark:text-gray-400\">{{friday}}</th>\n <th class=\"py-1 px-1 text-xs font-semibold text-gray-500 dark:text-gray-400\">{{saturday}}</th>\n </tr></thead>{{body}}</table>",
|
|
58
|
-
calendarBody: "<tbody data-kt-datepicker-calendar-body {{class}}>{{rows}}</tbody>",
|
|
59
|
-
calendarRow: "<tr data-kt-datepicker-calendar-row role=\"row\" {{class}}>{{cells}}</tr>",
|
|
60
|
-
todayButton: "<button type=\"button\" data-kt-datepicker-today {{class}}>Today</button>",
|
|
61
|
-
clearButton: "<button type=\"button\" data-kt-datepicker-clear {{class}}>Clear</button>",
|
|
62
|
-
applyButton: "<button type=\"button\" data-kt-datepicker-apply {{class}}>Apply</button>",
|
|
63
|
-
/**
|
|
64
|
-
* Container for multiple calendar months (horizontal multi-month view)
|
|
65
|
-
*/
|
|
66
|
-
multiMonthContainer: "<div data-kt-datepicker-multimonth-container class=\"flex flex-col md:flex-row gap-4 {{class}}\">{{calendars}}</div>",
|
|
67
|
-
// Time picker templates
|
|
68
|
-
timePickerWrapper: "<div data-kt-datepicker-time-picker {{class}}>{{timeDisplay}} {{timeControls}}</div>",
|
|
69
|
-
timeDisplay: "<div data-kt-datepicker-time-display {{class}}>{{timeValue}}</div>",
|
|
70
|
-
timeControls: "<div data-kt-datepicker-time-controls {{class}}>{{timeUnits}} {{ampmControl}}</div>",
|
|
71
|
-
timeUnit: "<div data-kt-datepicker-time-unit data-kt-datepicker-time-unit=\"{{unitType}}\" {{class}}>{{upButton}} {{valueDisplay}} {{downButton}}</div>",
|
|
72
|
-
timeUpButton: "<button type=\"button\" data-kt-datepicker-time-up aria-label=\"Increment {{unitType}}\" {{class}} {{disabled}}>\u25B2</button>",
|
|
73
|
-
timeDownButton: "<button type=\"button\" data-kt-datepicker-time-down aria-label=\"Decrement {{unitType}}\" {{class}} {{disabled}}>\u25BC</button>",
|
|
74
|
-
timeValue: "<span data-kt-datepicker-time-value {{class}}>{{value}}</span>",
|
|
75
|
-
timeSeparator: "<span data-kt-datepicker-time-separator {{class}}>{{separator}}</span>",
|
|
76
|
-
ampmControl: "<div data-kt-datepicker-ampm-control {{class}}>{{ampmButton}}</div>",
|
|
77
|
-
ampmButton: "<button type=\"button\" data-kt-datepicker-ampm-button aria-label=\"Toggle AM/PM\" {{class}} {{disabled}}>{{ampmValue}}</button>",
|
|
78
|
-
/**
|
|
79
|
-
* Panel wrapper for header + calendar
|
|
80
|
-
*/
|
|
81
|
-
panel: "<div data-kt-datepicker-panel {{class}}>{{header}}{{calendar}}</div>",
|
|
82
|
-
/**
|
|
83
|
-
* Live region for accessibility announcements
|
|
84
|
-
*/
|
|
85
|
-
liveRegion: "<div data-kt-datepicker-live aria-live=\"polite\" {{class}}></div>",
|
|
86
|
-
/**
|
|
87
|
-
* Container for range input start date segment
|
|
88
|
-
*/
|
|
89
|
-
rangeStartContainer: "<div data-kt-datepicker-segmented-start {{class}}></div>",
|
|
90
|
-
/**
|
|
91
|
-
* Container for range input end date segment
|
|
92
|
-
*/
|
|
93
|
-
rangeEndContainer: "<div data-kt-datepicker-segmented-end {{class}}></div>",
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* Merges default templates with user overrides.
|
|
97
|
-
* User overrides take precedence.
|
|
98
|
-
*/
|
|
99
|
-
export function mergeTemplates(defaults, overrides) {
|
|
100
|
-
return __assign(__assign({}, defaults), (overrides || {}));
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Merges default, config, and user templates (string or function)
|
|
104
|
-
* Precedence: default < config < user
|
|
105
|
-
*/
|
|
106
|
-
export function getMergedTemplates(configTemplates, userTemplates) {
|
|
107
|
-
return __assign(__assign(__assign({}, defaultTemplates), (configTemplates || {})), (userTemplates || {}));
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Renders a template string with data using {{key}} placeholders.
|
|
111
|
-
* Enhanced to handle class placeholders specifically.
|
|
112
|
-
*/
|
|
113
|
-
export function renderTemplateString(template, data) {
|
|
114
|
-
return template.replace(/{{(\w+)}}/g, function (_, key) {
|
|
115
|
-
var value = data[key];
|
|
116
|
-
if (value !== undefined) {
|
|
117
|
-
return String(value);
|
|
118
|
-
}
|
|
119
|
-
return '';
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Merges class data with template data for rendering.
|
|
124
|
-
* Extracts class for specific template key from config classes object.
|
|
125
|
-
*/
|
|
126
|
-
export function mergeClassData(templateKey, templateData, configClasses) {
|
|
127
|
-
var classValue = (configClasses === null || configClasses === void 0 ? void 0 : configClasses[templateKey]) || '';
|
|
128
|
-
return __assign(__assign({}, templateData), { class: classValue });
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Checks if a template is a function.
|
|
132
|
-
*/
|
|
133
|
-
export function isTemplateFunction(tpl) {
|
|
134
|
-
return typeof tpl === 'function';
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Renders a template string with data and returns a DocumentFragment.
|
|
138
|
-
* Usage: const frag = renderTemplateToDOM(template, data)
|
|
139
|
-
*/
|
|
140
|
-
export function renderTemplateToDOM(template, data) {
|
|
141
|
-
if (data === void 0) { data = {}; }
|
|
142
|
-
var html = renderTemplateString(template, data);
|
|
143
|
-
var frag = document.createDocumentFragment();
|
|
144
|
-
var temp = document.createElement('div');
|
|
145
|
-
temp.innerHTML = html;
|
|
146
|
-
while (temp.firstChild) {
|
|
147
|
-
frag.appendChild(temp.firstChild);
|
|
148
|
-
}
|
|
149
|
-
return frag;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Unified template renderer for all datepicker UI components
|
|
153
|
-
* Ensures consistent template usage and eliminates scattered rendering logic
|
|
154
|
-
*/
|
|
155
|
-
var TemplateRenderer = /** @class */ (function () {
|
|
156
|
-
function TemplateRenderer(templates) {
|
|
157
|
-
this._templates = templates;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Render a template with data and return HTML string
|
|
161
|
-
*/
|
|
162
|
-
TemplateRenderer.prototype.renderTemplateString = function (options) {
|
|
163
|
-
var templateKey = options.templateKey, data = options.data, configClasses = options.configClasses, fallbackTemplate = options.fallbackTemplate;
|
|
164
|
-
// Get template from template set
|
|
165
|
-
var template = this._templates[templateKey];
|
|
166
|
-
// Use fallback if template not found
|
|
167
|
-
if (!template && fallbackTemplate) {
|
|
168
|
-
template = fallbackTemplate;
|
|
169
|
-
}
|
|
170
|
-
// Validate template exists
|
|
171
|
-
if (!template) {
|
|
172
|
-
throw new Error("Template not found for key: ".concat(templateKey));
|
|
173
|
-
}
|
|
174
|
-
// Merge class data
|
|
175
|
-
var mergedData = mergeClassData(templateKey, data, configClasses);
|
|
176
|
-
// Render template
|
|
177
|
-
if (isTemplateFunction(template)) {
|
|
178
|
-
return template(mergedData);
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
return renderTemplateString(template, mergedData);
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
/**
|
|
185
|
-
* Render a template with data and return HTMLElement
|
|
186
|
-
*/
|
|
187
|
-
TemplateRenderer.prototype.renderTemplateToElement = function (options) {
|
|
188
|
-
var html = this.renderTemplateString(options);
|
|
189
|
-
var fragment = renderTemplateToDOM(html);
|
|
190
|
-
var element = fragment.firstElementChild;
|
|
191
|
-
if (!element) {
|
|
192
|
-
throw new Error("Failed to render template to element for key: ".concat(options.templateKey));
|
|
193
|
-
}
|
|
194
|
-
return element;
|
|
195
|
-
};
|
|
196
|
-
/**
|
|
197
|
-
* Render a template with data and return DocumentFragment
|
|
198
|
-
*/
|
|
199
|
-
TemplateRenderer.prototype.renderTemplateToFragment = function (options) {
|
|
200
|
-
var html = this.renderTemplateString(options);
|
|
201
|
-
return renderTemplateToDOM(html);
|
|
202
|
-
};
|
|
203
|
-
/**
|
|
204
|
-
* Check if a template exists
|
|
205
|
-
*/
|
|
206
|
-
TemplateRenderer.prototype.hasTemplate = function (templateKey) {
|
|
207
|
-
return !!this._templates[templateKey];
|
|
208
|
-
};
|
|
209
|
-
/**
|
|
210
|
-
* Get template by key
|
|
211
|
-
*/
|
|
212
|
-
TemplateRenderer.prototype.getTemplate = function (templateKey) {
|
|
213
|
-
return this._templates[templateKey];
|
|
214
|
-
};
|
|
215
|
-
/**
|
|
216
|
-
* Update templates
|
|
217
|
-
*/
|
|
218
|
-
TemplateRenderer.prototype.updateTemplates = function (templates) {
|
|
219
|
-
this._templates = templates;
|
|
220
|
-
};
|
|
221
|
-
/**
|
|
222
|
-
* Get all templates
|
|
223
|
-
*/
|
|
224
|
-
TemplateRenderer.prototype.getTemplates = function () {
|
|
225
|
-
return __assign({}, this._templates);
|
|
226
|
-
};
|
|
227
|
-
return TemplateRenderer;
|
|
228
|
-
}());
|
|
229
|
-
export { TemplateRenderer };
|
|
230
|
-
/**
|
|
231
|
-
* Factory function to create a template renderer
|
|
232
|
-
*/
|
|
233
|
-
export function createTemplateRenderer(templates) {
|
|
234
|
-
return new TemplateRenderer(templates);
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Returns the merged template set for a given config.
|
|
238
|
-
*/
|
|
239
|
-
export function getTemplateStrings(config) {
|
|
240
|
-
return mergeTemplates(defaultTemplates, config === null || config === void 0 ? void 0 : config.templates);
|
|
241
|
-
}
|
|
242
|
-
//# sourceMappingURL=templates.js.map
|