@aquera/nile-elements 0.0.3-3 → 0.0.3-5
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/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-option/nile-option.css.js +11 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-option/nile-option.css.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-option/nile-option.d.ts +2 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-option/nile-option.js +23 -9
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-option/nile-option.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-select/nile-select.css.js +36 -8
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-select/nile-select.css.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-select/nile-select.d.ts +7 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-select/nile-select.js +74 -34
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-select/nile-select.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +193 -157
- package/dist/nile-option/index.cjs.js +1 -1
- package/dist/nile-option/index.esm.js +1 -1
- package/dist/nile-option/nile-option.cjs.js +1 -1
- package/dist/nile-option/nile-option.cjs.js.map +1 -1
- package/dist/nile-option/nile-option.css.cjs.js +1 -1
- package/dist/nile-option/nile-option.css.cjs.js.map +1 -1
- package/dist/nile-option/nile-option.css.esm.js +11 -1
- package/dist/nile-option/nile-option.esm.js +6 -10
- package/dist/nile-select/index.cjs.js +1 -1
- package/dist/nile-select/index.esm.js +1 -1
- package/dist/nile-select/nile-select.cjs.js +1 -1
- package/dist/nile-select/nile-select.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.css.cjs.js +1 -1
- package/dist/nile-select/nile-select.css.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.css.esm.js +36 -8
- package/dist/nile-select/nile-select.esm.js +34 -31
- package/dist/src/nile-option/nile-option.css.js +11 -1
- package/dist/src/nile-option/nile-option.css.js.map +1 -1
- package/dist/src/nile-option/nile-option.d.ts +2 -0
- package/dist/src/nile-option/nile-option.js +23 -9
- package/dist/src/nile-option/nile-option.js.map +1 -1
- package/dist/src/nile-select/nile-select.css.js +36 -8
- package/dist/src/nile-select/nile-select.css.js.map +1 -1
- package/dist/src/nile-select/nile-select.d.ts +7 -0
- package/dist/src/nile-select/nile-select.js +74 -34
- package/dist/src/nile-select/nile-select.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/nile-option/nile-option.css.ts +11 -1
- package/src/nile-option/nile-option.ts +22 -9
- package/src/nile-select/nile-select.css.ts +36 -8
- package/src/nile-select/nile-select.ts +77 -44
package/package.json
CHANGED
@@ -29,11 +29,15 @@ export const styles = css`
|
|
29
29
|
line-height: 1.8;
|
30
30
|
letter-spacing: normal;
|
31
31
|
color: hsl(240 5.3% 26.1%);
|
32
|
-
padding:
|
32
|
+
padding: 6px 0;
|
33
33
|
transition: 150ms fill;
|
34
34
|
cursor: pointer;
|
35
35
|
}
|
36
36
|
|
37
|
+
.option--single-select {
|
38
|
+
padding: 9px 12px;
|
39
|
+
}
|
40
|
+
|
37
41
|
.option--hover:not(.option--current):not(.option--disabled) {
|
38
42
|
background-color: rgba(0, 94, 166, 0.1);
|
39
43
|
color: hsl(0, 0%, 0%);
|
@@ -86,6 +90,12 @@ export const styles = css`
|
|
86
90
|
margin-inline-start: 0.5rem;
|
87
91
|
}
|
88
92
|
|
93
|
+
.option--checkbox{
|
94
|
+
pointer-events: none;
|
95
|
+
margin-left: 12px;
|
96
|
+
margin-right: 12px;
|
97
|
+
}
|
98
|
+
|
89
99
|
@media (forced-colors: active) {
|
90
100
|
:host(:hover:not([aria-disabled='true'])) .option {
|
91
101
|
outline: dashed 1px SelectedItem;
|
@@ -14,6 +14,7 @@ import { html } from 'lit';
|
|
14
14
|
import { watch } from '../internal/watch';
|
15
15
|
import type { CSSResultGroup } from 'lit';
|
16
16
|
import NileElement from '../internal/nile-element';
|
17
|
+
import '../nile-checkbox';
|
17
18
|
|
18
19
|
/**
|
19
20
|
* Nile icon component.
|
@@ -51,6 +52,7 @@ export class NileOption extends NileElement {
|
|
51
52
|
@state() selected = false; // the option is selected and has aria-selected="true"
|
52
53
|
@state() hasHover = false; // we need this because Safari doesn't honor :hover styles while dragging
|
53
54
|
@state() hidden = false; // the option is hidden
|
55
|
+
@state() isMultipleSelect = false;
|
54
56
|
|
55
57
|
/**
|
56
58
|
* The option's value. When selected, the containing form control will receive this value. The value must be unique
|
@@ -66,6 +68,20 @@ export class NileOption extends NileElement {
|
|
66
68
|
super.connectedCallback();
|
67
69
|
this.setAttribute('role', 'option');
|
68
70
|
this.setAttribute('aria-selected', 'false');
|
71
|
+
|
72
|
+
// Find the closest parent 'nile-select' element
|
73
|
+
const parentSelect = this.closest('nile-select');
|
74
|
+
|
75
|
+
// Check if the parent has the 'multiple' attribute
|
76
|
+
if (parentSelect && parentSelect.hasAttribute('multiple')) {
|
77
|
+
let multipleValue = parentSelect.getAttribute('multiple');
|
78
|
+
if (multipleValue !== 'false') {
|
79
|
+
if(multipleValue === ''){
|
80
|
+
multipleValue = 'true';
|
81
|
+
}
|
82
|
+
this.isMultipleSelect = Boolean(multipleValue);
|
83
|
+
}
|
84
|
+
}
|
69
85
|
}
|
70
86
|
|
71
87
|
private handleDefaultSlotChange() {
|
@@ -135,21 +151,18 @@ export class NileOption extends NileElement {
|
|
135
151
|
part="base"
|
136
152
|
class=${classMap({
|
137
153
|
option: true,
|
138
|
-
'option--
|
154
|
+
'option--single-select': !this.isMultipleSelect,
|
155
|
+
'option--current': this.selected && !this.isMultipleSelect,
|
139
156
|
'option--disabled': this.disabled,
|
140
|
-
'option--selected': this.selected,
|
157
|
+
'option--selected': this.selected && !this.isMultipleSelect,
|
141
158
|
'option--hover': this.hasHover,
|
142
159
|
})}
|
143
160
|
@mouseenter=${this.handleMouseEnter}
|
144
161
|
@mouseleave=${this.handleMouseLeave}
|
145
162
|
>
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
name="tick"
|
150
|
-
color=${this.current ? '#005EA6' : ''}
|
151
|
-
aria-hidden="true"
|
152
|
-
></nile-icon>
|
163
|
+
|
164
|
+
${this.isMultipleSelect ? html`<nile-checkbox class="option--checkbox" .checked=${this.selected}></nile-checkbox>` : ''}
|
165
|
+
|
153
166
|
<slot part="prefix" name="prefix" class="option__prefix"></slot>
|
154
167
|
<slot
|
155
168
|
part="label"
|
@@ -179,11 +179,14 @@ export const styles = css`
|
|
179
179
|
}
|
180
180
|
|
181
181
|
.select__tags-count {
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
182
|
+
color: #005ea6;
|
183
|
+
font-family: Colfax-regular;
|
184
|
+
font-size: 14px;
|
185
|
+
font-style: normal;
|
186
|
+
font-weight: 400;
|
187
|
+
line-height: 14px;
|
188
|
+
letter-spacing: 0.2px;
|
189
|
+
margin: 6px;
|
187
190
|
}
|
188
191
|
|
189
192
|
.select__tags-count-clearable {
|
@@ -205,6 +208,11 @@ export const styles = css`
|
|
205
208
|
border: solid 1px #cccccc;
|
206
209
|
}
|
207
210
|
|
211
|
+
.select--standard .select__combobox:hover {
|
212
|
+
border: 1px solid #000;
|
213
|
+
background: #fff;
|
214
|
+
}
|
215
|
+
|
208
216
|
.select--standard.select--disabled .select__combobox {
|
209
217
|
background-color: #f4f4f4;
|
210
218
|
border-color: #cccccc;
|
@@ -218,7 +226,18 @@ export const styles = css`
|
|
218
226
|
.select--standard:not(.select--disabled).select--focused .select__combobox {
|
219
227
|
background-color: #f4f4f4;
|
220
228
|
border-color: #0059ff;
|
221
|
-
|
229
|
+
}
|
230
|
+
|
231
|
+
.select--warning .select__combobox {
|
232
|
+
border-color: var(--nile-colors-yellow-500);
|
233
|
+
}
|
234
|
+
|
235
|
+
.select--error .select__combobox {
|
236
|
+
border-color: #e5434d;
|
237
|
+
}
|
238
|
+
|
239
|
+
.select--success {
|
240
|
+
border-color: #43e5c0;
|
222
241
|
}
|
223
242
|
|
224
243
|
/* Filled selects */
|
@@ -328,7 +347,6 @@ export const styles = css`
|
|
328
347
|
position: relative;
|
329
348
|
font-size: 1rem;
|
330
349
|
font-weight: 400;
|
331
|
-
box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15);
|
332
350
|
background: #ffffff;
|
333
351
|
border: solid 1px #cccccc;
|
334
352
|
border-radius: 0.25rem;
|
@@ -383,10 +401,20 @@ export const styles = css`
|
|
383
401
|
display: flex;
|
384
402
|
flex-direction: row;
|
385
403
|
align-items: flex-start;
|
386
|
-
padding: 8px
|
404
|
+
padding: 8px 12px 16px;
|
387
405
|
gap: 12px;
|
388
406
|
justify-content: space-between;
|
389
407
|
}
|
408
|
+
|
409
|
+
.tag__prefix[slot='prefix'] {
|
410
|
+
height: 14px;
|
411
|
+
display: inline-block;
|
412
|
+
overflow: hidden;
|
413
|
+
}
|
414
|
+
|
415
|
+
.tag__prefix[slot='prefix'] img {
|
416
|
+
max-height: 100%;
|
417
|
+
}
|
390
418
|
`;
|
391
419
|
|
392
420
|
export default [styles];
|
@@ -36,6 +36,7 @@ import type { CSSResultGroup } from 'lit';
|
|
36
36
|
import type { NileFormControl } from '../internal/nile-element';
|
37
37
|
import type NileOption from '../nile-option/nile-option';
|
38
38
|
import type NilePopup from '../nile-popup/nile-popup';
|
39
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
39
40
|
|
40
41
|
type NileRemoveEvent = CustomEvent<Record<PropertyKey, never>>;
|
41
42
|
|
@@ -139,7 +140,7 @@ export class NileSelect extends NileElement implements NileFormControl {
|
|
139
140
|
@property() size: 'small' | 'medium' | 'large' = 'medium';
|
140
141
|
|
141
142
|
/** Placeholder text to show as a hint when the select is empty. */
|
142
|
-
@property() placeholder = '';
|
143
|
+
@property() placeholder = 'Select...';
|
143
144
|
|
144
145
|
/** Placeholder text to show as a hint when the select is empty. */
|
145
146
|
@state() searchValue = '';
|
@@ -154,6 +155,15 @@ export class NileSelect extends NileElement implements NileFormControl {
|
|
154
155
|
|
155
156
|
@property({ attribute: 'error-message' }) errorMessage = '';
|
156
157
|
|
158
|
+
/** Sets the input to a warning state, changing its visual appearance. */
|
159
|
+
@property({ type: Boolean }) warning = false;
|
160
|
+
|
161
|
+
/** Sets the input to an error state, changing its visual appearance. */
|
162
|
+
@property({ type: Boolean }) error = false;
|
163
|
+
|
164
|
+
/** Sets the input to a success state, changing its visual appearance. */
|
165
|
+
@property({ type: Boolean }) success = false;
|
166
|
+
|
157
167
|
/**
|
158
168
|
* The maximum number of selected options to show when `multiple` is true. After the maximum, "+n" will be shown to
|
159
169
|
* indicate the number of additional items that are selected. Set to 0 to remove the limit.
|
@@ -574,6 +584,25 @@ export class NileSelect extends NileElement implements NileFormControl {
|
|
574
584
|
return [...this.querySelectorAll<NileOption>('nile-option')];
|
575
585
|
}
|
576
586
|
|
587
|
+
private getOptionPrefix(option: NileOption): string {
|
588
|
+
const prefixSlot = option.shadowRoot?.querySelector('slot[name="prefix"]') as HTMLSlotElement;
|
589
|
+
if (!prefixSlot) return '';
|
590
|
+
|
591
|
+
const assignedNodes = prefixSlot.assignedNodes();
|
592
|
+
const htmlStrings: string[] = [];
|
593
|
+
|
594
|
+
assignedNodes.forEach(node => {
|
595
|
+
if (node instanceof HTMLElement) {
|
596
|
+
htmlStrings.push(node.outerHTML);
|
597
|
+
} else if (node.nodeType === Node.TEXT_NODE) {
|
598
|
+
// Text node
|
599
|
+
htmlStrings.push(node.textContent || '');
|
600
|
+
}
|
601
|
+
});
|
602
|
+
|
603
|
+
return htmlStrings.join('');
|
604
|
+
}
|
605
|
+
|
577
606
|
// Gets the first <nile-option> element
|
578
607
|
private getFirstOption() {
|
579
608
|
return this.querySelector<NileOption>('nile-option');
|
@@ -854,6 +883,9 @@ export class NileSelect extends NileElement implements NileFormControl {
|
|
854
883
|
<nile-popup
|
855
884
|
class=${classMap({
|
856
885
|
select: true,
|
886
|
+
'select--warning': this.warning,
|
887
|
+
'select--error': this.error,
|
888
|
+
'select--success': this.success,
|
857
889
|
'select--standard': true,
|
858
890
|
'select--filled': this.filled,
|
859
891
|
'select--pill': this.pill,
|
@@ -883,11 +915,14 @@ export class NileSelect extends NileElement implements NileFormControl {
|
|
883
915
|
@keydown=${this.handleComboboxKeyDown}
|
884
916
|
@mousedown=${this.handleComboboxMouseDown}
|
885
917
|
>
|
886
|
-
<slot
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
918
|
+
<slot
|
919
|
+
part="prefix"
|
920
|
+
name="prefix"
|
921
|
+
class=${classMap({
|
922
|
+
select__prefix: true,
|
923
|
+
multiple: this.multiple,
|
924
|
+
})}
|
925
|
+
></slot>
|
891
926
|
|
892
927
|
<input
|
893
928
|
part="display-input"
|
@@ -924,30 +959,33 @@ export class NileSelect extends NileElement implements NileFormControl {
|
|
924
959
|
<nile-tag
|
925
960
|
part="tag"
|
926
961
|
exportparts="
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
962
|
+
base:tag__base,
|
963
|
+
content:tag__content,
|
964
|
+
remove-button:tag__remove-button,
|
965
|
+
remove-button__base:tag__remove-button__base
|
966
|
+
"
|
932
967
|
?pill=${this.pill}
|
933
968
|
size=${this.size}
|
934
969
|
removable
|
935
970
|
@nile-remove=${(event: NileRemoveEvent) =>
|
936
971
|
this.handleTagRemove(event, option)}
|
937
972
|
>
|
973
|
+
${this.getOptionPrefix(option)
|
974
|
+
? html`<span class="tag__prefix" slot="prefix"
|
975
|
+
>${unsafeHTML(
|
976
|
+
this.getOptionPrefix(option)
|
977
|
+
)}</span
|
978
|
+
>`
|
979
|
+
: ''}
|
938
980
|
${option.getTextLabel()}
|
939
981
|
</nile-tag>
|
940
982
|
`;
|
941
983
|
} else if (index === this.maxOptionsVisible) {
|
942
984
|
return html`
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
size=${this.size}
|
948
|
-
>
|
949
|
-
+${this.selectedOptions.length - index}
|
950
|
-
</nile-tag>
|
985
|
+
|
986
|
+
|
987
|
+
<span class="select__tags-count">+${this.selectedOptions.length - index} More </span>
|
988
|
+
|
951
989
|
`;
|
952
990
|
} else {
|
953
991
|
return null;
|
@@ -1012,7 +1050,7 @@ export class NileSelect extends NileElement implements NileFormControl {
|
|
1012
1050
|
@mouseup=${this.handleOptionClick}
|
1013
1051
|
@slotchange=${this.handleDefaultSlotChange}
|
1014
1052
|
>
|
1015
|
-
|
1053
|
+
${this.searchEnabled
|
1016
1054
|
? html` <div class="select__search">
|
1017
1055
|
<nile-input
|
1018
1056
|
size="small"
|
@@ -1027,13 +1065,16 @@ export class NileSelect extends NileElement implements NileFormControl {
|
|
1027
1065
|
</nile-input>
|
1028
1066
|
</div>`
|
1029
1067
|
: ``}
|
1030
|
-
|
1068
|
+
<div class="select__options">
|
1031
1069
|
${this.showNoResults
|
1032
|
-
|
1033
|
-
|
1070
|
+
? html`
|
1071
|
+
<div class="select__no-results">
|
1072
|
+
${this.noResultsMessage}
|
1073
|
+
</div>
|
1074
|
+
`
|
1075
|
+
: ''}
|
1034
1076
|
<slot></slot>
|
1035
|
-
|
1036
|
-
|
1077
|
+
</div>
|
1037
1078
|
|
1038
1079
|
${this.multiple
|
1039
1080
|
? html` <div
|
@@ -1048,7 +1089,7 @@ export class NileSelect extends NileElement implements NileFormControl {
|
|
1048
1089
|
?disabled="${this.selectedOptions.length === 0}"
|
1049
1090
|
?checked="${this.showSelected}"
|
1050
1091
|
>
|
1051
|
-
|
1092
|
+
Show Selected</nile-checkbox
|
1052
1093
|
>
|
1053
1094
|
</span>
|
1054
1095
|
<span class="select__clear" @click="${this.unSlectAll}"
|
@@ -1060,24 +1101,16 @@ export class NileSelect extends NileElement implements NileFormControl {
|
|
1060
1101
|
</nile-popup>
|
1061
1102
|
</div>
|
1062
1103
|
|
1063
|
-
${
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
? html`
|
1074
|
-
<nile-form-error-message
|
1075
|
-
>${this.errorMessage}</nile-form-error-message
|
1076
|
-
>
|
1077
|
-
`
|
1078
|
-
: ``
|
1079
|
-
}
|
1080
|
-
|
1104
|
+
${hasHelpText
|
1105
|
+
? html` <nile-form-help-text>${this.helpText}</nile-form-help-text> `
|
1106
|
+
: ``}
|
1107
|
+
${hasErrorMessage
|
1108
|
+
? html`
|
1109
|
+
<nile-form-error-message
|
1110
|
+
>${this.errorMessage}</nile-form-error-message
|
1111
|
+
>
|
1112
|
+
`
|
1113
|
+
: ``}
|
1081
1114
|
</div>
|
1082
1115
|
`;
|
1083
1116
|
}
|