@aquera/nile-elements 0.0.6-10 → 0.0.6-12

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 (130) hide show
  1. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.d.ts +2 -0
  2. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.js +2 -0
  3. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/index.js.map +1 -1
  4. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button-toggle/index.d.ts +1 -0
  5. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button-toggle/index.js +2 -0
  6. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button-toggle/index.js.map +1 -0
  7. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/{nile-radio-button/nile-radio-button.css.d.ts → nile-button-toggle/nile-button-toggle.css.d.ts} +1 -1
  8. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button-toggle/nile-button-toggle.css.js +56 -0
  9. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button-toggle/nile-button-toggle.css.js.map +1 -0
  10. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button-toggle/nile-button-toggle.d.ts +41 -0
  11. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button-toggle/nile-button-toggle.js +104 -0
  12. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button-toggle/nile-button-toggle.js.map +1 -0
  13. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button-toggle-group/index.d.ts +1 -0
  14. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button-toggle-group/index.js +2 -0
  15. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button-toggle-group/index.js.map +1 -0
  16. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button-toggle-group/nile-button-toggle-group.css.d.ts +12 -0
  17. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button-toggle-group/nile-button-toggle-group.css.js +17 -0
  18. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button-toggle-group/nile-button-toggle-group.css.js.map +1 -0
  19. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button-toggle-group/nile-button-toggle-group.d.ts +41 -0
  20. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button-toggle-group/nile-button-toggle-group.js +99 -0
  21. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-button-toggle-group/nile-button-toggle-group.js.map +1 -0
  22. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/tsconfig.tsbuildinfo +1 -1
  23. package/demo/index.html +1 -1
  24. package/dist/index.cjs.js +1 -1
  25. package/dist/index.esm.js +1 -1
  26. package/dist/index.iife.js +251 -194
  27. package/dist/nile-button-toggle/index.cjs.js +2 -0
  28. package/dist/nile-button-toggle/index.esm.js +1 -0
  29. package/dist/nile-button-toggle/nile-button-toggle.cjs.js +2 -0
  30. package/dist/nile-button-toggle/nile-button-toggle.cjs.js.map +1 -0
  31. package/dist/nile-button-toggle/nile-button-toggle.css.cjs.js +2 -0
  32. package/dist/nile-button-toggle/nile-button-toggle.css.cjs.js.map +1 -0
  33. package/dist/nile-button-toggle/nile-button-toggle.css.esm.js +44 -0
  34. package/dist/nile-button-toggle/nile-button-toggle.esm.js +6 -0
  35. package/dist/nile-button-toggle-group/index.cjs.js +2 -0
  36. package/dist/nile-button-toggle-group/index.esm.js +1 -0
  37. package/dist/nile-button-toggle-group/nile-button-toggle-group.cjs.js +2 -0
  38. package/dist/nile-button-toggle-group/nile-button-toggle-group.cjs.js.map +1 -0
  39. package/dist/nile-button-toggle-group/nile-button-toggle-group.css.cjs.js +2 -0
  40. package/dist/nile-button-toggle-group/nile-button-toggle-group.css.cjs.js.map +1 -0
  41. package/dist/nile-button-toggle-group/nile-button-toggle-group.css.esm.js +5 -0
  42. package/dist/nile-button-toggle-group/nile-button-toggle-group.esm.js +1 -0
  43. package/dist/src/index.d.ts +2 -0
  44. package/dist/src/index.js +2 -0
  45. package/dist/src/index.js.map +1 -1
  46. package/dist/src/nile-button-toggle/index.d.ts +1 -0
  47. package/dist/src/nile-button-toggle/index.js +2 -0
  48. package/dist/src/nile-button-toggle/index.js.map +1 -0
  49. package/dist/src/{nile-radio-button/nile-radio-button.css.d.ts → nile-button-toggle/nile-button-toggle.css.d.ts} +1 -1
  50. package/dist/src/nile-button-toggle/nile-button-toggle.css.js +56 -0
  51. package/dist/src/nile-button-toggle/nile-button-toggle.css.js.map +1 -0
  52. package/dist/src/nile-button-toggle/nile-button-toggle.d.ts +41 -0
  53. package/dist/src/nile-button-toggle/nile-button-toggle.js +104 -0
  54. package/dist/src/nile-button-toggle/nile-button-toggle.js.map +1 -0
  55. package/dist/src/nile-button-toggle-group/index.d.ts +1 -0
  56. package/dist/src/nile-button-toggle-group/index.js +2 -0
  57. package/dist/src/nile-button-toggle-group/index.js.map +1 -0
  58. package/dist/src/nile-button-toggle-group/nile-button-toggle-group.css.d.ts +12 -0
  59. package/dist/src/nile-button-toggle-group/nile-button-toggle-group.css.js +17 -0
  60. package/dist/src/nile-button-toggle-group/nile-button-toggle-group.css.js.map +1 -0
  61. package/dist/src/nile-button-toggle-group/nile-button-toggle-group.d.ts +41 -0
  62. package/dist/src/nile-button-toggle-group/nile-button-toggle-group.js +99 -0
  63. package/dist/src/nile-button-toggle-group/nile-button-toggle-group.js.map +1 -0
  64. package/dist/tsconfig.tsbuildinfo +1 -1
  65. package/package.json +1 -1
  66. package/src/index.ts +3 -1
  67. package/src/nile-button-toggle/index.ts +1 -0
  68. package/src/nile-button-toggle/nile-button-toggle.css.ts +58 -0
  69. package/src/nile-button-toggle/nile-button-toggle.ts +106 -0
  70. package/src/nile-button-toggle-group/index.ts +1 -0
  71. package/src/nile-button-toggle-group/nile-button-toggle-group.css.ts +19 -0
  72. package/src/nile-button-toggle-group/nile-button-toggle-group.ts +115 -0
  73. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio-button/index.d.ts +0 -1
  74. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio-button/index.js +0 -2
  75. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio-button/index.js.map +0 -1
  76. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio-button/nile-radio-button.css.js +0 -173
  77. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio-button/nile-radio-button.css.js.map +0 -1
  78. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio-button/nile-radio-button.d.ts +0 -57
  79. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio-button/nile-radio-button.js +0 -145
  80. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio-button/nile-radio-button.js.map +0 -1
  81. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio-button-group/index.d.ts +0 -1
  82. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio-button-group/index.js +0 -2
  83. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio-button-group/index.js.map +0 -1
  84. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio-button-group/nile-radio-button-group.css.d.ts +0 -12
  85. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio-button-group/nile-radio-button-group.css.js +0 -70
  86. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio-button-group/nile-radio-button-group.css.js.map +0 -1
  87. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio-button-group/nile-radio-button-group.d.ts +0 -66
  88. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio-button-group/nile-radio-button-group.js +0 -308
  89. package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-radio-button-group/nile-radio-button-group.js.map +0 -1
  90. package/dist/nile-radio-button/index.cjs.js +0 -2
  91. package/dist/nile-radio-button/index.esm.js +0 -1
  92. package/dist/nile-radio-button/nile-radio-button.cjs.js +0 -2
  93. package/dist/nile-radio-button/nile-radio-button.cjs.js.map +0 -1
  94. package/dist/nile-radio-button/nile-radio-button.css.cjs.js +0 -2
  95. package/dist/nile-radio-button/nile-radio-button.css.cjs.js.map +0 -1
  96. package/dist/nile-radio-button/nile-radio-button.css.esm.js +0 -161
  97. package/dist/nile-radio-button/nile-radio-button.esm.js +0 -21
  98. package/dist/nile-radio-button-group/index.cjs.js +0 -2
  99. package/dist/nile-radio-button-group/index.esm.js +0 -1
  100. package/dist/nile-radio-button-group/nile-radio-button-group.cjs.js +0 -2
  101. package/dist/nile-radio-button-group/nile-radio-button-group.cjs.js.map +0 -1
  102. package/dist/nile-radio-button-group/nile-radio-button-group.css.cjs.js +0 -2
  103. package/dist/nile-radio-button-group/nile-radio-button-group.css.cjs.js.map +0 -1
  104. package/dist/nile-radio-button-group/nile-radio-button-group.css.esm.js +0 -58
  105. package/dist/nile-radio-button-group/nile-radio-button-group.esm.js +0 -56
  106. package/dist/src/nile-radio-button/index.d.ts +0 -1
  107. package/dist/src/nile-radio-button/index.js +0 -2
  108. package/dist/src/nile-radio-button/index.js.map +0 -1
  109. package/dist/src/nile-radio-button/nile-radio-button.css.js +0 -173
  110. package/dist/src/nile-radio-button/nile-radio-button.css.js.map +0 -1
  111. package/dist/src/nile-radio-button/nile-radio-button.d.ts +0 -57
  112. package/dist/src/nile-radio-button/nile-radio-button.js +0 -145
  113. package/dist/src/nile-radio-button/nile-radio-button.js.map +0 -1
  114. package/dist/src/nile-radio-button-group/index.d.ts +0 -1
  115. package/dist/src/nile-radio-button-group/index.js +0 -2
  116. package/dist/src/nile-radio-button-group/index.js.map +0 -1
  117. package/dist/src/nile-radio-button-group/nile-radio-button-group.css.d.ts +0 -12
  118. package/dist/src/nile-radio-button-group/nile-radio-button-group.css.js +0 -70
  119. package/dist/src/nile-radio-button-group/nile-radio-button-group.css.js.map +0 -1
  120. package/dist/src/nile-radio-button-group/nile-radio-button-group.d.ts +0 -66
  121. package/dist/src/nile-radio-button-group/nile-radio-button-group.js +0 -308
  122. package/dist/src/nile-radio-button-group/nile-radio-button-group.js.map +0 -1
  123. package/src/nile-radio-button/index.ts +0 -1
  124. package/src/nile-radio-button/nile-radio-button.css.ts +0 -175
  125. package/src/nile-radio-button/nile-radio-button.ts +0 -151
  126. package/src/nile-radio-button-group/index.ts +0 -1
  127. package/src/nile-radio-button-group/nile-radio-button-group.css.ts +0 -72
  128. package/src/nile-radio-button-group/nile-radio-button-group.ts +0 -337
  129. /package/dist/{nile-radio-button → nile-button-toggle}/index.cjs.js.map +0 -0
  130. /package/dist/{nile-radio-button-group → nile-button-toggle-group}/index.cjs.js.map +0 -0
