@luzmo/ngx-lucero 1.0.1-alpha.78
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 +41 -0
- package/esm/components/accordion-item.d.ts +32 -0
- package/esm/components/accordion-item.js +89 -0
- package/esm/components/accordion.d.ts +38 -0
- package/esm/components/accordion.js +107 -0
- package/esm/components/action-bar.d.ts +32 -0
- package/esm/components/action-bar.js +83 -0
- package/esm/components/action-button.d.ts +59 -0
- package/esm/components/action-button.js +205 -0
- package/esm/components/action-group.d.ts +42 -0
- package/esm/components/action-group.js +155 -0
- package/esm/components/action-menu.d.ts +75 -0
- package/esm/components/action-menu.js +337 -0
- package/esm/components/avatar.d.ts +35 -0
- package/esm/components/avatar.js +94 -0
- package/esm/components/badge.d.ts +31 -0
- package/esm/components/badge.js +86 -0
- package/esm/components/button-group.d.ts +28 -0
- package/esm/components/button-group.js +71 -0
- package/esm/components/button.d.ts +40 -0
- package/esm/components/button.js +140 -0
- package/esm/components/calendar.d.ts +64 -0
- package/esm/components/calendar.js +218 -0
- package/esm/components/chat-message-group.d.ts +29 -0
- package/esm/components/chat-message-group.js +76 -0
- package/esm/components/chat-message.d.ts +50 -0
- package/esm/components/chat-message.js +156 -0
- package/esm/components/checkbox.d.ts +55 -0
- package/esm/components/checkbox.js +196 -0
- package/esm/components/clear-button.d.ts +32 -0
- package/esm/components/clear-button.js +88 -0
- package/esm/components/close-button.d.ts +33 -0
- package/esm/components/close-button.js +95 -0
- package/esm/components/color-area.d.ts +45 -0
- package/esm/components/color-area.js +167 -0
- package/esm/components/color-field.d.ts +91 -0
- package/esm/components/color-field.js +321 -0
- package/esm/components/color-handle.d.ts +31 -0
- package/esm/components/color-handle.js +90 -0
- package/esm/components/color-loupe.d.ts +29 -0
- package/esm/components/color-loupe.js +76 -0
- package/esm/components/color-menu.d.ts +36 -0
- package/esm/components/color-menu.js +97 -0
- package/esm/components/color-palette-group.d.ts +40 -0
- package/esm/components/color-palette-group.js +117 -0
- package/esm/components/color-palette.d.ts +43 -0
- package/esm/components/color-palette.js +126 -0
- package/esm/components/color-picker.d.ts +49 -0
- package/esm/components/color-picker.js +143 -0
- package/esm/components/color-slider.d.ts +53 -0
- package/esm/components/color-slider.js +215 -0
- package/esm/components/date-range-picker.d.ts +69 -0
- package/esm/components/date-range-picker.js +228 -0
- package/esm/components/date-time-picker.d.ts +71 -0
- package/esm/components/date-time-picker.js +249 -0
- package/esm/components/divider.d.ts +31 -0
- package/esm/components/divider.js +78 -0
- package/esm/components/field-group.d.ts +32 -0
- package/esm/components/field-group.js +101 -0
- package/esm/components/field-label.d.ts +37 -0
- package/esm/components/field-label.js +104 -0
- package/esm/components/help-text.d.ts +30 -0
- package/esm/components/help-text.js +77 -0
- package/esm/components/icon.d.ts +33 -0
- package/esm/components/icon.js +104 -0
- package/esm/components/infield-button.d.ts +35 -0
- package/esm/components/infield-button.js +103 -0
- package/esm/components/label.d.ts +29 -0
- package/esm/components/label.js +76 -0
- package/esm/components/menu.d.ts +53 -0
- package/esm/components/menu.js +218 -0
- package/esm/components/multi-language-field.d.ts +58 -0
- package/esm/components/multi-language-field.js +263 -0
- package/esm/components/number-field.d.ts +103 -0
- package/esm/components/number-field.js +372 -0
- package/esm/components/options.d.ts +58 -0
- package/esm/components/options.js +207 -0
- package/esm/components/overlay.d.ts +67 -0
- package/esm/components/overlay.js +212 -0
- package/esm/components/picker-button.d.ts +32 -0
- package/esm/components/picker-button.js +94 -0
- package/esm/components/picker.d.ts +79 -0
- package/esm/components/picker.js +340 -0
- package/esm/components/popover.d.ts +33 -0
- package/esm/components/popover.js +93 -0
- package/esm/components/progress-bar.d.ts +35 -0
- package/esm/components/progress-bar.js +121 -0
- package/esm/components/progress-circle.d.ts +35 -0
- package/esm/components/progress-circle.js +94 -0
- package/esm/components/progress-steps.d.ts +46 -0
- package/esm/components/progress-steps.js +127 -0
- package/esm/components/prompt-box.d.ts +88 -0
- package/esm/components/prompt-box.js +280 -0
- package/esm/components/radio-group.d.ts +39 -0
- package/esm/components/radio-group.js +136 -0
- package/esm/components/radio.d.ts +46 -0
- package/esm/components/radio.js +172 -0
- package/esm/components/search.d.ts +95 -0
- package/esm/components/search.js +351 -0
- package/esm/components/select.d.ts +82 -0
- package/esm/components/select.js +351 -0
- package/esm/components/slider.d.ts +47 -0
- package/esm/components/slider.js +185 -0
- package/esm/components/status-light.d.ts +30 -0
- package/esm/components/status-light.js +78 -0
- package/esm/components/swatch-group.d.ts +37 -0
- package/esm/components/swatch-group.js +126 -0
- package/esm/components/swatch.d.ts +49 -0
- package/esm/components/swatch.js +197 -0
- package/esm/components/switch.d.ts +48 -0
- package/esm/components/switch.js +160 -0
- package/esm/components/tab-panel.d.ts +29 -0
- package/esm/components/tab-panel.js +78 -0
- package/esm/components/tab.d.ts +32 -0
- package/esm/components/tab.js +100 -0
- package/esm/components/tabs-overflow.d.ts +33 -0
- package/esm/components/tabs-overflow.js +97 -0
- package/esm/components/tabs.d.ts +43 -0
- package/esm/components/tabs.js +150 -0
- package/esm/components/tag.d.ts +31 -0
- package/esm/components/tag.js +90 -0
- package/esm/components/tags.d.ts +30 -0
- package/esm/components/tags.js +81 -0
- package/esm/components/text-field.d.ts +87 -0
- package/esm/components/text-field.js +308 -0
- package/esm/components/toast.d.ts +30 -0
- package/esm/components/toast.js +68 -0
- package/esm/components/tooltip.d.ts +44 -0
- package/esm/components/tooltip.js +154 -0
- package/esm/components/top-nav-item.d.ts +35 -0
- package/esm/components/top-nav-item.js +120 -0
- package/esm/components/top-nav.d.ts +35 -0
- package/esm/components/top-nav.js +110 -0
- package/esm/index.d.ts +135 -0
- package/esm/index.js +269 -0
- package/package.json +40 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, forwardRef, inject, Input, output, Renderer2 } from '@angular/core';
|
|
2
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
3
|
+
import '@luzmo/lucero/number-field';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
const _c0 = ["*"];
|
|
6
|
+
/**
|
|
7
|
+
* Angular wrapper component for <luzmo-number-field>
|
|
8
|
+
*
|
|
9
|
+
* @slot help-text - default or non-negative help text to associate to your form element
|
|
10
|
+
* @slot negative-help-text - negative help text to associate to your form element when `invalid`
|
|
11
|
+
*/
|
|
12
|
+
export class LuzmoNumberField {
|
|
13
|
+
elementRef = inject(ElementRef);
|
|
14
|
+
renderer = inject(Renderer2);
|
|
15
|
+
destroyRef = inject(DestroyRef);
|
|
16
|
+
host = this.elementRef.nativeElement;
|
|
17
|
+
listenerCleanup = [];
|
|
18
|
+
/** The underlying custom element instance. Use to call imperative methods. */
|
|
19
|
+
get nativeElement() {
|
|
20
|
+
return this.host;
|
|
21
|
+
}
|
|
22
|
+
/** An `<luzmo-number-field>` element will process its numeric value with `new Intl.NumberFormat(this.resolvedLanguage, this.formatOptions).format(this.valueAsNumber)` in order to prepare it for visual delivery in the input. In order to customize this processing supply your own `Intl.NumberFormatOptions` object here. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat */
|
|
23
|
+
formatOptions;
|
|
24
|
+
/** Whether the stepper UI is hidden or not. */
|
|
25
|
+
hideStepper;
|
|
26
|
+
/** Whether the number field should grow to fit the content. */
|
|
27
|
+
grows;
|
|
28
|
+
/** Whether the number field is indeterminate (temporary UI state) */
|
|
29
|
+
indeterminate;
|
|
30
|
+
/** Whether the number field is keyboard focused. */
|
|
31
|
+
keyboardFocused;
|
|
32
|
+
/** The maximum value for the number field. */
|
|
33
|
+
max;
|
|
34
|
+
/** The minimum value for the number field. */
|
|
35
|
+
min;
|
|
36
|
+
/** The distance by which to alter the value of the element when taking a "step". When `this.formatOptions.style === 'percentage'` the default step will be set to 0.01 unless otherwise supplied to the element. */
|
|
37
|
+
step;
|
|
38
|
+
/** The modifier for the step. */
|
|
39
|
+
stepModifier;
|
|
40
|
+
/** The value held by the form control */
|
|
41
|
+
value;
|
|
42
|
+
helpTextManager;
|
|
43
|
+
/** A regular expression outlining the keys that will be allowed to update the value of the form control. */
|
|
44
|
+
allowedKeys;
|
|
45
|
+
/** Whether the `value` held by the form control is invalid. */
|
|
46
|
+
invalid;
|
|
47
|
+
/** A string applied via `aria-label` to the form control when a user visible label is not provided. */
|
|
48
|
+
label;
|
|
49
|
+
/** Name of the form control. */
|
|
50
|
+
name;
|
|
51
|
+
/** Text that appears in the form control when it has no value set */
|
|
52
|
+
placeholder;
|
|
53
|
+
type;
|
|
54
|
+
/** Pattern the `value` must match to be valid */
|
|
55
|
+
pattern;
|
|
56
|
+
/** Defines the maximum string length that the user can enter */
|
|
57
|
+
maxlength;
|
|
58
|
+
/** Defines the minimum string length that the user can enter */
|
|
59
|
+
minlength;
|
|
60
|
+
/** Whether the form control should accept a value longer than one line */
|
|
61
|
+
multiline;
|
|
62
|
+
/** Whether a user can interact with the value of the form control */
|
|
63
|
+
readonly;
|
|
64
|
+
/** The specific number of rows the form control should provide in the user interface */
|
|
65
|
+
rows;
|
|
66
|
+
/** The maximum number of rows the form control should grow to when `grows` is enabled. When content exceeds this limit, the textarea will show a scrollbar. A value of -1 means no maximum (unlimited growth). When set, the value must be >= 1; values < 1 will be disregarded. */
|
|
67
|
+
maxRows;
|
|
68
|
+
/** Whether the `value` held by the form control is valid. */
|
|
69
|
+
valid;
|
|
70
|
+
/** Whether to hide the validation state icons (valid/invalid icons). */
|
|
71
|
+
hideValidationIcons;
|
|
72
|
+
/** Whether to display the form control with no visible background */
|
|
73
|
+
quiet;
|
|
74
|
+
/** Whether the form control will be found to be invalid when it holds no `value` */
|
|
75
|
+
required;
|
|
76
|
+
/** What form of assistance should be provided when attempting to supply a value to the form control */
|
|
77
|
+
autocomplete;
|
|
78
|
+
/** An alteration to the value of the element has been committed by the user. */
|
|
79
|
+
changeEvent = output({ alias: 'change' });
|
|
80
|
+
/** The value of the element has changed. */
|
|
81
|
+
inputEvent = output({ alias: 'input' });
|
|
82
|
+
/** A key has been pressed. */
|
|
83
|
+
keypressEvent = output({ alias: 'keypress' });
|
|
84
|
+
constructor() {
|
|
85
|
+
this.bindEvents();
|
|
86
|
+
this.destroyRef.onDestroy(() => {
|
|
87
|
+
for (const cleanup of this.listenerCleanup) {
|
|
88
|
+
cleanup();
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
ngOnChanges(changes) {
|
|
93
|
+
for (const key of Object.keys(changes)) {
|
|
94
|
+
switch (key) {
|
|
95
|
+
case 'formatOptions':
|
|
96
|
+
this.setHostProperty('formatOptions', changes['formatOptions'].currentValue);
|
|
97
|
+
break;
|
|
98
|
+
case 'hideStepper':
|
|
99
|
+
this.setHostProperty('hideStepper', changes['hideStepper'].currentValue);
|
|
100
|
+
break;
|
|
101
|
+
case 'grows':
|
|
102
|
+
this.setHostProperty('grows', changes['grows'].currentValue);
|
|
103
|
+
break;
|
|
104
|
+
case 'indeterminate':
|
|
105
|
+
this.setHostProperty('indeterminate', changes['indeterminate'].currentValue);
|
|
106
|
+
break;
|
|
107
|
+
case 'keyboardFocused':
|
|
108
|
+
this.setHostProperty('keyboardFocused', changes['keyboardFocused'].currentValue);
|
|
109
|
+
break;
|
|
110
|
+
case 'max':
|
|
111
|
+
this.setHostProperty('max', changes['max'].currentValue);
|
|
112
|
+
break;
|
|
113
|
+
case 'min':
|
|
114
|
+
this.setHostProperty('min', changes['min'].currentValue);
|
|
115
|
+
break;
|
|
116
|
+
case 'step':
|
|
117
|
+
this.setHostProperty('step', changes['step'].currentValue);
|
|
118
|
+
break;
|
|
119
|
+
case 'stepModifier':
|
|
120
|
+
this.setHostProperty('stepModifier', changes['stepModifier'].currentValue);
|
|
121
|
+
break;
|
|
122
|
+
case 'value':
|
|
123
|
+
this.setHostProperty('value', changes['value'].currentValue);
|
|
124
|
+
break;
|
|
125
|
+
case 'helpTextManager':
|
|
126
|
+
this.setHostProperty('helpTextManager', changes['helpTextManager'].currentValue);
|
|
127
|
+
break;
|
|
128
|
+
case 'allowedKeys':
|
|
129
|
+
this.setHostProperty('allowedKeys', changes['allowedKeys'].currentValue);
|
|
130
|
+
break;
|
|
131
|
+
case 'invalid':
|
|
132
|
+
this.setHostProperty('invalid', changes['invalid'].currentValue);
|
|
133
|
+
break;
|
|
134
|
+
case 'label':
|
|
135
|
+
this.setHostProperty('label', changes['label'].currentValue);
|
|
136
|
+
break;
|
|
137
|
+
case 'name':
|
|
138
|
+
this.setHostProperty('name', changes['name'].currentValue);
|
|
139
|
+
break;
|
|
140
|
+
case 'placeholder':
|
|
141
|
+
this.setHostProperty('placeholder', changes['placeholder'].currentValue);
|
|
142
|
+
break;
|
|
143
|
+
case 'type':
|
|
144
|
+
this.setHostProperty('type', changes['type'].currentValue);
|
|
145
|
+
break;
|
|
146
|
+
case 'pattern':
|
|
147
|
+
this.setHostProperty('pattern', changes['pattern'].currentValue);
|
|
148
|
+
break;
|
|
149
|
+
case 'maxlength':
|
|
150
|
+
this.setHostProperty('maxlength', changes['maxlength'].currentValue);
|
|
151
|
+
break;
|
|
152
|
+
case 'minlength':
|
|
153
|
+
this.setHostProperty('minlength', changes['minlength'].currentValue);
|
|
154
|
+
break;
|
|
155
|
+
case 'multiline':
|
|
156
|
+
this.setHostProperty('multiline', changes['multiline'].currentValue);
|
|
157
|
+
break;
|
|
158
|
+
case 'readonly':
|
|
159
|
+
this.setHostProperty('readonly', changes['readonly'].currentValue);
|
|
160
|
+
break;
|
|
161
|
+
case 'rows':
|
|
162
|
+
this.setHostProperty('rows', changes['rows'].currentValue);
|
|
163
|
+
break;
|
|
164
|
+
case 'maxRows':
|
|
165
|
+
this.setHostProperty('maxRows', changes['maxRows'].currentValue);
|
|
166
|
+
break;
|
|
167
|
+
case 'valid':
|
|
168
|
+
this.setHostProperty('valid', changes['valid'].currentValue);
|
|
169
|
+
break;
|
|
170
|
+
case 'hideValidationIcons':
|
|
171
|
+
this.setHostProperty('hideValidationIcons', changes['hideValidationIcons'].currentValue);
|
|
172
|
+
break;
|
|
173
|
+
case 'quiet':
|
|
174
|
+
this.setHostProperty('quiet', changes['quiet'].currentValue);
|
|
175
|
+
break;
|
|
176
|
+
case 'required':
|
|
177
|
+
this.setHostProperty('required', changes['required'].currentValue);
|
|
178
|
+
break;
|
|
179
|
+
case 'autocomplete':
|
|
180
|
+
this.setHostProperty('autocomplete', changes['autocomplete'].currentValue);
|
|
181
|
+
break;
|
|
182
|
+
default:
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Forward a wrapper @Input to the underlying host element via Renderer2 so
|
|
189
|
+
* the wrapper stays compatible with non-DOM Angular platforms (SSR, tests).
|
|
190
|
+
* Unlike a "skip undefined" guard, this lets consumers reset values back to
|
|
191
|
+
* undefined / null by clearing their bindings.
|
|
192
|
+
*/
|
|
193
|
+
setHostProperty(key, value) {
|
|
194
|
+
this.renderer.setProperty(this.host, key, value);
|
|
195
|
+
}
|
|
196
|
+
bindEvents() {
|
|
197
|
+
this.listenerCleanup.push(this.renderer.listen(this.host, 'change', (event) => {
|
|
198
|
+
this.changeEvent.emit(event);
|
|
199
|
+
if (!this.isWritingValue) {
|
|
200
|
+
const eventWithDetail = event;
|
|
201
|
+
const eventTarget = event.target;
|
|
202
|
+
const detail = 'detail' in eventWithDetail ? eventWithDetail.detail : undefined;
|
|
203
|
+
const hostRecord = this.host;
|
|
204
|
+
const nextValue = (detail
|
|
205
|
+
?? eventTarget?.['value']
|
|
206
|
+
?? hostRecord['value']);
|
|
207
|
+
if (Object.is(this.lastCvaValue, nextValue)) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
this.lastCvaValue = nextValue;
|
|
211
|
+
this.setHostProperty('value', nextValue);
|
|
212
|
+
this.onChange(nextValue);
|
|
213
|
+
}
|
|
214
|
+
}));
|
|
215
|
+
this.listenerCleanup.push(this.renderer.listen(this.host, 'input', (event) => {
|
|
216
|
+
this.inputEvent.emit(event);
|
|
217
|
+
}));
|
|
218
|
+
this.listenerCleanup.push(this.renderer.listen(this.host, 'keypress', (event) => {
|
|
219
|
+
this.keypressEvent.emit(event);
|
|
220
|
+
}));
|
|
221
|
+
this.listenerCleanup.push(this.renderer.listen(this.host, 'blur', () => {
|
|
222
|
+
this.onTouched();
|
|
223
|
+
}));
|
|
224
|
+
}
|
|
225
|
+
onChange = () => { };
|
|
226
|
+
onTouched = () => { };
|
|
227
|
+
isWritingValue = false;
|
|
228
|
+
lastCvaValue;
|
|
229
|
+
writeValue(value) {
|
|
230
|
+
this.isWritingValue = true;
|
|
231
|
+
this.lastCvaValue = value;
|
|
232
|
+
this.setHostProperty('value', value);
|
|
233
|
+
this.isWritingValue = false;
|
|
234
|
+
}
|
|
235
|
+
registerOnChange(fn) {
|
|
236
|
+
this.onChange = fn;
|
|
237
|
+
}
|
|
238
|
+
registerOnTouched(fn) {
|
|
239
|
+
this.onTouched = fn;
|
|
240
|
+
}
|
|
241
|
+
setDisabledState(isDisabled) {
|
|
242
|
+
// Underlying element does not declare a 'disabled' field; nothing to do.
|
|
243
|
+
void isDisabled;
|
|
244
|
+
}
|
|
245
|
+
/** Sets the start and end positions of the current selection. */
|
|
246
|
+
setSelectionRange(selectionStart, selectionEnd, selectionDirection) {
|
|
247
|
+
return this.host.setSelectionRange(selectionStart, selectionEnd, selectionDirection);
|
|
248
|
+
}
|
|
249
|
+
/** Selects all the text. */
|
|
250
|
+
select() {
|
|
251
|
+
return this.host.select();
|
|
252
|
+
}
|
|
253
|
+
checkValidity() {
|
|
254
|
+
return this.host.checkValidity();
|
|
255
|
+
}
|
|
256
|
+
static ɵfac = function LuzmoNumberField_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || LuzmoNumberField)(); };
|
|
257
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: LuzmoNumberField, selectors: [["luzmo-number-field"]], inputs: { formatOptions: [0, "format-options", "formatOptions"], hideStepper: [0, "hide-stepper", "hideStepper"], grows: "grows", indeterminate: "indeterminate", keyboardFocused: [0, "keyboard-focused", "keyboardFocused"], max: "max", min: "min", step: "step", stepModifier: [0, "step-modifier", "stepModifier"], value: "value", helpTextManager: [0, "help-text-manager", "helpTextManager"], allowedKeys: [0, "allowed-keys", "allowedKeys"], invalid: "invalid", label: "label", name: "name", placeholder: "placeholder", type: "type", pattern: "pattern", maxlength: "maxlength", minlength: "minlength", multiline: "multiline", readonly: "readonly", rows: "rows", maxRows: [0, "max-rows", "maxRows"], valid: "valid", hideValidationIcons: [0, "hide-validation-icons", "hideValidationIcons"], quiet: "quiet", required: "required", autocomplete: "autocomplete" }, outputs: { changeEvent: "change", inputEvent: "input", keypressEvent: "keypress" }, exportAs: ["luzmoNumberField"], features: [i0.ɵɵProvidersFeature([
|
|
258
|
+
{
|
|
259
|
+
provide: NG_VALUE_ACCESSOR,
|
|
260
|
+
useExisting: forwardRef(() => LuzmoNumberField),
|
|
261
|
+
multi: true
|
|
262
|
+
}
|
|
263
|
+
]), i0.ɵɵNgOnChangesFeature], ngContentSelectors: _c0, decls: 1, vars: 0, template: function LuzmoNumberField_Template(rf, ctx) { if (rf & 1) {
|
|
264
|
+
i0.ɵɵprojectionDef();
|
|
265
|
+
i0.ɵɵprojection(0);
|
|
266
|
+
} }, encapsulation: 2, changeDetection: 0 });
|
|
267
|
+
}
|
|
268
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LuzmoNumberField, [{
|
|
269
|
+
type: Component,
|
|
270
|
+
args: [{
|
|
271
|
+
selector: 'luzmo-number-field',
|
|
272
|
+
exportAs: 'luzmoNumberField',
|
|
273
|
+
standalone: true,
|
|
274
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
275
|
+
template: '<ng-content />',
|
|
276
|
+
providers: [
|
|
277
|
+
{
|
|
278
|
+
provide: NG_VALUE_ACCESSOR,
|
|
279
|
+
useExisting: forwardRef(() => LuzmoNumberField),
|
|
280
|
+
multi: true
|
|
281
|
+
}
|
|
282
|
+
]
|
|
283
|
+
}]
|
|
284
|
+
}], () => [], { formatOptions: [{
|
|
285
|
+
type: Input,
|
|
286
|
+
args: [{ alias: 'format-options' }]
|
|
287
|
+
}], hideStepper: [{
|
|
288
|
+
type: Input,
|
|
289
|
+
args: [{ alias: 'hide-stepper' }]
|
|
290
|
+
}], grows: [{
|
|
291
|
+
type: Input,
|
|
292
|
+
args: [{ alias: 'grows' }]
|
|
293
|
+
}], indeterminate: [{
|
|
294
|
+
type: Input,
|
|
295
|
+
args: [{ alias: 'indeterminate' }]
|
|
296
|
+
}], keyboardFocused: [{
|
|
297
|
+
type: Input,
|
|
298
|
+
args: [{ alias: 'keyboard-focused' }]
|
|
299
|
+
}], max: [{
|
|
300
|
+
type: Input,
|
|
301
|
+
args: [{ alias: 'max' }]
|
|
302
|
+
}], min: [{
|
|
303
|
+
type: Input,
|
|
304
|
+
args: [{ alias: 'min' }]
|
|
305
|
+
}], step: [{
|
|
306
|
+
type: Input,
|
|
307
|
+
args: [{ alias: 'step' }]
|
|
308
|
+
}], stepModifier: [{
|
|
309
|
+
type: Input,
|
|
310
|
+
args: [{ alias: 'step-modifier' }]
|
|
311
|
+
}], value: [{
|
|
312
|
+
type: Input,
|
|
313
|
+
args: [{ alias: 'value' }]
|
|
314
|
+
}], helpTextManager: [{
|
|
315
|
+
type: Input,
|
|
316
|
+
args: [{ alias: 'help-text-manager' }]
|
|
317
|
+
}], allowedKeys: [{
|
|
318
|
+
type: Input,
|
|
319
|
+
args: [{ alias: 'allowed-keys' }]
|
|
320
|
+
}], invalid: [{
|
|
321
|
+
type: Input,
|
|
322
|
+
args: [{ alias: 'invalid' }]
|
|
323
|
+
}], label: [{
|
|
324
|
+
type: Input,
|
|
325
|
+
args: [{ alias: 'label' }]
|
|
326
|
+
}], name: [{
|
|
327
|
+
type: Input,
|
|
328
|
+
args: [{ alias: 'name' }]
|
|
329
|
+
}], placeholder: [{
|
|
330
|
+
type: Input,
|
|
331
|
+
args: [{ alias: 'placeholder' }]
|
|
332
|
+
}], type: [{
|
|
333
|
+
type: Input,
|
|
334
|
+
args: [{ alias: 'type' }]
|
|
335
|
+
}], pattern: [{
|
|
336
|
+
type: Input,
|
|
337
|
+
args: [{ alias: 'pattern' }]
|
|
338
|
+
}], maxlength: [{
|
|
339
|
+
type: Input,
|
|
340
|
+
args: [{ alias: 'maxlength' }]
|
|
341
|
+
}], minlength: [{
|
|
342
|
+
type: Input,
|
|
343
|
+
args: [{ alias: 'minlength' }]
|
|
344
|
+
}], multiline: [{
|
|
345
|
+
type: Input,
|
|
346
|
+
args: [{ alias: 'multiline' }]
|
|
347
|
+
}], readonly: [{
|
|
348
|
+
type: Input,
|
|
349
|
+
args: [{ alias: 'readonly' }]
|
|
350
|
+
}], rows: [{
|
|
351
|
+
type: Input,
|
|
352
|
+
args: [{ alias: 'rows' }]
|
|
353
|
+
}], maxRows: [{
|
|
354
|
+
type: Input,
|
|
355
|
+
args: [{ alias: 'max-rows' }]
|
|
356
|
+
}], valid: [{
|
|
357
|
+
type: Input,
|
|
358
|
+
args: [{ alias: 'valid' }]
|
|
359
|
+
}], hideValidationIcons: [{
|
|
360
|
+
type: Input,
|
|
361
|
+
args: [{ alias: 'hide-validation-icons' }]
|
|
362
|
+
}], quiet: [{
|
|
363
|
+
type: Input,
|
|
364
|
+
args: [{ alias: 'quiet' }]
|
|
365
|
+
}], required: [{
|
|
366
|
+
type: Input,
|
|
367
|
+
args: [{ alias: 'required' }]
|
|
368
|
+
}], autocomplete: [{
|
|
369
|
+
type: Input,
|
|
370
|
+
args: [{ alias: 'autocomplete' }]
|
|
371
|
+
}], changeEvent: [{ type: i0.Output, args: ["change"] }], inputEvent: [{ type: i0.Output, args: ["input"] }], keypressEvent: [{ type: i0.Output, args: ["keypress"] }] }); })();
|
|
372
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(LuzmoNumberField, { className: "LuzmoNumberField", filePath: "components/number-field.ts", lineNumber: 26 }); })();
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { OnChanges, SimpleChanges } from '@angular/core';
|
|
2
|
+
import { ControlValueAccessor } from '@angular/forms';
|
|
3
|
+
import '@luzmo/lucero/options';
|
|
4
|
+
import type { LuzmoOptions as LuzmoOptionsHostElement } from '@luzmo/lucero/options';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export declare class LuzmoOptions implements OnChanges, ControlValueAccessor {
|
|
7
|
+
private readonly elementRef;
|
|
8
|
+
private readonly renderer;
|
|
9
|
+
private readonly destroyRef;
|
|
10
|
+
private readonly host;
|
|
11
|
+
private readonly listenerCleanup;
|
|
12
|
+
/** The underlying custom element instance. Use to call imperative methods. */
|
|
13
|
+
get nativeElement(): LuzmoOptionsHostElement;
|
|
14
|
+
label?: string;
|
|
15
|
+
variant?: 'checkmarks' | 'checkboxes' | 'highlight';
|
|
16
|
+
selects?: 'single' | 'multiple';
|
|
17
|
+
emphasized?: boolean;
|
|
18
|
+
pending?: boolean;
|
|
19
|
+
/** options - The options to be listed in the options menu OptionValue is an object with the following properties: - label: string - value: string | number | null - disabled: boolean - divider: boolean - icon: IconDefinition - imgSrc: string */
|
|
20
|
+
options?: unknown;
|
|
21
|
+
noWrap?: boolean;
|
|
22
|
+
/** value - The value of the selected options */
|
|
23
|
+
value?: string | number | null;
|
|
24
|
+
/** Optional icon renderer callback for option icon area. When it returns null, default icon rendering is used. */
|
|
25
|
+
optionIconRenderer?: unknown;
|
|
26
|
+
/** Announces that the user has scrolled within the options menu. Only fires when the options menu is virtualized. */
|
|
27
|
+
readonly luzmoScrolledEvent: import("@angular/core").OutputEmitterRef<CustomEvent<unknown>>;
|
|
28
|
+
/** Announces that the `value` of the element has changed */
|
|
29
|
+
readonly changeEvent: import("@angular/core").OutputEmitterRef<CustomEvent<unknown>>;
|
|
30
|
+
/** Announces that the `arrowUp` key has been pressed and the top of the options menu has been exceeded */
|
|
31
|
+
readonly luzmoExceededTopEvent: import("@angular/core").OutputEmitterRef<CustomEvent<unknown>>;
|
|
32
|
+
/** Announces that the `arrowDown` key has been pressed and the bottom of the options menu has been exceeded */
|
|
33
|
+
readonly luzmoExceededBottomEvent: import("@angular/core").OutputEmitterRef<CustomEvent<unknown>>;
|
|
34
|
+
constructor();
|
|
35
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
36
|
+
/**
|
|
37
|
+
* Forward a wrapper @Input to the underlying host element via Renderer2 so
|
|
38
|
+
* the wrapper stays compatible with non-DOM Angular platforms (SSR, tests).
|
|
39
|
+
* Unlike a "skip undefined" guard, this lets consumers reset values back to
|
|
40
|
+
* undefined / null by clearing their bindings.
|
|
41
|
+
*/
|
|
42
|
+
private setHostProperty;
|
|
43
|
+
private bindEvents;
|
|
44
|
+
private onChange;
|
|
45
|
+
private onTouched;
|
|
46
|
+
private isWritingValue;
|
|
47
|
+
private lastCvaValue;
|
|
48
|
+
writeValue(value: string | number | null): void;
|
|
49
|
+
registerOnChange(fn: (value: string | number | null) => void): void;
|
|
50
|
+
registerOnTouched(fn: () => void): void;
|
|
51
|
+
setDisabledState(isDisabled: boolean): void;
|
|
52
|
+
focus({ preventScroll }: FocusOptions): void;
|
|
53
|
+
scrollToTop(): void;
|
|
54
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<LuzmoOptions, never>;
|
|
55
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<LuzmoOptions, "luzmo-options", ["luzmoOptions"], { "label": { "alias": "label"; "required": false; }; "variant": { "alias": "variant"; "required": false; }; "selects": { "alias": "selects"; "required": false; }; "emphasized": { "alias": "emphasized"; "required": false; }; "pending": { "alias": "pending"; "required": false; }; "options": { "alias": "options"; "required": false; }; "noWrap": { "alias": "no-wrap"; "required": false; }; "value": { "alias": "value"; "required": false; }; "optionIconRenderer": { "alias": "option-icon-renderer"; "required": false; }; }, { "luzmoScrolledEvent": "luzmo-scrolled"; "changeEvent": "change"; "luzmoExceededTopEvent": "luzmo-exceeded-top"; "luzmoExceededBottomEvent": "luzmo-exceeded-bottom"; }, never, ["*"], true, never>;
|
|
56
|
+
}
|
|
57
|
+
/** The underlying custom element type for LuzmoOptions */
|
|
58
|
+
export type LuzmoOptionsElement = LuzmoOptionsHostElement;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, forwardRef, inject, Input, output, Renderer2 } from '@angular/core';
|
|
2
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
3
|
+
import '@luzmo/lucero/options';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
const _c0 = ["*"];
|
|
6
|
+
/**
|
|
7
|
+
* Angular wrapper component for <luzmo-options>
|
|
8
|
+
*
|
|
9
|
+
* @slot (default) - option items to be listed in the options menu
|
|
10
|
+
*/
|
|
11
|
+
export class LuzmoOptions {
|
|
12
|
+
elementRef = inject(ElementRef);
|
|
13
|
+
renderer = inject(Renderer2);
|
|
14
|
+
destroyRef = inject(DestroyRef);
|
|
15
|
+
host = this.elementRef.nativeElement;
|
|
16
|
+
listenerCleanup = [];
|
|
17
|
+
/** The underlying custom element instance. Use to call imperative methods. */
|
|
18
|
+
get nativeElement() {
|
|
19
|
+
return this.host;
|
|
20
|
+
}
|
|
21
|
+
label;
|
|
22
|
+
variant;
|
|
23
|
+
selects;
|
|
24
|
+
emphasized;
|
|
25
|
+
pending;
|
|
26
|
+
/** options - The options to be listed in the options menu OptionValue is an object with the following properties: - label: string - value: string | number | null - disabled: boolean - divider: boolean - icon: IconDefinition - imgSrc: string */
|
|
27
|
+
options;
|
|
28
|
+
noWrap;
|
|
29
|
+
/** value - The value of the selected options */
|
|
30
|
+
value;
|
|
31
|
+
/** Optional icon renderer callback for option icon area. When it returns null, default icon rendering is used. */
|
|
32
|
+
optionIconRenderer;
|
|
33
|
+
/** Announces that the user has scrolled within the options menu. Only fires when the options menu is virtualized. */
|
|
34
|
+
luzmoScrolledEvent = output({ alias: 'luzmo-scrolled' });
|
|
35
|
+
/** Announces that the `value` of the element has changed */
|
|
36
|
+
changeEvent = output({ alias: 'change' });
|
|
37
|
+
/** Announces that the `arrowUp` key has been pressed and the top of the options menu has been exceeded */
|
|
38
|
+
luzmoExceededTopEvent = output({ alias: 'luzmo-exceeded-top' });
|
|
39
|
+
/** Announces that the `arrowDown` key has been pressed and the bottom of the options menu has been exceeded */
|
|
40
|
+
luzmoExceededBottomEvent = output({ alias: 'luzmo-exceeded-bottom' });
|
|
41
|
+
constructor() {
|
|
42
|
+
this.bindEvents();
|
|
43
|
+
this.destroyRef.onDestroy(() => {
|
|
44
|
+
for (const cleanup of this.listenerCleanup) {
|
|
45
|
+
cleanup();
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
ngOnChanges(changes) {
|
|
50
|
+
for (const key of Object.keys(changes)) {
|
|
51
|
+
switch (key) {
|
|
52
|
+
case 'label':
|
|
53
|
+
this.setHostProperty('label', changes['label'].currentValue);
|
|
54
|
+
break;
|
|
55
|
+
case 'variant':
|
|
56
|
+
this.setHostProperty('variant', changes['variant'].currentValue);
|
|
57
|
+
break;
|
|
58
|
+
case 'selects':
|
|
59
|
+
this.setHostProperty('selects', changes['selects'].currentValue);
|
|
60
|
+
break;
|
|
61
|
+
case 'emphasized':
|
|
62
|
+
this.setHostProperty('emphasized', changes['emphasized'].currentValue);
|
|
63
|
+
break;
|
|
64
|
+
case 'pending':
|
|
65
|
+
this.setHostProperty('pending', changes['pending'].currentValue);
|
|
66
|
+
break;
|
|
67
|
+
case 'options':
|
|
68
|
+
this.setHostProperty('options', changes['options'].currentValue);
|
|
69
|
+
break;
|
|
70
|
+
case 'noWrap':
|
|
71
|
+
this.setHostProperty('noWrap', changes['noWrap'].currentValue);
|
|
72
|
+
break;
|
|
73
|
+
case 'value':
|
|
74
|
+
this.setHostProperty('value', changes['value'].currentValue);
|
|
75
|
+
break;
|
|
76
|
+
case 'optionIconRenderer':
|
|
77
|
+
this.setHostProperty('optionIconRenderer', changes['optionIconRenderer'].currentValue);
|
|
78
|
+
break;
|
|
79
|
+
default:
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Forward a wrapper @Input to the underlying host element via Renderer2 so
|
|
86
|
+
* the wrapper stays compatible with non-DOM Angular platforms (SSR, tests).
|
|
87
|
+
* Unlike a "skip undefined" guard, this lets consumers reset values back to
|
|
88
|
+
* undefined / null by clearing their bindings.
|
|
89
|
+
*/
|
|
90
|
+
setHostProperty(key, value) {
|
|
91
|
+
this.renderer.setProperty(this.host, key, value);
|
|
92
|
+
}
|
|
93
|
+
bindEvents() {
|
|
94
|
+
this.listenerCleanup.push(this.renderer.listen(this.host, 'luzmo-scrolled', (event) => {
|
|
95
|
+
this.luzmoScrolledEvent.emit(event);
|
|
96
|
+
}));
|
|
97
|
+
this.listenerCleanup.push(this.renderer.listen(this.host, 'change', (event) => {
|
|
98
|
+
this.changeEvent.emit(event);
|
|
99
|
+
if (!this.isWritingValue) {
|
|
100
|
+
const eventWithDetail = event;
|
|
101
|
+
const eventTarget = event.target;
|
|
102
|
+
const detail = 'detail' in eventWithDetail ? eventWithDetail.detail : undefined;
|
|
103
|
+
const hostRecord = this.host;
|
|
104
|
+
const nextValue = (detail
|
|
105
|
+
?? eventTarget?.['value']
|
|
106
|
+
?? hostRecord['value']);
|
|
107
|
+
if (Object.is(this.lastCvaValue, nextValue)) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
this.lastCvaValue = nextValue;
|
|
111
|
+
this.setHostProperty('value', nextValue);
|
|
112
|
+
this.onChange(nextValue);
|
|
113
|
+
}
|
|
114
|
+
}));
|
|
115
|
+
this.listenerCleanup.push(this.renderer.listen(this.host, 'luzmo-exceeded-top', (event) => {
|
|
116
|
+
this.luzmoExceededTopEvent.emit(event);
|
|
117
|
+
}));
|
|
118
|
+
this.listenerCleanup.push(this.renderer.listen(this.host, 'luzmo-exceeded-bottom', (event) => {
|
|
119
|
+
this.luzmoExceededBottomEvent.emit(event);
|
|
120
|
+
}));
|
|
121
|
+
this.listenerCleanup.push(this.renderer.listen(this.host, 'blur', () => {
|
|
122
|
+
this.onTouched();
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
onChange = () => { };
|
|
126
|
+
onTouched = () => { };
|
|
127
|
+
isWritingValue = false;
|
|
128
|
+
lastCvaValue;
|
|
129
|
+
writeValue(value) {
|
|
130
|
+
this.isWritingValue = true;
|
|
131
|
+
this.lastCvaValue = value;
|
|
132
|
+
this.setHostProperty('value', value);
|
|
133
|
+
this.isWritingValue = false;
|
|
134
|
+
}
|
|
135
|
+
registerOnChange(fn) {
|
|
136
|
+
this.onChange = fn;
|
|
137
|
+
}
|
|
138
|
+
registerOnTouched(fn) {
|
|
139
|
+
this.onTouched = fn;
|
|
140
|
+
}
|
|
141
|
+
setDisabledState(isDisabled) {
|
|
142
|
+
// Underlying element does not declare a 'disabled' field; nothing to do.
|
|
143
|
+
void isDisabled;
|
|
144
|
+
}
|
|
145
|
+
focus({ preventScroll }) {
|
|
146
|
+
return this.host.focus({ preventScroll });
|
|
147
|
+
}
|
|
148
|
+
scrollToTop() {
|
|
149
|
+
return this.host.scrollToTop();
|
|
150
|
+
}
|
|
151
|
+
static ɵfac = function LuzmoOptions_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || LuzmoOptions)(); };
|
|
152
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: LuzmoOptions, selectors: [["luzmo-options"]], inputs: { label: "label", variant: "variant", selects: "selects", emphasized: "emphasized", pending: "pending", options: "options", noWrap: [0, "no-wrap", "noWrap"], value: "value", optionIconRenderer: [0, "option-icon-renderer", "optionIconRenderer"] }, outputs: { luzmoScrolledEvent: "luzmo-scrolled", changeEvent: "change", luzmoExceededTopEvent: "luzmo-exceeded-top", luzmoExceededBottomEvent: "luzmo-exceeded-bottom" }, exportAs: ["luzmoOptions"], features: [i0.ɵɵProvidersFeature([
|
|
153
|
+
{
|
|
154
|
+
provide: NG_VALUE_ACCESSOR,
|
|
155
|
+
useExisting: forwardRef(() => LuzmoOptions),
|
|
156
|
+
multi: true
|
|
157
|
+
}
|
|
158
|
+
]), i0.ɵɵNgOnChangesFeature], ngContentSelectors: _c0, decls: 1, vars: 0, template: function LuzmoOptions_Template(rf, ctx) { if (rf & 1) {
|
|
159
|
+
i0.ɵɵprojectionDef();
|
|
160
|
+
i0.ɵɵprojection(0);
|
|
161
|
+
} }, encapsulation: 2, changeDetection: 0 });
|
|
162
|
+
}
|
|
163
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LuzmoOptions, [{
|
|
164
|
+
type: Component,
|
|
165
|
+
args: [{
|
|
166
|
+
selector: 'luzmo-options',
|
|
167
|
+
exportAs: 'luzmoOptions',
|
|
168
|
+
standalone: true,
|
|
169
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
170
|
+
template: '<ng-content />',
|
|
171
|
+
providers: [
|
|
172
|
+
{
|
|
173
|
+
provide: NG_VALUE_ACCESSOR,
|
|
174
|
+
useExisting: forwardRef(() => LuzmoOptions),
|
|
175
|
+
multi: true
|
|
176
|
+
}
|
|
177
|
+
]
|
|
178
|
+
}]
|
|
179
|
+
}], () => [], { label: [{
|
|
180
|
+
type: Input,
|
|
181
|
+
args: [{ alias: 'label' }]
|
|
182
|
+
}], variant: [{
|
|
183
|
+
type: Input,
|
|
184
|
+
args: [{ alias: 'variant' }]
|
|
185
|
+
}], selects: [{
|
|
186
|
+
type: Input,
|
|
187
|
+
args: [{ alias: 'selects' }]
|
|
188
|
+
}], emphasized: [{
|
|
189
|
+
type: Input,
|
|
190
|
+
args: [{ alias: 'emphasized' }]
|
|
191
|
+
}], pending: [{
|
|
192
|
+
type: Input,
|
|
193
|
+
args: [{ alias: 'pending' }]
|
|
194
|
+
}], options: [{
|
|
195
|
+
type: Input,
|
|
196
|
+
args: [{ alias: 'options' }]
|
|
197
|
+
}], noWrap: [{
|
|
198
|
+
type: Input,
|
|
199
|
+
args: [{ alias: 'no-wrap' }]
|
|
200
|
+
}], value: [{
|
|
201
|
+
type: Input,
|
|
202
|
+
args: [{ alias: 'value' }]
|
|
203
|
+
}], optionIconRenderer: [{
|
|
204
|
+
type: Input,
|
|
205
|
+
args: [{ alias: 'option-icon-renderer' }]
|
|
206
|
+
}], luzmoScrolledEvent: [{ type: i0.Output, args: ["luzmo-scrolled"] }], changeEvent: [{ type: i0.Output, args: ["change"] }], luzmoExceededTopEvent: [{ type: i0.Output, args: ["luzmo-exceeded-top"] }], luzmoExceededBottomEvent: [{ type: i0.Output, args: ["luzmo-exceeded-bottom"] }] }); })();
|
|
207
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(LuzmoOptions, { className: "LuzmoOptions", filePath: "components/options.ts", lineNumber: 25 }); })();
|