lightning-base-components 1.18.3-alpha → 1.18.5-alpha

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 (52) hide show
  1. package/metadata/raptor.json +21 -0
  2. package/package.json +3 -2
  3. package/src/lightning/baseCombobox/baseCombobox.js +20 -14
  4. package/src/lightning/buttonIcon/buttonIcon.js +19 -16
  5. package/src/lightning/combobox/combobox.js +17 -16
  6. package/src/lightning/primitiveInputCheckbox/form-element.slds.css +281 -0
  7. package/src/lightning/primitiveInputCheckbox/input-checkbox.slds.css +395 -0
  8. package/src/lightning/primitiveInputCheckbox/primitiveInputCheckbox.css +3 -0
  9. package/src/lightning/primitiveInputCheckbox/primitiveInputCheckbox.html +48 -0
  10. package/src/lightning/primitiveInputCheckbox/primitiveInputCheckbox.js +139 -0
  11. package/src/lightning/primitiveInputCheckboxButton/form-element.slds.css +281 -0
  12. package/src/lightning/primitiveInputCheckboxButton/input-checkbox-button.slds.css +126 -0
  13. package/src/lightning/primitiveInputCheckboxButton/primitiveInputCheckboxButton.css +6 -0
  14. package/src/lightning/primitiveInputCheckboxButton/primitiveInputCheckboxButton.html +24 -0
  15. package/src/lightning/primitiveInputCheckboxButton/primitiveInputCheckboxButton.js +176 -0
  16. package/src/lightning/primitiveInputColor/form-element.slds.css +281 -0
  17. package/src/lightning/primitiveInputColor/input-color.slds.css +35 -0
  18. package/src/lightning/primitiveInputColor/input-text.slds.css +398 -0
  19. package/src/lightning/primitiveInputColor/primitiveInputColor.css +4 -0
  20. package/src/lightning/primitiveInputColor/primitiveInputColor.html +50 -0
  21. package/src/lightning/primitiveInputColor/primitiveInputColor.js +184 -0
  22. package/src/lightning/primitiveInputFile/button.slds.css +527 -0
  23. package/src/lightning/primitiveInputFile/form-element.slds.css +281 -0
  24. package/src/lightning/primitiveInputFile/input-file.slds.css +62 -0
  25. package/src/lightning/primitiveInputFile/primitiveInputFile.css +5 -0
  26. package/src/lightning/primitiveInputFile/primitiveInputFile.html +45 -0
  27. package/src/lightning/primitiveInputFile/primitiveInputFile.js +111 -0
  28. package/src/lightning/primitiveInputRadio/primitiveInputRadio.html +24 -0
  29. package/src/lightning/primitiveInputRadio/primitiveInputRadio.js +103 -0
  30. package/src/lightning/primitiveInputSimple/form-element.slds.css +281 -0
  31. package/src/lightning/primitiveInputSimple/input-text.slds.css +398 -0
  32. package/src/lightning/primitiveInputSimple/normalize.js +6 -0
  33. package/src/lightning/primitiveInputSimple/primitiveInputSimple.css +9 -0
  34. package/src/lightning/primitiveInputSimple/primitiveInputSimple.html +65 -0
  35. package/src/lightning/primitiveInputSimple/primitiveInputSimple.js +585 -0
  36. package/src/lightning/primitiveInputSimple/selection.js +131 -0
  37. package/src/lightning/primitiveInputToggle/form-element.slds.css +281 -0
  38. package/src/lightning/primitiveInputToggle/input-toggle.slds.css +170 -0
  39. package/src/lightning/primitiveInputToggle/primitiveInputToggle.css +3 -0
  40. package/src/lightning/primitiveInputToggle/primitiveInputToggle.html +34 -0
  41. package/src/lightning/primitiveInputToggle/primitiveInputToggle.js +164 -0
  42. package/src/lightning/tab/tab.css +2 -0
  43. package/src/lightning/tab/tab.js +22 -14
  44. package/src/lightning/tab/tab.slds.css +47 -0
  45. package/src/lightning/tabset/tabset.css +10 -0
  46. package/src/lightning/tabset/tabset.js +28 -10
  47. package/src/lightning/button/__wdio__/utam/utam.html +0 -3
  48. package/src/lightning/button/__wdio__/utam/utam.js +0 -3
  49. package/src/lightning/button/__wdio__/utam/utam.spec.js +0 -20
  50. package/src/lightning/datatable/__wdio__/utam/utam.html +0 -32
  51. package/src/lightning/datatable/__wdio__/utam/utam.js +0 -91
  52. package/src/lightning/datatable/__wdio__/utam/utam.spec.js +0 -214