@@ -1,308 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { classMap } from 'lit/directives/class-map.js';
3
- import { customElement, property, query, state } from 'lit/decorators.js';
4
- import { HasSlotController } from '../internal/slot';
5
- import { html } from 'lit';
6
- import { watch } from '../internal/watch';
7
- import NileElement from '../internal/nile-element';
8
- import styles from './nile-radio-button-group.css';
9
- /**
10
- * @summary Radio groups are used to group multiple [radios](/components/radio) or [radio buttons](/components/radio-button) so they function as a single form control.
11
- *
12
- * @dependency nile-button-group
13
- *
14
- * @slot - The default slot where `<nile-radio>` or `<nile-radio-button>` elements are placed.
15
- * @slot label - The radio group's label. Required for proper accessibility. Alternatively, you can use the `label`
16
- * attribute.
17
- *
18
- * @event change - Emitted when the radio group's selected value changes.
19
- * @event input - Emitted when the radio group receives user input.
20
- * @event invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied.
21
- * @csspart button-group - The button group that wraps radio buttons.
22
- * @csspart button-group__base - The button group's `base` part.
23
- */
24
- let NileRadioButtonGroup = class NileRadioButtonGroup extends NileElement {
25
- constructor() {
26
- super(...arguments);
27
- this.hasSlotController = new HasSlotController(this, 'help-text', 'label');
28
- this.customValidityMessage = '';
29
- this.hasButtonGroup = false;
30
- this.defaultValue = '';
31
- /**
32
- * The radio group's label. Required for proper accessibility. If you need to display HTML, use the `label` slot
33
- * instead.
34
- */
35
- this.label = '';
36
- /** The name of the radio group, submitted as a name/value pair with form data. */
37
- this.name = 'option';
38
- /** The current value of the radio group, submitted as a name/value pair with form data. */
39
- this.value = '';
40
- /**
41
- * By default, form controls are associated with the nearest containing `<form>` element. This attribute allows you
42
- * to place the form control outside of a form and associate it with the form that has this `id`. The form must be in
43
- * the same document or shadow root for this to work.
44
- */
45
- this.form = '';
46
- /** Ensures a child radio is checked before allowing the containing form to submit. */
47
- this.required = false;
48
- /** Used to show radio in inline or not */
49
- this.labelInline = false;
50
- /** Used to disabled or not */
51
- this.disabled = false;
52
- this.helpText = '';
53
- this.errorMessage = '';
54
- }
55
- connectedCallback() {
56
- super.connectedCallback();
57
- this.defaultValue = this.value;
58
- this.handleInitialDisabledState();
59
- }
60
- getAllRadios() {
61
- return [...this.querySelectorAll('nile-radio-button')];
62
- }
63
- handleRadioClick(event) {
64
- const target = event.target.closest('nile-radio-button');
65
- const radios = this.getAllRadios();
66
- const oldValue = this.value;
67
- if (target.disabled) {
68
- return;
69
- }
70
- this.value = target.value;
71
- radios.forEach(radio => (radio.checked = radio === target));
72
- if (this.value !== oldValue) {
73
- this.emit('nile-change', { value: this.value });
74
- this.emit('input');
75
- }
76
- }
77
- handleDisabledChange() {
78
- this.getAllRadios().forEach(radio => {
79
- radio.disabled = this.disabled;
80
- });
81
- }
82
- handleInitialDisabledState() {
83
- this.getAllRadios().forEach(radio => {
84
- radio.disabled = radio.hasAttribute('disabled')
85
- ? radio.disabled
86
- : this.disabled;
87
- });
88
- }
89
- handleKeyDown(event) {
90
- if (!['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', ' '].includes(event.key)) {
91
- return;
92
- }
93
- const radios = this.getAllRadios().filter(radio => !radio.disabled);
94
- const checkedRadio = radios.find(radio => radio.checked) ?? radios[0];
95
- const incr = event.key === ' '
96
- ? 0
97
- : ['ArrowUp', 'ArrowLeft'].includes(event.key)
98
- ? -1
99
- : 1;
100
- const oldValue = this.value;
101
- let index = radios.indexOf(checkedRadio) + incr;
102
- if (index < 0) {
103
- index = radios.length - 1;
104
- }
105
- if (index > radios.length - 1) {
106
- index = 0;
107
- }
108
- this.getAllRadios().forEach(radio => {
109
- radio.checked = false;
110
- if (!this.hasButtonGroup) {
111
- radio.tabIndex = -1;
112
- }
113
- });
114
- this.value = radios[index].value;
115
- radios[index].checked = true;
116
- if (!this.hasButtonGroup) {
117
- radios[index].tabIndex = 0;
118
- radios[index].focus();
119
- }
120
- else {
121
- radios[index].shadowRoot.querySelector('button').focus();
122
- }
123
- if (this.value !== oldValue) {
124
- this.emit('change');
125
- this.emit('input');
126
- }
127
- event.preventDefault();
128
- }
129
- handleLabelClick() {
130
- const radios = this.getAllRadios();
131
- const checked = radios.find(radio => radio.checked);
132
- const radioToFocus = checked || radios[0];
133
- // Move focus to the checked radio (or the first one if none are checked) when clicking the label
134
- if (radioToFocus) {
135
- radioToFocus.focus();
136
- }
137
- }
138
- handleSlotChange() {
139
- const radios = this.getAllRadios();
140
- radios.forEach(radio => (radio.checked = radio.value === this.value));
141
- this.hasButtonGroup = radios.some(radio => radio.tagName.toLowerCase() === 'nile-radio-button');
142
- if (!radios.some(radio => radio.checked)) {
143
- if (this.hasButtonGroup) {
144
- const buttonRadio = radios[0].shadowRoot.querySelector('button');
145
- buttonRadio.tabIndex = 0;
146
- }
147
- else {
148
- radios[0].tabIndex = 0;
149
- }
150
- }
151
- if (this.hasButtonGroup) {
152
- const buttonGroup = this.shadowRoot?.querySelector('nile-button-group');
153
- }
154
- const slottedElements = [
155
- ...this.defaultSlot.assignedElements({ flatten: true }),
156
- ];
157
- // console.log(slottedElements);
158
- slottedElements.forEach(el => {
159
- const index = slottedElements.indexOf(el);
160
- const button = this.findButton(el);
161
- if (button !== null) {
162
- button.classList.toggle('nile-radio-button--first', index === 0);
163
- button.classList.toggle('nile-radio-button--inner', index > 0 && index < slottedElements.length - 1);
164
- button.classList.toggle('nile-radio-button--last', index === slottedElements.length - 1);
165
- }
166
- });
167
- }
168
- findButton(el) {
169
- const selector = 'nile-radio-button';
170
- return el.closest(selector) ?? el.querySelector(selector);
171
- }
172
- updateCheckedRadio() {
173
- const radios = this.getAllRadios();
174
- radios.forEach(radio => (radio.checked = radio.value === this.value));
175
- }
176
- handleValueChange() {
177
- if (this.hasUpdated) {
178
- this.updateCheckedRadio();
179
- }
180
- }
181
- render() {
182
- const hasLabelSlot = this.hasSlotController.test('label');
183
- const hasHelpTextSlot = this.hasSlotController.test('help-text');
184
- const hasLabel = this.label ? true : !!hasLabelSlot;
185
- const hasHelpText = this.helpText ? true : false;
186
- const hasErrorMessage = this.errorMessage ? true : false;
187
- const defaultSlot = html `
188
- <slot
189
- @click=${this.handleRadioClick}
190
- @keydown=${this.handleKeyDown}
191
- @slotchange=${this.handleSlotChange}
192
- role="presentation"
193
- ></slot>
194
- `;
195
- return html `
196
- <fieldset
197
- part="form-control"
198
- class=${classMap({
199
- 'form-control': true,
200
- 'form-control--medium': true,
201
- 'form-control--radio-group': true,
202
- 'form-control--has-label': hasLabel,
203
- 'form-control--has-help-text': hasHelpText,
204
- })}
205
- role="radiogroup"
206
- aria-labelledby="label"
207
- aria-describedby="help-text"
208
- aria-errormessage="error-message"
209
- >
210
- <label
211
- part="form-control-label"
212
- id="label"
213
- class="form-control__label"
214
- aria-hidden=${hasLabel ? 'false' : 'true'}
215
- @click=${this.handleLabelClick}
216
- >
217
- <slot name="label">${this.label}</slot>
218
- </label>
219
-
220
- <div part="form-control-input" class="form-control-input">
221
- <div class="visually-hidden">
222
- <label class="radio-group__validation">
223
- <input
224
- type="text"
225
- class="radio-group__validation-input"
226
- ?required=${this.required}
227
- tabindex="-1"
228
- hidden
229
- />
230
- </label>
231
- </div>
232
-
233
- ${this.hasButtonGroup
234
- ? html ` ${defaultSlot} `
235
- : html `
236
- <div
237
- class="${this.labelInline
238
- ? `form-control--inline-radio`
239
- : ``}"
240
- >
241
- ${defaultSlot}
242
- </div>
243
- `}
244
- </div>
245
-
246
- ${hasHelpText
247
- ? html ` <nile-form-help-text>${this.helpText}</nile-form-help-text> `
248
- : ``}
249
- ${hasErrorMessage
250
- ? html `
251
- <nile-form-error-message
252
- >${this.errorMessage}</nile-form-error-message
253
- >
254
- `
255
- : ``}
256
- </fieldset>
257
- `;
258
- }
259
- };
260
- NileRadioButtonGroup.styles = styles;
261
- __decorate([
262
- query('slot:not([name])')
263
- ], NileRadioButtonGroup.prototype, "defaultSlot", void 0);
264
- __decorate([
265
- state()
266
- ], NileRadioButtonGroup.prototype, "hasButtonGroup", void 0);
267
- __decorate([
268
- state()
269
- ], NileRadioButtonGroup.prototype, "defaultValue", void 0);
270
- __decorate([
271
- property()
272
- ], NileRadioButtonGroup.prototype, "label", void 0);
273
- __decorate([
274
- property()
275
- ], NileRadioButtonGroup.prototype, "name", void 0);
276
- __decorate([
277
- property({ reflect: true })
278
- ], NileRadioButtonGroup.prototype, "value", void 0);
279
- __decorate([
280
- property({ reflect: true })
281
- ], NileRadioButtonGroup.prototype, "form", void 0);
282
- __decorate([
283
- property({ type: Boolean, reflect: true })
284
- ], NileRadioButtonGroup.prototype, "required", void 0);
285
- __decorate([
286
- property({ type: Boolean, reflect: true })
287
- ], NileRadioButtonGroup.prototype, "labelInline", void 0);
288
- __decorate([
289
- property({ type: Boolean, reflect: true })
290
- ], NileRadioButtonGroup.prototype, "disabled", void 0);
291
- __decorate([
292
- property({ attribute: 'help-text' })
293
- ], NileRadioButtonGroup.prototype, "helpText", void 0);
294
- __decorate([
295
- property({ attribute: 'error-message' })
296
- ], NileRadioButtonGroup.prototype, "errorMessage", void 0);
297
- __decorate([
298
- watch('disabled', { waitUntilFirstUpdate: true })
299
- ], NileRadioButtonGroup.prototype, "handleDisabledChange", null);
300
- __decorate([
301
- watch('value')
302
- ], NileRadioButtonGroup.prototype, "handleValueChange", null);
303
- NileRadioButtonGroup = __decorate([
304
- customElement('nile-radio-button-group')
305
- ], NileRadioButtonGroup);
306
- export { NileRadioButtonGroup };
307
- export default NileRadioButtonGroup;
308
- //# sourceMappingURL=nile-radio-button-group.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nile-radio-button-group.js","sourceRoot":"","sources":["../../../src/nile-radio-button-group/nile-radio-button-group.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,MAAM,MAAM,+BAA+B,CAAC;AAInD;;;;;;;;;;;;;;GAcG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,WAAW;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'lit/directives/class-map.js';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { HasSlotController } from '../internal/slot';\nimport { html } from 'lit';\nimport { watch } from '../internal/watch';\nimport NileElement from '../internal/nile-element';\nimport styles from './nile-radio-button-group.css';\nimport type { CSSResultGroup } from 'lit';\nimport type NileRadioButton from '../nile-radio-button/nile-radio-button';\n\n/**\n * @summary Radio groups are used to group multiple [radios](/components/radio) or [radio buttons](/components/radio-button) so they function as a single form control.\n *\n * @dependency nile-button-group\n *\n * @slot - The default slot where `<nile-radio>` or `<nile-radio-button>` elements are placed.\n * @slot label - The radio group's label. Required for proper accessibility. Alternatively, you can use the `label`\n * attribute.\n *\n * @event change - Emitted when the radio group's selected value changes.\n * @event input - Emitted when the radio group receives user input.\n * @event invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied.\n * @csspart button-group - The button group that wraps radio buttons.\n * @csspart button-group__base - The button group's `base` part.\n */\n@customElement('nile-radio-button-group')\nexport class NileRadioButtonGroup extends NileElement {\n static styles: CSSResultGroup = styles;\n\n private readonly hasSlotController = new HasSlotController(\n this,\n 'help-text',\n 'label'\n );\n private customValidityMessage = '';\n\n @query('slot:not([name])') defaultSlot: HTMLSlotElement;\n\n @state() private hasButtonGroup = false;\n\n @state() defaultValue = '';\n\n /**\n * The radio group's label. Required for proper accessibility. If you need to display HTML, use the `label` slot\n * instead.\n */\n @property() label = '';\n\n /** The name of the radio group, submitted as a name/value pair with form data. */\n @property() name = 'option';\n\n /** The current value of the radio group, submitted as a name/value pair with form data. */\n @property({ reflect: true }) value = '';\n\n /**\n * By default, form controls are associated with the nearest containing `<form>` element. This attribute allows you\n * to place the form control outside of a form and associate it with the form that has this `id`. The form must be in\n * the same document or shadow root for this to work.\n */\n @property({ reflect: true }) form = '';\n\n /** Ensures a child radio is checked before allowing the containing form to submit. */\n @property({ type: Boolean, reflect: true }) required = false;\n\n /** Used to show radio in inline or not */\n @property({ type: Boolean, reflect: true }) labelInline = false;\n\n /** Used to disabled or not */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n @property({ attribute: 'help-text' }) helpText = '';\n\n @property({ attribute: 'error-message' }) errorMessage = '';\n\n connectedCallback() {\n super.connectedCallback();\n this.defaultValue = this.value;\n this.handleInitialDisabledState();\n }\n\n private getAllRadios() {\n return [...this.querySelectorAll<NileRadioButton>('nile-radio-button')];\n }\n\n private handleRadioClick(event: MouseEvent) {\n const target = (event.target as HTMLElement).closest<NileRadioButton>(\n 'nile-radio-button'\n )!;\n const radios = this.getAllRadios();\n const oldValue = this.value;\n\n if (target.disabled) {\n return;\n }\n\n this.value = target.value;\n radios.forEach(radio => (radio.checked = radio === target));\n\n if (this.value !== oldValue) {\n this.emit('nile-change', { value: this.value });\n this.emit('input');\n }\n }\n\n @watch('disabled', { waitUntilFirstUpdate: true })\n handleDisabledChange() {\n this.getAllRadios().forEach(radio => {\n radio.disabled = this.disabled;\n });\n }\n\n private handleInitialDisabledState() {\n this.getAllRadios().forEach(radio => {\n radio.disabled = radio.hasAttribute('disabled')\n ? radio.disabled\n : this.disabled;\n });\n }\n\n private handleKeyDown(event: KeyboardEvent) {\n if (\n !['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', ' '].includes(\n event.key\n )\n ) {\n return;\n }\n\n const radios = this.getAllRadios().filter(radio => !radio.disabled);\n const checkedRadio = radios.find(radio => radio.checked) ?? radios[0];\n const incr =\n event.key === ' '\n ? 0\n : ['ArrowUp', 'ArrowLeft'].includes(event.key)\n ? -1\n : 1;\n const oldValue = this.value;\n let index = radios.indexOf(checkedRadio) + incr;\n\n if (index < 0) {\n index = radios.length - 1;\n }\n\n if (index > radios.length - 1) {\n index = 0;\n }\n\n this.getAllRadios().forEach(radio => {\n radio.checked = false;\n\n if (!this.hasButtonGroup) {\n radio.tabIndex = -1;\n }\n });\n\n this.value = radios[index].value;\n radios[index].checked = true;\n\n if (!this.hasButtonGroup) {\n radios[index].tabIndex = 0;\n radios[index].focus();\n } else {\n radios[index].shadowRoot!.querySelector('button')!.focus();\n }\n\n if (this.value !== oldValue) {\n this.emit('change');\n this.emit('input');\n }\n\n event.preventDefault();\n }\n\n private handleLabelClick() {\n const radios = this.getAllRadios();\n const checked = radios.find(radio => radio.checked);\n const radioToFocus = checked || radios[0];\n\n // Move focus to the checked radio (or the first one if none are checked) when clicking the label\n if (radioToFocus) {\n radioToFocus.focus();\n }\n }\n\n private handleSlotChange() {\n const radios = this.getAllRadios();\n\n radios.forEach(radio => (radio.checked = radio.value === this.value));\n\n this.hasButtonGroup = radios.some(\n radio => radio.tagName.toLowerCase() === 'nile-radio-button'\n );\n\n if (!radios.some(radio => radio.checked)) {\n if (this.hasButtonGroup) {\n const buttonRadio = radios[0].shadowRoot!.querySelector('button')!;\n buttonRadio.tabIndex = 0;\n } else {\n radios[0].tabIndex = 0;\n }\n }\n\n if (this.hasButtonGroup) {\n const buttonGroup = this.shadowRoot?.querySelector('nile-button-group');\n }\n\n const slottedElements = [\n ...this.defaultSlot.assignedElements({ flatten: true }),\n ] as HTMLElement[];\n\n // console.log(slottedElements);\n\n slottedElements.forEach(el => {\n const index = slottedElements.indexOf(el);\n const button = this.findButton(el);\n\n if (button !== null) {\n button.classList.toggle('nile-radio-button--first', index === 0);\n button.classList.toggle(\n 'nile-radio-button--inner',\n index > 0 && index < slottedElements.length - 1\n );\n button.classList.toggle(\n 'nile-radio-button--last',\n index === slottedElements.length - 1\n );\n }\n });\n }\n\n private findButton(el: HTMLElement) {\n const selector = 'nile-radio-button';\n\n return el.closest(selector) ?? el.querySelector(selector);\n }\n\n private updateCheckedRadio() {\n const radios = this.getAllRadios();\n radios.forEach(radio => (radio.checked = radio.value === this.value));\n }\n\n @watch('value')\n handleValueChange() {\n if (this.hasUpdated) {\n this.updateCheckedRadio();\n }\n }\n\n render() {\n const hasLabelSlot = this.hasSlotController.test('label');\n const hasHelpTextSlot = this.hasSlotController.test('help-text');\n const hasLabel = this.label ? true : !!hasLabelSlot;\n const hasHelpText = this.helpText ? true : false;\n const hasErrorMessage = this.errorMessage ? true : false;\n\n const defaultSlot = html`\n <slot\n @click=${this.handleRadioClick}\n @keydown=${this.handleKeyDown}\n @slotchange=${this.handleSlotChange}\n role=\"presentation\"\n ></slot>\n `;\n\n return html`\n <fieldset\n part=\"form-control\"\n class=${classMap({\n 'form-control': true,\n 'form-control--medium': true,\n 'form-control--radio-group': true,\n 'form-control--has-label': hasLabel,\n 'form-control--has-help-text': hasHelpText,\n })}\n role=\"radiogroup\"\n aria-labelledby=\"label\"\n aria-describedby=\"help-text\"\n aria-errormessage=\"error-message\"\n >\n <label\n part=\"form-control-label\"\n id=\"label\"\n class=\"form-control__label\"\n aria-hidden=${hasLabel ? 'false' : 'true'}\n @click=${this.handleLabelClick}\n >\n <slot name=\"label\">${this.label}</slot>\n </label>\n\n <div part=\"form-control-input\" class=\"form-control-input\">\n <div class=\"visually-hidden\">\n <label class=\"radio-group__validation\">\n <input\n type=\"text\"\n class=\"radio-group__validation-input\"\n ?required=${this.required}\n tabindex=\"-1\"\n hidden\n />\n </label>\n </div>\n\n ${this.hasButtonGroup\n ? html` ${defaultSlot} `\n : html`\n <div\n class=\"${this.labelInline\n ? `form-control--inline-radio`\n : ``}\"\n >\n ${defaultSlot}\n </div>\n `}\n </div>\n\n ${hasHelpText\n ? html` <nile-form-help-text>${this.helpText}</nile-form-help-text> `\n : ``}\n ${hasErrorMessage\n ? html`\n <nile-form-error-message\n >${this.errorMessage}</nile-form-error-message\n >\n `\n : ``}\n </fieldset>\n `;\n }\n}\n\nexport default NileRadioButtonGroup;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-radio-button-group': NileRadioButtonGroup;\n }\n}\n"]}
@@ -1 +0,0 @@
1
- export { NileRadioButton } from './nile-radio-button';
@@ -1,175 +0,0 @@
1
- /**
2
- * Copyright Aquera Inc 2023
3
- *
4
- * This source code is licensed under the BSD-3-Clause license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- import { css } from 'lit-element';
9
-
10
- /**
11
- * RadioButton CSS
12
- */
13
- export const styles = css`
14
- :host {
15
- }
16
-
17
- .button {
18
- display: inline-flex;
19
- align-items: center;
20
- justify-content: center;
21
- width: 100%;
22
- color: var(--color-text-default, #000);
23
- text-align: center;
24
- border-radius: 4px;
25
- font-family: Colfax-regular;
26
- font-size: 14px;
27
- font-style: normal;
28
- font-weight: 400;
29
- line-height: 14px; /* 100% */
30
- letter-spacing: 0.2px;
31
- text-decoration: none;
32
- user-select: none;
33
- white-space: nowrap;
34
- vertical-align: middle;
35
- padding: 12px;
36
- cursor: pointer;
37
- gap: 10px;
38
- }
39
-
40
- .button::-moz-focus-inner {
41
- border: 0;
42
- }
43
-
44
- .button:focus {
45
- outline: none;
46
- }
47
-
48
- .button:focus-visible {
49
- outline: var(--nile-focus-ring);
50
- outline-offset: var(--nile-focus-ring-offset);
51
- }
52
-
53
- .button--disabled {
54
- opacity: 0.5;
55
- cursor: not-allowed;
56
- }
57
-
58
- /* When disabled, prevent mouse events from bubbling up from children */
59
- .button--disabled * {
60
- pointer-events: none;
61
- }
62
-
63
- .button__prefix,
64
- .button__suffix {
65
- flex: 0 0 auto;
66
- display: flex;
67
- align-items: center;
68
- pointer-events: none;
69
- }
70
-
71
- .button__label {
72
- display: inline-block;
73
- }
74
-
75
- .button__label::slotted(nile-icon) {
76
- vertical-align: -2px;
77
- }
78
-
79
- /* Default */
80
- .button--default {
81
- border: 1px solid #c7ced4;
82
- background: #fff;
83
- color: black;
84
- }
85
-
86
- .button--default:hover:not(.button--disabled) {
87
- border: 1px solid #c7ced4;
88
- background: #e5e9eb;
89
- }
90
-
91
- .button--default:active:not(.button--disabled) {
92
- border: 1px solid #c7ced4;
93
- background: #e5e9eb;
94
- }
95
-
96
- .button--checked {
97
- border: 1px solid #c7ced4;
98
- background: #e5e9eb;
99
- }
100
-
101
- .button--has-label.button--medium .button__label {
102
- padding: 0 var(--nile-spacing-medium);
103
- }
104
-
105
- .button--has-prefix.button--medium {
106
- padding-inline-start: var(--nile-spacing-small);
107
- }
108
-
109
- .button--has-prefix.button--medium .button__label {
110
- padding-inline-start: var(--nile-spacing-small);
111
- }
112
-
113
- .button--has-suffix.button--medium,
114
- .button--caret.button--medium {
115
- padding-inline-end: var(--nile-spacing-small);
116
- }
117
-
118
- .button--has-suffix.button--medium .button__label,
119
- .button--caret.button--medium .button__label {
120
- padding-inline-end: var(--nile-spacing-small);
121
- }
122
-
123
- .nile-radio-button--first {
124
- background-color: red;
125
- }
126
-
127
- :host(.nile-radio-button--first:not(.nile-radio-button--last)) .button {
128
- border-start-end-radius: 0;
129
- border-end-end-radius: 0;
130
- }
131
-
132
- :host(.nile-group-button--inner) .button {
133
- border-radius: 0;
134
- }
135
-
136
- :host(.nile-radio-button--last:not(.nile-radio-button--first)) .button {
137
- border-start-start-radius: 0;
138
- border-end-start-radius: 0;
139
- }
140
-
141
- /* All except the first */
142
- :host(.nile-radio-button__button:not(.nile-radio-button__button--first)) {
143
- margin-inline-start: calc(-1 * var(--nile-input-border-width));
144
- }
145
-
146
- :host(.nile-radio-button--inner) .button {
147
- border-radius: 0;
148
- border-left: 0;
149
- border-right: 0;
150
- }
151
-
152
- .button__prefix,
153
- .button__suffix,
154
- .button__label {
155
- display: inline-flex;
156
- position: relative;
157
- align-items: center;
158
- }
159
-
160
- /* We use a hidden input so constraint validation errors work, since they don't appear to show when used with buttons.
161
- We can't actually hide it, though, otherwise the messages will be suppressed by the browser. */
162
- .hidden-input {
163
- all: unset;
164
- position: absolute;
165
- top: 0;
166
- left: 0;
167
- bottom: 0;
168
- right: 0;
169
- outline: dotted 1px red;
170
- opacity: 0;
171
- z-index: -1;
172
- }
173
- `;
174
-
175
- export default [styles];
@@ -1,151 +0,0 @@
1
- /**
2
- * Copyright Aquera Inc 2023
3
- *
4
- * This source code is licensed under the BSD-3-Clause license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- import {
9
- LitElement,
10
- html,
11
- property,
12
- CSSResultArray,
13
- TemplateResult,
14
- } from 'lit-element';
15
- import { customElement, query, state } from 'lit/decorators.js';
16
- import { styles } from './nile-radio-button.css';
17
- import NileElement from '../internal/nile-element';
18
- import { HasSlotController } from '../slot';
19
- import { classMap } from 'lit/directives/class-map.js';
20
- import { ifDefined } from 'lit/directives/if-defined.js';
21
- import { watch } from '../internal/watch';
22
-
23
- /**
24
- * Nile icon component.
25
- *
26
- * @tag nile-radio-button
27
- *
28
- */
29
- @customElement('nile-radio-button')
30
- export class NileRadioButton extends NileElement {
31
- /**
32
- * The styles for RadioButton
33
- * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
34
- */
35
- public static get styles(): CSSResultArray {
36
- return [styles];
37
- }
38
- private readonly hasSlotController = new HasSlotController(
39
- this,
40
- '[default]',
41
- 'prefix',
42
- 'suffix'
43
- );
44
-
45
- @query('.button') input: HTMLInputElement;
46
- @query('.hidden-input') hiddenInput: HTMLInputElement;
47
-
48
- @state() protected hasFocus = false;
49
-
50
- /**
51
- * @internal The radio button's checked state. This is exposed as an "internal" attribute so we can reflect it, making
52
- * it easier to style in button groups.
53
- */
54
- @property({ type: Boolean, reflect: true }) checked = false;
55
-
56
- /** The radio's value. When selected, the radio group will receive this value. */
57
- @property() value: string;
58
-
59
- /** Disables the radio button. */
60
- @property({ type: Boolean, reflect: true }) disabled = false;
61
-
62
- /**
63
- * The radio button's size. When used inside a radio group, the size will be determined by the radio group's size so
64
- * this attribute can typically be omitted.
65
- */
66
- @property({ reflect: true }) size: 'small' | 'medium' | 'large' = 'medium';
67
-
68
- /** Draws a pill-style radio button with rounded edges. */
69
- @property({ type: Boolean, reflect: true }) pill = false;
70
-
71
- connectedCallback() {
72
- super.connectedCallback();
73
- this.setAttribute('role', 'presentation');
74
- }
75
-
76
- private handleBlur() {
77
- this.hasFocus = false;
78
- this.emit('nile-blur');
79
- }
80
-
81
- private handleClick(e: MouseEvent) {
82
- if (this.disabled) {
83
- e.preventDefault();
84
- e.stopPropagation();
85
- return;
86
- }
87
-
88
- this.checked = true;
89
- }
90
-
91
- private handleFocus() {
92
- this.hasFocus = true;
93
- this.emit('nile-focus');
94
- }
95
-
96
- @watch('disabled', { waitUntilFirstUpdate: true })
97
- handleDisabledChange() {
98
- this.setAttribute('aria-disabled', this.disabled ? 'true' : 'false');
99
- }
100
-
101
- /** Sets focus on the radio button. */
102
- focus(options?: FocusOptions) {
103
- this.input.focus(options);
104
- }
105
-
106
- /** Removes focus from the radio button. */
107
- blur() {
108
- this.input.blur();
109
- }
110
-
111
- render() {
112
- return html`
113
- <div part="base" role="presentation">
114
- <button
115
- part="${`button${this.checked ? ' button--checked' : ''}`}"
116
- role="radio"
117
- aria-checked="${this.checked}"
118
- class=${classMap({
119
- button: true,
120
- 'button--default': true,
121
- 'button--checked': this.checked,
122
- 'button--disabled': this.disabled,
123
- 'button--focused': this.hasFocus,
124
- 'button--has-label': this.hasSlotController.test('[default]'),
125
- 'button--has-prefix': this.hasSlotController.test('prefix'),
126
- 'button--has-suffix': this.hasSlotController.test('suffix'),
127
- })}
128
- aria-disabled=${this.disabled}
129
- type="button"
130
- value=${ifDefined(this.value)}
131
- tabindex="${this.checked ? '0' : '-1'}"
132
- @blur=${this.handleBlur}
133
- @focus=${this.handleFocus}
134
- @click=${this.handleClick}
135
- >
136
- <slot name="prefix" part="prefix" class="button__prefix"></slot>
137
- <slot part="label" class="button__label"></slot>
138
- <slot name="suffix" part="suffix" class="button__suffix"></slot>
139
- </button>
140
- </div>
141
- `;
142
- }
143
- }
144
-
145
- export default NileRadioButton;
146
-
147
- declare global {
148
- interface HTMLElementTagNameMap {
149
- 'nile-radio-button': NileRadioButton;
150
- }
151
- }
@@ -1 +0,0 @@
1
- export { NileRadioButtonGroup } from './nile-radio-button-group';