lightning-base-components 1.18.3-alpha → 1.18.4-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 (37) hide show
  1. package/package.json +1 -1
  2. package/src/lightning/primitiveInputCheckbox/form-element.slds.css +281 -0
  3. package/src/lightning/primitiveInputCheckbox/input-checkbox.slds.css +395 -0
  4. package/src/lightning/primitiveInputCheckbox/primitiveInputCheckbox.css +3 -0
  5. package/src/lightning/primitiveInputCheckbox/primitiveInputCheckbox.html +48 -0
  6. package/src/lightning/primitiveInputCheckbox/primitiveInputCheckbox.js +139 -0
  7. package/src/lightning/primitiveInputCheckboxButton/form-element.slds.css +281 -0
  8. package/src/lightning/primitiveInputCheckboxButton/input-checkbox-button.slds.css +126 -0
  9. package/src/lightning/primitiveInputCheckboxButton/primitiveInputCheckboxButton.css +6 -0
  10. package/src/lightning/primitiveInputCheckboxButton/primitiveInputCheckboxButton.html +24 -0
  11. package/src/lightning/primitiveInputCheckboxButton/primitiveInputCheckboxButton.js +176 -0
  12. package/src/lightning/primitiveInputColor/form-element.slds.css +281 -0
  13. package/src/lightning/primitiveInputColor/input-color.slds.css +35 -0
  14. package/src/lightning/primitiveInputColor/input-text.slds.css +398 -0
  15. package/src/lightning/primitiveInputColor/primitiveInputColor.css +4 -0
  16. package/src/lightning/primitiveInputColor/primitiveInputColor.html +50 -0
  17. package/src/lightning/primitiveInputColor/primitiveInputColor.js +184 -0
  18. package/src/lightning/primitiveInputFile/button.slds.css +527 -0
  19. package/src/lightning/primitiveInputFile/form-element.slds.css +281 -0
  20. package/src/lightning/primitiveInputFile/input-file.slds.css +62 -0
  21. package/src/lightning/primitiveInputFile/primitiveInputFile.css +5 -0
  22. package/src/lightning/primitiveInputFile/primitiveInputFile.html +45 -0
  23. package/src/lightning/primitiveInputFile/primitiveInputFile.js +111 -0
  24. package/src/lightning/primitiveInputRadio/primitiveInputRadio.html +24 -0
  25. package/src/lightning/primitiveInputRadio/primitiveInputRadio.js +103 -0
  26. package/src/lightning/primitiveInputSimple/form-element.slds.css +281 -0
  27. package/src/lightning/primitiveInputSimple/input-text.slds.css +398 -0
  28. package/src/lightning/primitiveInputSimple/normalize.js +6 -0
  29. package/src/lightning/primitiveInputSimple/primitiveInputSimple.css +9 -0
  30. package/src/lightning/primitiveInputSimple/primitiveInputSimple.html +65 -0
  31. package/src/lightning/primitiveInputSimple/primitiveInputSimple.js +585 -0
  32. package/src/lightning/primitiveInputSimple/selection.js +131 -0
  33. package/src/lightning/primitiveInputToggle/form-element.slds.css +281 -0
  34. package/src/lightning/primitiveInputToggle/input-toggle.slds.css +170 -0
  35. package/src/lightning/primitiveInputToggle/primitiveInputToggle.css +3 -0
  36. package/src/lightning/primitiveInputToggle/primitiveInputToggle.html +34 -0
  37. package/src/lightning/primitiveInputToggle/primitiveInputToggle.js +164 -0