@@ -0,0 +1,398 @@
1
+ /* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved
2
+ Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */
3
+
4
+ /* The Input Control Container holds the `start` and `end` slot contents, as well as the input control itself */
5
+
6
+ :host([data-render-mode="shadow"]) [part~='input-container'] {
7
+ display: flex;
8
+ align-items: center;
9
+ position: relative;
10
+ min-height: var(--sds-c-inputtext-sizing-height);
11
+ padding-inline-end: var(--sds-c-inputtext-spacing-inline-end, var(--sds-c-inputtext-spacing-inline));
12
+ padding-inline-start: var(--sds-c-inputtext-spacing-inline-start, var(--sds-c-inputtext-spacing-inline));
13
+ background-color: var(--sds-c-inputtext-color-background, var(--sds-g-color-neutral-base-1));
14
+ border-width: var(--sds-c-inputtext-sizing-border, var(--sds-g-sizing-border-1, 1px));
15
+ border-style: solid;
16
+ border-color: var(--sds-c-inputtext-color-border, var(--sds-g-color-neutral-base-contrast-3));
17
+ border-radius: var(--sds-c-inputtext-radius-border);
18
+ box-shadow: var(--sds-c-inputtext-shadow);
19
+ }
20
+
21
+ /* The Input element (in markup) */
22
+
23
+ :host([data-render-mode="shadow"]) [part~='input'] {
24
+ width: 100%;
25
+ height: 100%;
26
+ padding: 0;
27
+ font-size: var(--sds-c-inputtext-font-size);
28
+ color: var(--sds-c-inputtext-text-color);
29
+ line-height: 1;
30
+ border: none;
31
+ background: transparent;
32
+ }
33
+
34
+ /* Placeholder Text */
35
+
36
+ :host([data-render-mode="shadow"]) [part~='input']::placeholder {
37
+ color: var(--sds-c-inputtext-text-color-placeholder);
38
+ font-style: var(--sds-c-inputtext-font-style-placeholder);
39
+ }
40
+
41
+ /* Focus State */
42
+
43
+ :host([data-render-mode="shadow"]) [part~='input-container']:focus-within {
44
+ --sds-c-inputtext-color-border: var(
45
+ --sds-c-inputtext-color-border-focus,
46
+ var(--sds-g-color-palette-blue-50, #0176d3)
47
+ );
48
+ --sds-c-inputtext-shadow: var(--sds-c-inputtext-shadow-focus, 0 0 3px var(--sds-g-color-palette-blue-50, #0176d3));
49
+ --sds-c-inputtext-color-background: var(--sds-c-inputtext-color-background-focus);
50
+ --sds-c-inputtext-text-color: var(--sds-c-inputtext-text-color-focus);
51
+ }
52
+
53
+ :host([data-render-mode="shadow"]) [part~='input']:focus {
54
+ outline: none;
55
+ }
56
+
57
+ /* Invalid state */
58
+
59
+ :host([data-render-mode="shadow"][aria-invalid='true']) [part~='input-container'] {
60
+ --sds-c-inputtext-color-border: var(--sds-c-inputtext-color-border-invalid);
61
+ --sds-c-inputtext-color-background: var(--sds-c-inputtext-color-background-invalid);
62
+ }
63
+
64
+ :host([data-render-mode="shadow"][aria-invalid='true']) [part~='input'] {
65
+ --sds-c-inputtext-text-color: var(--sds-c-inputtext-text-color-invalid);
66
+ }
67
+
68
+ /* Valid State */
69
+
70
+ :host([data-render-mode="shadow"][aria-invalid='false']) [part~='input-container'] {
71
+ --sds-c-inputtext-color-border: var(--sds-c-inputtext-color-border-valid);
72
+ --sds-c-inputtext-color-background: var(--sds-c-inputtext-color-background-valid);
73
+ }
74
+
75
+ :host([data-render-mode="shadow"][aria-invalid='false']) [part~='input'] {
76
+ --sds-c-inputtext-text-color: var(--sds-c-inputtext-text-color-valid);
77
+ }
78
+
79
+ /* Readonly State */
80
+
81
+ :host([data-render-mode="shadow"][readonly]) [part~='input-container'] {
82
+ --sds-c-inputtext-sizing-border: var(--sds-c-inputtext-sizing-border-readonly);
83
+ --sds-c-inputtext-spacing-inline-start: var(
84
+ --sds-c-inputtext-spacing-inline-start-readonly,
85
+ var(--sds-c-inputtext-spacing-inline-readonly)
86
+ );
87
+ --sds-c-inputtext-spacing-inline-end: var(
88
+ --sds-c-inputtext-spacing-inline-end-readonly,
89
+ var(--sds-c-inputtext-spacing-inline-readonly)
90
+ );
91
+ }
92
+
93
+ /* Disabled State */
94
+
95
+ :host([data-render-mode="shadow"][disabled]) [part~='input-container'] {
96
+ --sds-c-inputtext-text-color: #3e3e3c; /* TODO: Replace with Global Styling Hook Fallback */
97
+ --sds-c-inputtext-color-background: #ecebea; /* TODO: Replace with Global Styling Hook Fallback */
98
+ --sds-c-inputtext-color-border: #c9c7c5; /* TODO: Replace with Global Styling Hook Fallback */
99
+ }
100
+
101
+ @supports (--styling-hooks: '') {
102
+ /**
103
+ * Input Text
104
+ */
105
+ :host([data-render-mode="shadow"]) [part~='input-text'] {
106
+ /* Host reassignments to composed slds-icon */
107
+ --slds-c-icon-color-foreground: var(
108
+ --slds-c-inputtext-icon-color-foreground,
109
+ var(--sds-g-color-neutral-base-50, #747474)
110
+ );
111
+ --slds-c-icon-sizing: var(--slds-c-inputtext-icon-sizing, 14px);
112
+ --sds-c-inputtext-sizing-height: var(
113
+ --slds-c-inputtext-sizing-height,
114
+ var(--sds-g-sizing-9, 2rem)
115
+ );
116
+ --sds-c-inputtext-color-background: var(
117
+ --slds-c-inputtext-color-background,
118
+ var(--sds-g-color-neutral-base-100, #ffffff)
119
+ );
120
+ --sds-c-inputtext-color-background-focus: var(
121
+ --slds-c-inputtext-color-background-focus,
122
+ var(--sds-g-color-neutral-base-100, #ffffff)
123
+ );
124
+ --sds-c-inputtext-text-color: var(--slds-c-inputtext-text-color);
125
+ --sds-c-inputtext-font-size: var(
126
+ --slds-c-inputtext-font-size,
127
+ var(--sds-g-font-scale-neg-2, 0.8125rem)
128
+ );
129
+ --sds-c-inputtext-text-color-placeholder: var(
130
+ --slds-c-inputtext-text-color-placeholder,
131
+ var(--sds-g-color-neutral-base-50, #747474)
132
+ );
133
+ --sds-c-inputtext-color-border: var(
134
+ --slds-c-inputtext-color-border,
135
+ var(--sds-g-color-neutral-base-80, #c9c9c9)
136
+ );
137
+ --sds-c-inputtext-sizing-border: var(--slds-c-inputtext-sizing-border);
138
+ --sds-c-inputtext-radius-border: var(
139
+ --slds-c-inputtext-radius-border,
140
+ var(--sds-g-radius-border-2, 0.25rem)
141
+ );
142
+
143
+ display: flex;
144
+ flex-wrap: wrap;
145
+ align-items: center;
146
+ }
147
+
148
+ /**
149
+ * Input Container
150
+ */
151
+ :host([data-render-mode="shadow"]) [part~='input-container'] {
152
+ flex: 1 0 100%;
153
+ align-items: stretch;
154
+ }
155
+
156
+ :host([data-render-mode="shadow"]) [part~='input-container'][type~='range'] {
157
+ border: none;
158
+ display: inline-block;
159
+ }
160
+
161
+ :host([data-render-mode="shadow"]) [part~='input'][type~='range'] {
162
+ min-height: calc(1.875rem + (1px * 2));
163
+ margin: 0;
164
+ }
165
+
166
+ :host([data-render-mode="shadow"]) [part~='input-container'][type~='range']:focus-within,:host([data-render-mode="shadow"])
167
+ [part~='input-container'][type~='range']:active {
168
+ --sds-c-inputtext-color-border: var(--sds-g-color-brand-base-60, #1b96ff);
169
+ --sds-c-inputtext-shadow: 0 0 3px var(--sds-g-color-brand-base-50, #0176d3);
170
+ --sds-c-inputtext-color-background: var(--sds-g-color-neutral-base-100, #ffffff);
171
+
172
+ outline: 0;
173
+ border-width: var(--sds-c-inputtext-sizing-border, var(--sds-g-sizing-border-1, 1px));
174
+ border-color: var(--sds-c-inputtext-color-border, var(--sds-g-color-neutral-base-contrast-3));
175
+ }
176
+
177
+ /**
178
+ * Input
179
+ */
180
+ :host([data-render-mode="shadow"]) [part~='input'] {
181
+ padding-inline-start: var(
182
+ --slds-c-inputtext-spacing-inline-start,
183
+ var(--sds-g-spacing-3, 0.75rem));
184
+ padding-inline-end: var(
185
+ --slds-c-inputtext-spacing-inline-end,
186
+ var(--sds-g-spacing-4, 1rem));
187
+ height: unset;
188
+ font-family: var(--sds-g-font-family, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol');
189
+ }
190
+
191
+ /**
192
+ * Focus / active State
193
+ */
194
+ :host([data-render-mode="shadow"]) [part~="input-container"]:focus-within,:host([data-render-mode="shadow"])
195
+ [part~="input-container"]:active {
196
+ --sds-c-inputtext-color-border: var(--sds-g-color-brand-base-60, #1b96ff);
197
+ --sds-c-inputtext-shadow: 0 0 3px var(--sds-g-color-brand-base-50, #0176d3);
198
+ --sds-c-inputtext-color-background: var(--sds-g-color-neutral-base-100, #ffffff);
199
+
200
+ outline: 0;
201
+ }
202
+
203
+ /**
204
+ * Read Only State
205
+ */
206
+ :host([data-render-mode="shadow"][readonly]) [part~='input-text'] {
207
+ --sds-c-inputtext-spacing-inline-start-readonly: 0;
208
+ --sds-c-inputtext-color-border-focus: transparent;
209
+ --slds-c-inputtext-color-border: transparent;
210
+ --slds-c-inputtext-color-background: transparent;
211
+ --slds-c-inputtext-color-background-focus: transparent;
212
+ }
213
+
214
+ /**
215
+ * Invalid State
216
+ *
217
+ * Does not use --sds-c-inputtext-color-border-invalid due to this hook being
218
+ * tied to :host([aria-invalid]) which this subsystem does not use. Instead, it
219
+ * uses :host([invalid]).
220
+ */
221
+ :host([data-render-mode="shadow"][invalid]) [part~='input-text'] {
222
+ --sds-c-inputtext-shadow: 0 0 0 var(--sds-g-sizing-border-1, 1px) inset
223
+ var(--sds-g-color-error-base-50, #ea001e);
224
+ --slds-c-inputtext-color-border: var(--sds-g-color-error-base-50, #ea001e);
225
+ --slds-c-icon-color-foreground: var(--sds-g-color-error-base-50, #ea001e);
226
+ }
227
+
228
+ /**
229
+ * Invalid State - Focus
230
+ *
231
+ * The following styling hooks are included in SDS and need to be reassigned
232
+ * here to prevent a bug with the focus state border and box-shadow
233
+ */
234
+ :host([data-render-mode="shadow"][invalid]) [part~='input-container']:focus-within {
235
+ --sds-c-inputtext-shadow:
236
+ var(--sds-g-color-error-base-50, #ea001e) 0 0 0 var(--sds-g-sizing-border-1, 1px) inset,
237
+ 0 0 var(--sds-g-sizing-border-3, 3px) var(--sds-g-color-brand-base-50, #0176d3);
238
+ --sds-c-inputtext-color-border: var(--sds-g-color-error-base-50, #ea001e);
239
+ }
240
+
241
+ /**
242
+ * Disabled State
243
+ *
244
+ * Both parts form the visible form control.
245
+ */
246
+ :host([data-render-mode="shadow"][disabled]) [part~='input-container'],:host([data-render-mode="shadow"][disabled]) [part~='input'] {
247
+ cursor: not-allowed;
248
+ --sds-c-inputtext-color-background: var(--sds-g-color-neutral-base-95, #f3f3f3);
249
+ --sds-c-inputtext-color-border: var(--sds-g-color-neutral-base-80, #c9c9c9);
250
+ --sds-c-inputtext-text-color: var(--sds-g-color-neutral-base-50, #747474);
251
+ }
252
+
253
+ /**
254
+ * Label
255
+ *
256
+ * Add [part~='input-text'] to increase specificity and
257
+ * avoid collisions with other components using [part~='label'] (e.g. slds-input-checkbox)
258
+ */
259
+ :host([data-render-mode="shadow"]) [part~='input-text'] [part~='label'] {
260
+ padding-block-start: var(--sds-g-spacing-1, 0.25rem);
261
+ padding-inline-end: var(--sds-g-spacing-2, 0.5rem);
262
+ color: var(
263
+ --slds-c-inputtext-label-color,
264
+ var(--sds-g-color-neutral-base-30, #444444)
265
+ );
266
+ font-size: var(
267
+ --slds-c-inputtext-label-font-size,
268
+ var(--sds-g-font-scale-neg-3, 0.75rem)
269
+ );
270
+ margin-block-end: var(--sds-g-sizing-1, 0.125rem);
271
+
272
+ /* We inline flex to control the spacing between elements and not have to rely on whitespace characters */
273
+ display: inline-flex;
274
+ }
275
+
276
+ /**
277
+ * Start
278
+ *
279
+ * Only expects an SLDS icon. We assign the SLDS Icon Styling Hook here
280
+ * so we don't add spacing to other icons composed in the component, e.g.,
281
+ * the icon in the inline help text.
282
+ */
283
+ :host([data-render-mode="shadow"]) [part~='start'] {
284
+ --slds-c-icon-spacing-inline-end: var(--sds-g-spacing-2, 0.5rem);
285
+ }
286
+
287
+ /**
288
+ * Label Inline Variant
289
+ *
290
+ * Note: all the 33% values you see are remnants of legacy SLDS. We need to
291
+ * keep this implementation intact so visual output is the same when used
292
+ * in a form that has non-shadow components. Attempting to refactor to a
293
+ * modern solution like flex is proving tricky due to the presence of the
294
+ * optional inline-help and the input needing to have exactly 33% of spacing
295
+ * from the inline-start.
296
+ *
297
+ * Ref: https://github.com/salesforce-ux/design-system-internal/blob/240-winter-23/ui/components/form-element/horizontal/_index.scss#L63
298
+ */
299
+ @media (min-width: 48em) {
300
+ :host([data-render-mode="shadow"][variant~='label-inline']) [part~='input-text'] {
301
+ display: block;
302
+ }
303
+
304
+ :host([data-render-mode="shadow"][variant~='label-inline']) [part~='label'] {
305
+ float: left;
306
+
307
+ /* TODO: Get rid of these magic numbers */
308
+ max-width: calc(33% - 1.125rem);
309
+ padding-block-start: var(--sds-g-spacing-1, 0.25rem);
310
+ }
311
+
312
+ :host([data-render-mode="shadow"][variant~='label-inline']) [part~='input-container'] {
313
+ margin-inline-start: 33%;
314
+ }
315
+
316
+ :host([data-render-mode="shadow"][variant~='label-inline']) [part~='inline-help'] {
317
+ float: left;
318
+ padding-block-start: var(--sds-g-spacing-1, 0.25rem);
319
+ }
320
+ }
321
+
322
+ :host([data-render-mode="shadow"]) input[type="search"] + lightning-primitive-icon::part(icon) {
323
+ left: var(--sds-g-spacing-3, 0.75rem);
324
+ fill: var(--slds-g-color-neutral-base-50, #747474);
325
+ }
326
+
327
+ :host([data-render-mode="shadow"]) .slds-input-has-icon .slds-button_icon {
328
+ background-color: transparent;
329
+ }
330
+
331
+ :host([data-render-mode="shadow"]) .slds-input-has-icon .slds-button_icon:focus,:host([data-render-mode="shadow"])
332
+ .slds-input-has-icon .slds-button_icon:hover {
333
+ --slds-c-icon-color-foreground: var(--sds-g-color-brand-base-30, #014486);
334
+ }
335
+
336
+ :host([data-render-mode="shadow"]) .slds-input-has-icon .slds-input__icon {
337
+ width: 0.875rem;
338
+ height: 0.875rem;
339
+ position: absolute;
340
+ top: 50%;
341
+ margin-top: -0.4375rem;
342
+ line-height: 1;
343
+ border: 0;
344
+ z-index: 2;
345
+ }
346
+
347
+ /**
348
+ * Has Icon Left
349
+ */
350
+ :host([data-render-mode="shadow"]) .slds-input-has-icon_left {
351
+ --slds-c-inputtext-spacing-inline-start: var(--sds-g-spacing-6, 2rem);
352
+ }
353
+
354
+ :host([data-render-mode="shadow"]) .slds-input-has-icon_left .slds-input__icon,:host([data-render-mode="shadow"])
355
+ .slds-input-has-icon_left-right .slds-input__icon_left {
356
+ inset-inline-start: var(--sds-g-spacing-3, 0.75rem);
357
+ }
358
+
359
+ /**
360
+ * Has Icon Right
361
+ */
362
+ :host([data-render-mode="shadow"]) .slds-input-has-icon_right {
363
+ --slds-c-inputtext-spacing-inline-end: var(--sds-g-spacing-6, 2rem);
364
+ }
365
+
366
+ :host([data-render-mode="shadow"]) .slds-input-has-icon_right .slds-input__icon,:host([data-render-mode="shadow"])
367
+ .slds-input-has-icon_left-right .slds-input__icon_right {
368
+ inset-inline-end: var(--sds-g-spacing-3, 0.75rem);
369
+ }
370
+
371
+ /**
372
+ * Has Icon Left & Right
373
+ */
374
+ :host([data-render-mode="shadow"]) .slds-input-has-icon_left-right {
375
+ --slds-c-inputtext-spacing-inline-start: var(--sds-g-spacing-6, 2rem);
376
+ --slds-c-inputtext-spacing-inline-end: var(--sds-g-spacing-6, 2rem);
377
+ }
378
+
379
+ /**
380
+ * A temporarily baked-in utility class until SLDS gets a proper utility package.
381
+ *
382
+ * This is a hybrid patch between synthetic and native shadow. The ideal final
383
+ * outcome is the removal of this class and replacing the class with the SLDS
384
+ * utility package solution.
385
+ */
386
+ :host([data-render-mode="shadow"]) .slds-assistive-text {
387
+ position: absolute !important;
388
+ margin: -1px !important;
389
+ border: 0 !important;
390
+ padding: 0 !important;
391
+ width: 1px !important;
392
+ height: 1px !important;
393
+ overflow: hidden !important;
394
+ clip: rect(0 0 0 0) !important;
395
+ text-transform: none !important;
396
+ white-space: nowrap !important;
397
+ }
398
+ }
@@ -0,0 +1,4 @@
1
+ @import 'lightning/sldsCommon';
2
+ @import './form-element.slds.css';
3
+ @import './input-text.slds.css';
4
+ @import './input-color.slds.css';
@@ -0,0 +1,50 @@
1
+ <template>
2
+ <div class="slds-color-picker" part="color-picker">
3
+ <div class="slds-form-element slds-color-picker__summary">
4
+ <template if:false={hasExternalLabel}>
5
+ <label class={computedColorLabelClass} for="color">
6
+ <template if:true={required}>
7
+ <abbr class="slds-required" title={required}>*</abbr>
8
+ </template>
9
+ {label}
10
+ </label>
11
+ <lightning-helptext if:true={fieldLevelHelp} content={fieldLevelHelp} alternative-text={helptextAlternativeText}></lightning-helptext>
12
+ </template>
13
+ <div class="slds-form-element__control" part="input-text">
14
+ <lightning-primitive-colorpicker-button
15
+ value={value}
16
+ disabled={disabled}
17
+ onblur={handleBlur}
18
+ onfocus={handleFocus}
19
+ onchange={handleColorChange}>
20
+ </lightning-primitive-colorpicker-button>
21
+ <!--
22
+ Using <lightning-input type="text"> here would duplicate the label
23
+ and change the input id/class, but we want to use the input-text and
24
+ input-container parts since most of the CSS still applies here
25
+ -->
26
+ <div class="slds-color-picker__summary-input" part="input-container">
27
+ <input type="text" id="color" class="slds-input slds-m-right_x-small"
28
+ part="input"
29
+ name={name}
30
+ autocomplete={autocomplete}
31
+ accesskey={accessKey}
32
+ aria-label={ariaLabel}
33
+ aria-invalid={ariaInvalid}
34
+ disabled={disabled}
35
+ minlength="4"
36
+ maxlength="7"
37
+ placeholder={placeholder}
38
+ pattern={pattern}
39
+ onblur={handleBlur}
40
+ onfocus={handleFocus}
41
+ onchange={handleChange}
42
+ oninput={handleInput}>
43
+ </div>
44
+ </div>
45
+ </div>
46
+ </div>
47
+ <template if:true={helpMessage}>
48
+ <div id="help-message" class="slds-form-element__help" data-help-message role="alert" part="help-text">{helpMessage}</div>
49
+ </template>
50
+ </template>
@@ -0,0 +1,184 @@
1
+ import { api } from 'lwc';
2
+ import LightningShadowBaseClass from 'lightning/shadowBaseClassPrivate';
3
+ import { classSet } from 'lightning/utils';
4
+ import { VARIANT } from 'lightning/inputUtils';
5
+ import { reflectAttribute, isNativeComponent } from 'lightning/utilsPrivate';
6
+ export default class LightningPrimitiveInputColor extends LightningShadowBaseClass {
7
+ @api hasExternalLabel;
8
+ @api required;
9
+ @api accessKey;
10
+ @api label;
11
+ @api fieldLevelHelp;
12
+ @api helptextAlternativeText;
13
+ @api helpMessage;
14
+ @api disabled;
15
+ @api name;
16
+ @api autocomplete;
17
+ @api ariaLabel;
18
+ @api ariaInvalid;
19
+ @api placeholder;
20
+ @api pattern;
21
+ @api variant;
22
+
23
+ _value = '';
24
+
25
+ rendered = false;
26
+ initialValueSet = false;
27
+
28
+ @api
29
+ focus() {
30
+ if (this.rendered) {
31
+ this.inputElement.focus();
32
+ }
33
+ }
34
+
35
+ @api
36
+ get value() {
37
+ return this._value;
38
+ }
39
+
40
+ set value(value) {
41
+ this._value = this.normalizeInput(value);
42
+ if (this.rendered && this.inputElement.value !== this._value) {
43
+ this.setInputValue(this._value);
44
+ }
45
+ }
46
+
47
+ @api
48
+ get inputElement() {
49
+ if (!this.cachedInputElement) {
50
+ let inputElement = this.template.querySelector('input');
51
+ this.cachedInputElement = inputElement;
52
+ }
53
+ return this.cachedInputElement;
54
+ }
55
+
56
+ @api
57
+ get describedByElements() {
58
+ return this.template.querySelector('[data-help-message]');
59
+ }
60
+
61
+ @api
62
+ get isNativeShadow() {
63
+ return this._isNativeShadow;
64
+ }
65
+
66
+ /********* COMPONENT CALLBACKS *********/
67
+
68
+ connectedCallback() {
69
+ super.connectedCallback();
70
+ this._isNativeShadow = isNativeComponent(this);
71
+ }
72
+
73
+ disconnectedCallback() {
74
+ this.rendered = false;
75
+ this.initialValueSet = false;
76
+ this.cachedInputElement = undefined;
77
+ }
78
+
79
+ renderedCallback() {
80
+ this.rendered = true;
81
+ if (!this.initialValueSet) {
82
+ this.inputElement.value = this._value;
83
+ this.initialValueSet = true;
84
+ }
85
+ reflectAttribute(this, 'disabled', this.disabled);
86
+ reflectAttribute(this, 'invalid', !!this.helpMessage);
87
+ reflectAttribute(this, 'variant', this.variant);
88
+ }
89
+
90
+ /**
91
+ * This value is used to compute the label's class which depends on the variant of the component
92
+ */
93
+ get computedColorLabelClass() {
94
+ return classSet(
95
+ 'slds-form-element__label slds-color-picker__summary-label'
96
+ ).add({ 'slds-assistive-text': this.isLabelHidden });
97
+ }
98
+
99
+ get isLabelHidden() {
100
+ return this.variant === VARIANT.LABEL_HIDDEN;
101
+ }
102
+
103
+ /********* ACTION HANDLERS *********/
104
+
105
+ handleBlur() {
106
+ this.dispatchEvent(new CustomEvent('blur'));
107
+ }
108
+
109
+ handleFocus() {
110
+ this.dispatchEvent(new CustomEvent('focus'));
111
+ }
112
+
113
+ handleChange(event) {
114
+ event.stopPropagation();
115
+ this.dispatchCommitEvent();
116
+ this.dispatchChangeEvent();
117
+ }
118
+
119
+ /**
120
+ * This event handler is used whenever a new color is selected and sets the inputElement's
121
+ * value to the selectedColor, while focusing on the color picker button.
122
+ * @param {*} event
123
+ */
124
+ handleColorChange(event) {
125
+ const selectedColor = event.detail.color;
126
+ if (selectedColor !== this.inputElement.value) {
127
+ this.setInputValue(selectedColor);
128
+ this._value = selectedColor;
129
+ this.focus();
130
+ this.dispatchChangeEventWithDetail({ value: selectedColor });
131
+ this.dispatchCommitEvent();
132
+ }
133
+
134
+ this.template
135
+ .querySelector('lightning-primitive-colorpicker-button')
136
+ .focus();
137
+ }
138
+
139
+ handleInput(event) {
140
+ event.stopPropagation();
141
+ this.dispatchChangeEvent();
142
+ }
143
+
144
+ /********* EVENT DISPATCHERS *********/
145
+
146
+ dispatchChangeEventWithDetail(detail) {
147
+ this.dispatchEvent(
148
+ new CustomEvent('change', {
149
+ composed: true,
150
+ bubbles: true,
151
+ detail,
152
+ })
153
+ );
154
+ }
155
+
156
+ dispatchChangeEvent() {
157
+ const detail = { value: this.inputElement.value };
158
+ this._value = detail.value;
159
+ this.dispatchChangeEventWithDetail(detail);
160
+ }
161
+
162
+ dispatchCommitEvent() {
163
+ this.dispatchEvent(new CustomEvent('commit'));
164
+ }
165
+
166
+ /********* VALUE UPDATERS *********/
167
+
168
+ setInputValue(value) {
169
+ this.inputElement.value = value;
170
+ }
171
+
172
+ /********* HELPER METHODS *********/
173
+
174
+ /**
175
+ * TODO: lightning/inputUtils methods should be utilized in the second run of the input
176
+ * breakdown initiative.
177
+ */
178
+ normalizeInput(value) {
179
+ if (typeof value === 'number' || typeof value === 'string') {
180
+ return String(value);
181
+ }
182
+ return '';
183
+ }
184
+ }