@nuralyui/timepicker 0.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.
Files changed (43) hide show
  1. package/controllers/formatting.controller.d.ts +93 -0
  2. package/controllers/formatting.controller.d.ts.map +1 -0
  3. package/controllers/formatting.controller.js +195 -0
  4. package/controllers/formatting.controller.js.map +1 -0
  5. package/controllers/index.d.ts +9 -0
  6. package/controllers/index.d.ts.map +1 -0
  7. package/controllers/index.js +9 -0
  8. package/controllers/index.js.map +1 -0
  9. package/controllers/selection.controller.d.ts +72 -0
  10. package/controllers/selection.controller.d.ts.map +1 -0
  11. package/controllers/selection.controller.js +175 -0
  12. package/controllers/selection.controller.js.map +1 -0
  13. package/controllers/validation.controller.d.ts +88 -0
  14. package/controllers/validation.controller.d.ts.map +1 -0
  15. package/controllers/validation.controller.js +200 -0
  16. package/controllers/validation.controller.js.map +1 -0
  17. package/index.d.ts +12 -0
  18. package/index.js +12 -0
  19. package/interfaces/timepicker.interface.d.ts +103 -0
  20. package/interfaces/timepicker.interface.d.ts.map +1 -0
  21. package/interfaces/timepicker.interface.js +7 -0
  22. package/interfaces/timepicker.interface.js.map +1 -0
  23. package/package.json +63 -0
  24. package/test/timepicker.test.d.ts +7 -0
  25. package/test/timepicker.test.d.ts.map +1 -0
  26. package/test/timepicker.test.js +218 -0
  27. package/test/timepicker.test.js.map +1 -0
  28. package/timepicker.component.backup.d.ts +165 -0
  29. package/timepicker.component.backup.js +890 -0
  30. package/timepicker.component.clean.d.ts +95 -0
  31. package/timepicker.component.clean.js +471 -0
  32. package/timepicker.component.d.ts +117 -0
  33. package/timepicker.component.js +747 -0
  34. package/timepicker.constants.d.ts +85 -0
  35. package/timepicker.constants.js +85 -0
  36. package/timepicker.style.d.ts +7 -0
  37. package/timepicker.style.js +646 -0
  38. package/timepicker.types.d.ts +161 -0
  39. package/timepicker.types.js +125 -0
  40. package/utils/time.utils.d.ts +87 -0
  41. package/utils/time.utils.d.ts.map +1 -0
  42. package/utils/time.utils.js +235 -0
  43. package/utils/time.utils.js.map +1 -0