@@ -0,0 +1,164 @@
1
+ import { api } from 'lwc';
2
+ import LightningShadowBaseClass from 'lightning/shadowBaseClassPrivate';
3
+ import {
4
+ isNativeComponent,
5
+ normalizeAriaAttribute,
6
+ reflectAttribute,
7
+ } from 'lightning/utilsPrivate';
8
+ import { VARIANT } from 'lightning/inputUtils';
9
+ import labelRequired from '@salesforce/label/LightningControl.required';
10
+
11
+ const i18n = {
12
+ required: labelRequired,
13
+ };
14
+
15
+ export default class LightningPrimitiveInputToggle extends LightningShadowBaseClass {
16
+ _checked;
17
+ _value = '';
18
+ _ariaLabel;
19
+ _cachedInputElement;
20
+ _helpMessage = '';
21
+ _messageToggleActive;
22
+ _messageToggleInactive;
23
+
24
+ initialRender = false;
25
+
26
+ @api accessKey;
27
+ @api disabled;
28
+ @api label;
29
+ @api variant;
30
+ @api name;
31
+ @api readOnly;
32
+ @api required;
33
+ @api ariaInvalid;
34
+
35
+ /**
36
+ * Text shown for the active state of a toggle. The default is "Active".
37
+ * @type {string}
38
+ */
39
+ @api messageToggleActive;
40
+
41
+ /**
42
+ * Text shown for the inactive state of a toggle. The default is "Inactive".
43
+ * @type {string}
44
+ */
45
+ @api messageToggleInactive;
46
+
47
+ @api
48
+ get value() {
49
+ return this._value;
50
+ }
51
+ set value(newValue) {
52
+ // value can only be a string
53
+ this._value =
54
+ typeof newValue === 'number' || typeof newValue === 'string'
55
+ ? String(newValue)
56
+ : '';
57
+ }
58
+
59
+ @api
60
+ get checked() {
61
+ if (this.initialRender) {
62
+ return this.inputElement.checked;
63
+ }
64
+ return this._checked;
65
+ }
66
+ set checked(value) {
67
+ value = Boolean(value);
68
+ this._checked = value;
69
+ if (this.initialRender) {
70
+ this.inputElement.checked = this._checked;
71
+ }
72
+ }
73
+
74
+ @api
75
+ get ariaDescribedByElements() {
76
+ return [
77
+ this.template.querySelector('[data-help-message]'),
78
+ this.template.querySelector('data-toggle-description'),
79
+ ];
80
+ }
81
+
82
+ @api
83
+ get isNativeShadow() {
84
+ return this._isNativeShadow;
85
+ }
86
+
87
+ @api
88
+ get ariaLabel() {
89
+ return this._ariaLabel;
90
+ }
91
+ set ariaLabel(value) {
92
+ this._ariaLabel = normalizeAriaAttribute(value);
93
+ }
94
+
95
+ @api
96
+ get inputElement() {
97
+ // cache the input in order to reduce dom queries
98
+ if (!this._cachedInputElement) {
99
+ let inputElement = this.template.querySelector('input');
100
+ this._cachedInputElement = inputElement;
101
+ }
102
+ return this._cachedInputElement;
103
+ }
104
+
105
+ @api
106
+ get helpMessage() {
107
+ return this._helpMessage;
108
+ }
109
+ set helpMessage(message) {
110
+ this._helpMessage = message;
111
+ reflectAttribute(this, 'invalid', Boolean(message));
112
+ }
113
+
114
+ get computedLabelClass() {
115
+ return this.variant === VARIANT.LABEL_HIDDEN
116
+ ? 'slds-form-element__label slds-assistive-text'
117
+ : 'slds-form-element__label';
118
+ }
119
+
120
+ get i18n() {
121
+ return i18n;
122
+ }
123
+
124
+ handleBlur() {
125
+ this.dispatchEvent(new CustomEvent('blur'));
126
+ }
127
+
128
+ handleFocus() {
129
+ this.dispatchEvent(new CustomEvent('focus'));
130
+ }
131
+
132
+ handleChange(event) {
133
+ this._checked = event.target.checked;
134
+ const changeEvent = new CustomEvent('change', {
135
+ detail: {
136
+ checked: event.target.checked,
137
+ },
138
+ });
139
+ this.dispatchEvent(changeEvent);
140
+ }
141
+
142
+ handleClick() {
143
+ if (this.template.activeElement === null) {
144
+ this.template.querySelector("[type='checkbox']").focus();
145
+ }
146
+ }
147
+
148
+ connectedCallback() {
149
+ super.connectedCallback();
150
+ this._isNativeShadow = isNativeComponent(this);
151
+ }
152
+
153
+ renderedCallback() {
154
+ if (!this.initialRender) {
155
+ this.inputElement.checked = this.checked;
156
+ this.inputElement.value = this._value;
157
+ this.initialRender = true;
158
+ }
159
+ }
160
+
161
+ disconnectedCallback() {
162
+ this._cachedInputElement = undefined;
163
+ }
164
+ }