@@ -0,0 +1,218 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Nuraly, Laabidi Aymen
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
+ return new (P || (P = Promise))(function (resolve, reject) {
9
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
13
+ });
14
+ };
15
+ import { html, fixture, expect, aTimeout } from '@open-wc/testing';
16
+ import { TimeFormat, TimePickerSize, TimePickerVariant } from '../timepicker.types.js';
17
+ describe('NrTimePickerElement', () => {
18
+ let element;
19
+ beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
20
+ element = yield fixture(html `<nr-timepicker></nr-timepicker>`);
21
+ }));
22
+ describe('Basic functionality', () => {
23
+ it('should render successfully', () => {
24
+ expect(element).to.exist;
25
+ expect(element.tagName).to.equal('NR-TIMEPICKER');
26
+ });
27
+ it('should have default properties', () => {
28
+ expect(element.format).to.equal(TimeFormat.TwentyFourHour);
29
+ expect(element.showSeconds).to.be.false;
30
+ expect(element.disabled).to.be.false;
31
+ expect(element.readonly).to.be.false;
32
+ expect(element.required).to.be.false;
33
+ });
34
+ it('should have empty initial value', () => {
35
+ expect(element.value).to.equal('');
36
+ });
37
+ });
38
+ describe('Time format handling', () => {
39
+ it('should handle 24-hour format by default', () => __awaiter(void 0, void 0, void 0, function* () {
40
+ element.value = '14:30';
41
+ yield element.updateComplete;
42
+ expect(element.value).to.equal('14:30');
43
+ }));
44
+ it('should handle 12-hour format', () => __awaiter(void 0, void 0, void 0, function* () {
45
+ element.format = TimeFormat.TwelveHour;
46
+ element.value = '2:30 PM';
47
+ yield element.updateComplete;
48
+ expect(element.value).to.equal('2:30 PM');
49
+ }));
50
+ it('should format time with seconds when enabled', () => __awaiter(void 0, void 0, void 0, function* () {
51
+ element.showSeconds = true;
52
+ element.value = '14:30:45';
53
+ yield element.updateComplete;
54
+ expect(element.value).to.equal('14:30:45');
55
+ }));
56
+ });
57
+ describe('Time validation', () => {
58
+ it('should validate time within min/max range', () => __awaiter(void 0, void 0, void 0, function* () {
59
+ element.minTime = '09:00';
60
+ element.maxTime = '17:00';
61
+ yield element.updateComplete;
62
+ // Valid time within range
63
+ element.value = '12:00';
64
+ yield element.updateComplete;
65
+ expect(element.value).to.equal('12:00');
66
+ }));
67
+ it('should reject invalid time formats', () => __awaiter(void 0, void 0, void 0, function* () {
68
+ const invalidValue = 'invalid-time';
69
+ element.value = invalidValue;
70
+ yield element.updateComplete;
71
+ // Should not set invalid value
72
+ expect(element.value).to.not.equal(invalidValue);
73
+ }));
74
+ });
75
+ describe('Clock functionality', () => {
76
+ it('should open and close clock', () => __awaiter(void 0, void 0, void 0, function* () {
77
+ var _a, _b, _c;
78
+ // Check initial state via DOM
79
+ let dropdown = (_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.time-picker__dropdown--open');
80
+ expect(dropdown).to.not.exist;
81
+ element.open();
82
+ yield element.updateComplete;
83
+ dropdown = (_b = element.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('.time-picker__dropdown--open');
84
+ expect(dropdown).to.exist;
85
+ element.close();
86
+ yield element.updateComplete;
87
+ dropdown = (_c = element.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('.time-picker__dropdown--open');
88
+ expect(dropdown).to.not.exist;
89
+ }));
90
+ it('should toggle clock state via trigger button', () => __awaiter(void 0, void 0, void 0, function* () {
91
+ var _d, _e, _f, _g;
92
+ const trigger = (_d = element.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector('.time-picker__trigger');
93
+ // Initially closed
94
+ let dropdown = (_e = element.shadowRoot) === null || _e === void 0 ? void 0 : _e.querySelector('.time-picker__dropdown--open');
95
+ expect(dropdown).to.not.exist;
96
+ // Click to open
97
+ trigger.click();
98
+ yield element.updateComplete;
99
+ dropdown = (_f = element.shadowRoot) === null || _f === void 0 ? void 0 : _f.querySelector('.time-picker__dropdown--open');
100
+ expect(dropdown).to.exist;
101
+ // Click to close
102
+ trigger.click();
103
+ yield element.updateComplete;
104
+ dropdown = (_g = element.shadowRoot) === null || _g === void 0 ? void 0 : _g.querySelector('.time-picker__dropdown--open');
105
+ expect(dropdown).to.not.exist;
106
+ }));
107
+ });
108
+ describe('Time manipulation', () => {
109
+ it('should clear time value', () => __awaiter(void 0, void 0, void 0, function* () {
110
+ element.value = '12:00';
111
+ yield element.updateComplete;
112
+ element.clear();
113
+ yield element.updateComplete;
114
+ expect(element.value).to.equal('');
115
+ }));
116
+ it('should set current time', () => __awaiter(void 0, void 0, void 0, function* () {
117
+ element.setToNow();
118
+ yield element.updateComplete;
119
+ // Should have some value after setting to now
120
+ expect(element.value).to.not.equal('');
121
+ // Basic format check for 24-hour format
122
+ expect(element.value).to.match(/^\d{1,2}:\d{2}$/);
123
+ }));
124
+ });
125
+ describe('Event handling', () => {
126
+ it('should dispatch time-change event', () => __awaiter(void 0, void 0, void 0, function* () {
127
+ let eventFired = false;
128
+ let eventDetail = null;
129
+ element.addEventListener('nr-time-change', (e) => {
130
+ const customEvent = e;
131
+ eventFired = true;
132
+ eventDetail = customEvent.detail;
133
+ });
134
+ element.value = '15:30';
135
+ yield element.updateComplete;
136
+ // Allow time for event to be dispatched
137
+ yield aTimeout(10);
138
+ expect(eventFired).to.be.true;
139
+ expect(eventDetail).to.exist;
140
+ }));
141
+ it('should dispatch clock open/close events', () => __awaiter(void 0, void 0, void 0, function* () {
142
+ let openEventFired = false;
143
+ let closeEventFired = false;
144
+ element.addEventListener('nr-clock-open', () => {
145
+ openEventFired = true;
146
+ });
147
+ element.addEventListener('nr-clock-close', () => {
148
+ closeEventFired = true;
149
+ });
150
+ element.open();
151
+ yield element.updateComplete;
152
+ yield aTimeout(10);
153
+ expect(openEventFired).to.be.true;
154
+ element.close();
155
+ yield element.updateComplete;
156
+ yield aTimeout(10);
157
+ expect(closeEventFired).to.be.true;
158
+ }));
159
+ });
160
+ describe('Accessibility', () => {
161
+ it('should have proper ARIA attributes', () => __awaiter(void 0, void 0, void 0, function* () {
162
+ var _a;
163
+ element.label = 'Select Time';
164
+ element.required = true;
165
+ yield element.updateComplete;
166
+ const input = (_a = element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('input');
167
+ expect(input).to.exist;
168
+ expect(input === null || input === void 0 ? void 0 : input.getAttribute('required')).to.exist;
169
+ }));
170
+ it('should support disabled state', () => __awaiter(void 0, void 0, void 0, function* () {
171
+ var _b;
172
+ element.disabled = true;
173
+ yield element.updateComplete;
174
+ const input = (_b = element.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('input');
175
+ expect(input === null || input === void 0 ? void 0 : input.hasAttribute('disabled')).to.be.true;
176
+ }));
177
+ it('should support readonly state', () => __awaiter(void 0, void 0, void 0, function* () {
178
+ var _c;
179
+ element.readonly = true;
180
+ yield element.updateComplete;
181
+ const input = (_c = element.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('input');
182
+ expect(input === null || input === void 0 ? void 0 : input.hasAttribute('readonly')).to.be.true;
183
+ }));
184
+ });
185
+ describe('Size and variant attributes', () => {
186
+ it('should apply size attribute to host', () => __awaiter(void 0, void 0, void 0, function* () {
187
+ element.size = TimePickerSize.Large;
188
+ yield element.updateComplete;
189
+ expect(element.hasAttribute('size')).to.be.true;
190
+ expect(element.getAttribute('size')).to.equal('large');
191
+ }));
192
+ it('should apply variant attribute to host', () => __awaiter(void 0, void 0, void 0, function* () {
193
+ element.variant = TimePickerVariant.Outlined;
194
+ yield element.updateComplete;
195
+ expect(element.hasAttribute('variant')).to.be.true;
196
+ expect(element.getAttribute('variant')).to.equal('outlined');
197
+ }));
198
+ });
199
+ describe('Controller integration', () => {
200
+ it('should have selection controller', () => {
201
+ // Access private controller for testing (cast to any to bypass TypeScript)
202
+ const controller = element.selectionController;
203
+ expect(controller).to.exist;
204
+ expect(typeof controller.selectTime).to.equal('function');
205
+ });
206
+ it('should have validation controller', () => {
207
+ const controller = element.validationController;
208
+ expect(controller).to.exist;
209
+ expect(typeof controller.validateConstraints).to.equal('function');
210
+ });
211
+ it('should have formatting controller', () => {
212
+ const controller = element.formattingController;
213
+ expect(controller).to.exist;
214
+ expect(typeof controller.formatForDisplay).to.equal('function');
215
+ });
216
+ });
217
+ });
218
+ //# sourceMappingURL=timepicker.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timepicker.test.js","sourceRoot":"","sources":["../../../../src/components/timepicker/test/timepicker.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;;;;;;AAEH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEvF,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,IAAI,OAA4B,CAAC;IAEjC,UAAU,CAAC,GAAS,EAAE;QACpB,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,CAAA,iCAAiC,CAAC,CAAC;IACjE,CAAC,CAAA,CAAC,CAAC;IAEH,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;QACnC,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;YACpC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;YACzB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC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AmC,EAAE,GAAG,EAAE;YAC3C,MAAM,UAAU,GAAI,OAAe,CAAC,oBAAoB,CAAC;YACzD,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;YAC5B,MAAM,CAAC,OAAO,UAAU,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;YAC3C,MAAM,UAAU,GAAI,OAAe,CAAC,oBAAoB,CAAC;YACzD,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;YAC5B,MAAM,CAAC,OAAO,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2023 Nuraly, Laabidi Aymen\n * SPDX-License-Identifier: MIT\n */\n\nimport { html, fixture, expect, aTimeout } from '@open-wc/testing';\nimport { NrTimePickerElement } from '../timepicker.component.js';\nimport { TimeFormat, TimePickerSize, TimePickerVariant } from '../timepicker.types.js';\n\ndescribe('NrTimePickerElement', () => {\n let element: NrTimePickerElement;\n\n beforeEach(async () => {\n element = await fixture(html`<nr-timepicker></nr-timepicker>`);\n });\n\n describe('Basic functionality', () => {\n it('should render successfully', () => {\n expect(element).to.exist;\n expect(element.tagName).to.equal('NR-TIMEPICKER');\n });\n\n it('should have default properties', () => {\n expect(element.format).to.equal(TimeFormat.TwentyFourHour);\n expect(element.showSeconds).to.be.false;\n expect(element.disabled).to.be.false;\n expect(element.readonly).to.be.false;\n expect(element.required).to.be.false;\n });\n\n it('should have empty initial value', () => {\n expect(element.value).to.equal('');\n });\n });\n\n describe('Time format handling', () => {\n it('should handle 24-hour format by default', async () => {\n element.value = '14:30';\n await element.updateComplete;\n expect(element.value).to.equal('14:30');\n });\n\n it('should handle 12-hour format', async () => {\n element.format = TimeFormat.TwelveHour;\n element.value = '2:30 PM';\n await element.updateComplete;\n expect(element.value).to.equal('2:30 PM');\n });\n\n it('should format time with seconds when enabled', async () => {\n element.showSeconds = true;\n element.value = '14:30:45';\n await element.updateComplete;\n expect(element.value).to.equal('14:30:45');\n });\n });\n\n describe('Time validation', () => {\n it('should validate time within min/max range', async () => {\n element.minTime = '09:00';\n element.maxTime = '17:00';\n await element.updateComplete;\n \n // Valid time within range\n element.value = '12:00';\n await element.updateComplete;\n expect(element.value).to.equal('12:00');\n });\n\n it('should reject invalid time formats', async () => {\n const invalidValue = 'invalid-time';\n element.value = invalidValue;\n await element.updateComplete;\n \n // Should not set invalid value\n expect(element.value).to.not.equal(invalidValue);\n });\n });\n\n describe('Clock functionality', () => {\n it('should open and close clock', async () => {\n // Check initial state via DOM\n let dropdown = element.shadowRoot?.querySelector('.time-picker__dropdown--open');\n expect(dropdown).to.not.exist;\n \n element.open();\n await element.updateComplete;\n dropdown = element.shadowRoot?.querySelector('.time-picker__dropdown--open');\n expect(dropdown).to.exist;\n \n element.close();\n await element.updateComplete;\n dropdown = element.shadowRoot?.querySelector('.time-picker__dropdown--open');\n expect(dropdown).to.not.exist;\n });\n\n it('should toggle clock state via trigger button', async () => {\n const trigger = element.shadowRoot?.querySelector('.time-picker__trigger') as HTMLButtonElement;\n \n // Initially closed\n let dropdown = element.shadowRoot?.querySelector('.time-picker__dropdown--open');\n expect(dropdown).to.not.exist;\n \n // Click to open\n trigger.click();\n await element.updateComplete;\n dropdown = element.shadowRoot?.querySelector('.time-picker__dropdown--open');\n expect(dropdown).to.exist;\n \n // Click to close\n trigger.click();\n await element.updateComplete;\n dropdown = element.shadowRoot?.querySelector('.time-picker__dropdown--open');\n expect(dropdown).to.not.exist;\n });\n });\n\n describe('Time manipulation', () => {\n it('should clear time value', async () => {\n element.value = '12:00';\n await element.updateComplete;\n \n element.clear();\n await element.updateComplete;\n expect(element.value).to.equal('');\n });\n\n it('should set current time', async () => {\n element.setToNow();\n await element.updateComplete;\n \n // Should have some value after setting to now\n expect(element.value).to.not.equal('');\n // Basic format check for 24-hour format\n expect(element.value).to.match(/^\\d{1,2}:\\d{2}$/);\n });\n });\n\n describe('Event handling', () => {\n it('should dispatch time-change event', async () => {\n let eventFired = false;\n let eventDetail = null;\n\n element.addEventListener('nr-time-change', (e: Event) => {\n const customEvent = e as CustomEvent;\n eventFired = true;\n eventDetail = customEvent.detail;\n });\n\n element.value = '15:30';\n await element.updateComplete;\n \n // Allow time for event to be dispatched\n await aTimeout(10);\n \n expect(eventFired).to.be.true;\n expect(eventDetail).to.exist;\n });\n\n it('should dispatch clock open/close events', async () => {\n let openEventFired = false;\n let closeEventFired = false;\n\n element.addEventListener('nr-clock-open', () => {\n openEventFired = true;\n });\n\n element.addEventListener('nr-clock-close', () => {\n closeEventFired = true;\n });\n\n element.open();\n await element.updateComplete;\n await aTimeout(10);\n expect(openEventFired).to.be.true;\n\n element.close();\n await element.updateComplete;\n await aTimeout(10);\n expect(closeEventFired).to.be.true;\n });\n });\n\n describe('Accessibility', () => {\n it('should have proper ARIA attributes', async () => {\n element.label = 'Select Time';\n element.required = true;\n await element.updateComplete;\n\n const input = element.shadowRoot?.querySelector('input');\n expect(input).to.exist;\n expect(input?.getAttribute('required')).to.exist;\n });\n\n it('should support disabled state', async () => {\n element.disabled = true;\n await element.updateComplete;\n\n const input = element.shadowRoot?.querySelector('input');\n expect(input?.hasAttribute('disabled')).to.be.true;\n });\n\n it('should support readonly state', async () => {\n element.readonly = true;\n await element.updateComplete;\n\n const input = element.shadowRoot?.querySelector('input');\n expect(input?.hasAttribute('readonly')).to.be.true;\n });\n });\n\n describe('Size and variant attributes', () => {\n it('should apply size attribute to host', async () => {\n element.size = TimePickerSize.Large;\n await element.updateComplete;\n expect(element.hasAttribute('size')).to.be.true;\n expect(element.getAttribute('size')).to.equal('large');\n });\n\n it('should apply variant attribute to host', async () => {\n element.variant = TimePickerVariant.Outlined;\n await element.updateComplete;\n expect(element.hasAttribute('variant')).to.be.true;\n expect(element.getAttribute('variant')).to.equal('outlined');\n });\n });\n\n describe('Controller integration', () => {\n it('should have selection controller', () => {\n // Access private controller for testing (cast to any to bypass TypeScript)\n const controller = (element as any).selectionController;\n expect(controller).to.exist;\n expect(typeof controller.selectTime).to.equal('function');\n });\n\n it('should have validation controller', () => {\n const controller = (element as any).validationController;\n expect(controller).to.exist;\n expect(typeof controller.validateConstraints).to.equal('function');\n });\n\n it('should have formatting controller', () => {\n const controller = (element as any).formattingController;\n expect(controller).to.exist;\n expect(typeof controller.formatForDisplay).to.equal('function');\n });\n });\n});\n"]}
@@ -0,0 +1,165 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Nuraly, Laabidi Aymen
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ import { LitElement, PropertyValues, TemplateResult } from 'lit';
7
+ import { TimeValue, TimeFormat, TimePickerMode, TimePickerSize, TimePickerVariant, TimePickerState, TimePickerPlacement, TimePickerConfig } from './timepicker.types.js';
8
+ import { TimePickerHost } from './interfaces/timepicker.interface.js';
9
+ declare const NrTimePickerElement_base: (new (...args: any[]) => import("../../shared/dependency-mixin.js").DependencyAware) & (new (...args: any[]) => import("../../shared/theme-mixin.js").ThemeAware) & (new (...args: any[]) => import("../../shared/event-handler-mixin.js").EventHandlerCapable) & typeof LitElement;
10
+ /**
11
+ * NuralyUI Time Picker - A comprehensive time selection component
12
+ *
13
+ * @element nr-timepicker
14
+ *
15
+ * @fires nr-time-change - Fired when time is selected
16
+ * @fires nr-clock-open - Fired when clock dropdown is opened
17
+ * @fires nr-clock-close - Fired when clock dropdown is closed
18
+ * @fires nr-focus - Fired when component receives focus
19
+ * @fires nr-blur - Fired when component loses focus
20
+ * @fires nr-validation - Fired when validation state changes
21
+ *
22
+ * @slot label - Label content for the input field
23
+ * @slot helper-text - Helper text content below the input field
24
+ * @slot icon - Icon content for the input field trigger
25
+ *
26
+ * @csspart input - The input field part
27
+ * @csspart dropdown - The clock dropdown container part
28
+ * @csspart clock - The clock face part
29
+ * @csspart clock-hand - The clock hand part
30
+ * @csspart time-input - Individual time input parts (hours, minutes, seconds)
31
+ *
32
+ * @example Basic usage
33
+ * ```html
34
+ * <nr-timepicker
35
+ * label="Select Time"
36
+ * @nr-time-change="${this.handleTimeChange}">
37
+ * </nr-timepicker>
38
+ * ```
39
+ *
40
+ * @example 12-hour format with seconds
41
+ * ```html
42
+ * <nr-timepicker
43
+ * format="12h"
44
+ * show-seconds
45
+ * label="Meeting Time">
46
+ * </nr-timepicker>
47
+ * ```
48
+ *
49
+ * @example With time constraints
50
+ * ```html
51
+ * <nr-timepicker
52
+ * min-time="09:00"
53
+ * max-time="17:00"
54
+ * label="Business Hours">
55
+ * </nr-timepicker>
56
+ * ```
57
+ */
58
+ export declare class NrTimePickerElement extends NrTimePickerElement_base implements TimePickerHost {
59
+ static styles: import("lit").CSSResult;
60
+ private selectionController;
61
+ private validationController;
62
+ private formattingController;
63
+ private dropdownController;
64
+ name: string;
65
+ value: string;
66
+ defaultValue: string;
67
+ disabled: boolean;
68
+ readonly: boolean;
69
+ required: boolean;
70
+ placeholder: string;
71
+ format: TimeFormat;
72
+ showSeconds: boolean;
73
+ showClock: boolean;
74
+ minuteInterval: number;
75
+ secondInterval: number;
76
+ minTime?: string;
77
+ maxTime?: string;
78
+ disabledTimes?: string[];
79
+ enabledTimes?: string[];
80
+ size: TimePickerSize;
81
+ variant: TimePickerVariant;
82
+ state: TimePickerState;
83
+ placement: TimePickerPlacement;
84
+ label: string;
85
+ helperText: string;
86
+ clockOpen: boolean;
87
+ clockMode: TimePickerMode;
88
+ private inputValue;
89
+ private currentMode;
90
+ private validationMessage;
91
+ private inputElement;
92
+ private clockContainer?;
93
+ protected firstUpdated(): void;
94
+ protected updated(changedProperties: PropertyValues): void;
95
+ /**
96
+ * Initialize time picker with default values and constraints
97
+ */
98
+ private initializeTimePicker;
99
+ /**
100
+ * Handle property changes
101
+ */
102
+ private handlePropertyChanges;
103
+ /**
104
+ * Check if constraint properties changed
105
+ */
106
+ private hasConstraintPropertiesChanged;
107
+ /**
108
+ * Update validation constraints
109
+ */
110
+ private updateConstraints;
111
+ /**
112
+ * Set time from string value
113
+ */
114
+ private setTimeFromValue;
115
+ getCurrentTime(): TimeValue;
116
+ setTime(time: TimeValue): void;
117
+ formatTime(time: TimeValue): string;
118
+ parseTime(timeString: string): TimeValue | null;
119
+ getConfig(): TimePickerConfig;
120
+ validateTime(time: TimeValue): boolean;
121
+ /**
122
+ * Open the clock dropdown
123
+ */
124
+ openClock(): void;
125
+ /**
126
+ * Close the clock dropdown
127
+ */
128
+ closeClock(): void;
129
+ /**
130
+ * Toggle clock dropdown
131
+ */
132
+ toggleClock(): void;
133
+ /**
134
+ * Clear selected time
135
+ */
136
+ clear(): void;
137
+ private handleInputChange;
138
+ private handleInputFocus;
139
+ private handleInputBlur;
140
+ private handleTriggerClick;
141
+ private handleTimeSelection;
142
+ private handleModeChange;
143
+ private handleDigitalTimeChange;
144
+ private handleHourSelect;
145
+ private handleMinuteSelect;
146
+ private handleSecondSelect;
147
+ private handlePeriodToggle;
148
+ private updateInputValue;
149
+ protected render(): TemplateResult;
150
+ private renderLabel;
151
+ private renderInput;
152
+ private renderDropdown;
153
+ private renderColumnPicker;
154
+ private renderHourColumn;
155
+ private renderMinuteColumn;
156
+ private renderSecondColumn;
157
+ private renderClockNumbers;
158
+ private renderClockHand;
159
+ private renderModeButtons;
160
+ private renderDigitalInputs;
161
+ private renderPeriodToggle;
162
+ private renderHelperText;
163
+ }
164
+ export {};
165
+ //# sourceMappingURL=timepicker.component.backup.d.ts.map