@aquera/nile-elements 0.1.21 → 0.1.22

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 (39) hide show
  1. package/README.md +3 -0
  2. package/dist/index.cjs.js +1 -1
  3. package/dist/index.esm.js +1 -1
  4. package/dist/nile-auto-complete/index.cjs.js +1 -1
  5. package/dist/nile-auto-complete/index.esm.js +1 -1
  6. package/dist/nile-auto-complete/nile-auto-complete.cjs.js +1 -1
  7. package/dist/nile-auto-complete/nile-auto-complete.cjs.js.map +1 -1
  8. package/dist/nile-auto-complete/nile-auto-complete.esm.js +6 -6
  9. package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js +1 -1
  10. package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js.map +1 -1
  11. package/dist/nile-auto-complete/nile-auto-complete.test.esm.js +5 -5
  12. package/dist/nile-chip/index.cjs.js +1 -1
  13. package/dist/nile-chip/index.esm.js +1 -1
  14. package/dist/nile-chip/nile-chip.cjs.js +1 -1
  15. package/dist/nile-chip/nile-chip.cjs.js.map +1 -1
  16. package/dist/nile-chip/nile-chip.esm.js +6 -5
  17. package/dist/nile-chip/nile-chip.test.cjs.js +1 -1
  18. package/dist/nile-chip/nile-chip.test.cjs.js.map +1 -1
  19. package/dist/nile-chip/nile-chip.test.esm.js +1 -1
  20. package/dist/nile-radio-group/nile-radio-group.css.cjs.js +1 -1
  21. package/dist/nile-radio-group/nile-radio-group.css.cjs.js.map +1 -1
  22. package/dist/nile-radio-group/nile-radio-group.css.esm.js +1 -1
  23. package/dist/src/nile-auto-complete/nile-auto-complete.d.ts +5 -5
  24. package/dist/src/nile-auto-complete/nile-auto-complete.js +42 -44
  25. package/dist/src/nile-auto-complete/nile-auto-complete.js.map +1 -1
  26. package/dist/src/nile-chip/nile-chip.d.ts +5 -5
  27. package/dist/src/nile-chip/nile-chip.js +76 -77
  28. package/dist/src/nile-chip/nile-chip.js.map +1 -1
  29. package/dist/src/nile-radio-group/nile-radio-group.css.js +1 -1
  30. package/dist/src/nile-radio-group/nile-radio-group.css.js.map +1 -1
  31. package/dist/tsconfig.tsbuildinfo +1 -1
  32. package/dist/watch.cjs.js +1 -1
  33. package/dist/watch.cjs.js.map +1 -1
  34. package/dist/watch.esm.js +1 -1
  35. package/package.json +1 -1
  36. package/src/nile-auto-complete/nile-auto-complete.ts +44 -47
  37. package/src/nile-chip/nile-chip.ts +94 -94
  38. package/src/nile-radio-group/nile-radio-group.css.ts +1 -1
  39. package/vscode-html-custom-data.json +2 -2
@@ -10,7 +10,6 @@ import { customElement, query, state, property } from 'lit/decorators.js';
10
10
  import { styles } from './nile-chip.css';
11
11
  import { classMap } from 'lit/directives/class-map.js';
12
12
  import { HasSlotController } from '../internal/slot';
13
- import { watch } from '../internal/watch';
14
13
  import NileElement from '../internal/nile-element';
15
14
  let NileChip = class NileChip extends NileElement {
16
15
  constructor() {
@@ -49,25 +48,26 @@ let NileChip = class NileChip extends NileElement {
49
48
  this.helpText = '';
50
49
  this.errorMessage = '';
51
50
  this.filterFunction = (item, searchedValue) => item.toLowerCase().includes(searchedValue.toLowerCase());
51
+ this.renderItemFunction = (item) => item;
52
52
  }
53
53
  static get styles() {
54
54
  return [styles];
55
55
  }
56
- onAutoCompleteOptionsChanged() {
57
- this.filteredAutoCompleteOptions = [...this.autoCompleteOptions];
58
- if (this.noDuplicates) {
59
- this.filteredAutoCompleteOptions =
60
- this.filteredAutoCompleteOptions.filter(option => !this.value.includes(option));
56
+ updated(changedProperties) {
57
+ super.updated(changedProperties);
58
+ if (changedProperties.has('autoCompleteOptions')) {
59
+ this.filteredAutoCompleteOptions = [...this.autoCompleteOptions];
60
+ if (this.noDuplicates) {
61
+ this.filteredAutoCompleteOptions =
62
+ this.filteredAutoCompleteOptions.filter(option => !this.value.includes(option));
63
+ }
61
64
  }
62
- }
63
- onValueChanged() {
64
- this.tags = [...this.value];
65
- this.onTagsChanged();
66
- }
67
- onTagsChanged() {
68
- if (this.noDuplicates) {
69
- this.filteredAutoCompleteOptions =
70
- this.filteredAutoCompleteOptions.filter(option => !this.tags.includes(option));
65
+ if (changedProperties.has('value')) {
66
+ this.tags = [...this.value];
67
+ this.onTagsChanged();
68
+ }
69
+ if (changedProperties.has('tags')) {
70
+ this.onTagsChanged();
71
71
  }
72
72
  }
73
73
  connectedCallback() {
@@ -82,60 +82,6 @@ let NileChip = class NileChip extends NileElement {
82
82
  super.disconnectedCallback();
83
83
  this.emit('nile-destroy');
84
84
  }
85
- handleSelect(event) {
86
- // Add the selected value to the tags array only if it doesn't already exist
87
- if (!this.noDuplicates || !this.tags.includes(event.detail.value)) {
88
- this.tags = [...this.tags, event.detail.value];
89
- this.emit('nile-chip-change', { value: this.tags });
90
- this.resetInput();
91
- }
92
- }
93
- handleRemove(value) {
94
- // Remove the tag from the tags array
95
- this.tags = this.tags.filter(tag => tag !== value);
96
- if (this.noDuplicates && this.autoCompleteOptions.includes(value)) {
97
- this.filteredAutoCompleteOptions = [
98
- ...this.filteredAutoCompleteOptions,
99
- value,
100
- ];
101
- }
102
- this.emit('nile-chip-change', { value: this.tags });
103
- }
104
- handleInputChange(event) {
105
- // Update the input value
106
- this.inputValue = event.detail.value;
107
- }
108
- handleInputKeydown(event) {
109
- if (!this.acceptUserInput) {
110
- return;
111
- }
112
- if (event.key === 'Tab') {
113
- event.preventDefault();
114
- }
115
- if ((event.key === 'Enter' || event.key === 'Tab')
116
- && this.inputValue
117
- && (!this.noDuplicates || !this.tags.includes(this.inputValue))) {
118
- event.preventDefault();
119
- this.tags = [...this.tags, this.inputValue];
120
- this.resetInput();
121
- this.emit('nile-chip-change', { value: this.tags });
122
- }
123
- if ((event.key === 'Enter' || event.key === 'Tab')
124
- && this.inputValue
125
- && (this.noDuplicates || this.tags.includes(this.inputValue))) {
126
- this.emit('nile-duplicates-blocked');
127
- }
128
- }
129
- handleFocus() {
130
- this.isDropdownOpen = true;
131
- }
132
- resetInput() {
133
- // Reset the input-related properties
134
- this.inputValue = '';
135
- this.isDropdownOpen = false;
136
- this.autoComplete.value = '';
137
- this.autoComplete.handleFocus();
138
- }
139
85
  render() {
140
86
  // Check if slots are present
141
87
  const hasLabelSlot = this.hasSlotController.test('label');
@@ -190,6 +136,7 @@ let NileChip = class NileChip extends NileElement {
190
136
  <nile-auto-complete
191
137
  .allMenuItems=${this.filteredAutoCompleteOptions}
192
138
  .filterFunction=${this.filterFunction}
139
+ .renderItemFunction=${this.renderItemFunction}
193
140
  .loading="${this.loading}"
194
141
  .value=${this.inputValue}
195
142
  ?isDropdownOpen=${this.isDropdownOpen}
@@ -229,6 +176,64 @@ let NileChip = class NileChip extends NileElement {
229
176
  </div>
230
177
  `;
231
178
  }
179
+ handleSelect(event) {
180
+ // Add the selected value to the tags array only if it doesn't already exist
181
+ if (!this.noDuplicates || !this.tags.includes(event.detail.value)) {
182
+ this.tags = [...this.tags, event.detail.value];
183
+ this.emit('nile-chip-change', { value: this.tags });
184
+ this.resetInput();
185
+ }
186
+ }
187
+ handleRemove(value) {
188
+ // Remove the tag from the tags array
189
+ this.tags = this.tags.filter(tag => tag !== value);
190
+ if (this.noDuplicates && this.autoCompleteOptions.includes(value)) {
191
+ this.filteredAutoCompleteOptions = [
192
+ ...this.filteredAutoCompleteOptions,
193
+ value,
194
+ ];
195
+ }
196
+ this.emit('nile-chip-change', { value: this.tags });
197
+ }
198
+ handleInputChange(event) {
199
+ // Update the input value
200
+ this.inputValue = event.detail.value;
201
+ }
202
+ handleInputKeydown(event) {
203
+ if (!this.acceptUserInput) {
204
+ return;
205
+ }
206
+ if (event.key === 'Tab') {
207
+ event.preventDefault();
208
+ }
209
+ if ((event.key === 'Enter' || event.key === 'Tab')
210
+ && this.inputValue
211
+ && (!this.noDuplicates || !this.tags.includes(this.inputValue))) {
212
+ event.preventDefault();
213
+ this.tags = [...this.tags, this.inputValue];
214
+ this.resetInput();
215
+ this.emit('nile-chip-change', { value: this.tags });
216
+ }
217
+ if ((event.key === 'Enter' || event.key === 'Tab')
218
+ && this.inputValue
219
+ && (this.noDuplicates || this.tags.includes(this.inputValue))) {
220
+ this.emit('nile-duplicates-blocked');
221
+ }
222
+ }
223
+ handleFocus() {
224
+ this.isDropdownOpen = true;
225
+ }
226
+ onTagsChanged() {
227
+ if (this.noDuplicates)
228
+ this.filteredAutoCompleteOptions = this.filteredAutoCompleteOptions.filter(option => !this.tags.includes(option));
229
+ }
230
+ resetInput() {
231
+ // Reset the input-related properties
232
+ this.inputValue = '';
233
+ this.isDropdownOpen = false;
234
+ this.autoComplete.value = '';
235
+ this.autoComplete.handleFocus();
236
+ }
232
237
  };
233
238
  __decorate([
234
239
  state()
@@ -300,14 +305,8 @@ __decorate([
300
305
  property({ attribute: false })
301
306
  ], NileChip.prototype, "filterFunction", void 0);
302
307
  __decorate([
303
- watch('autoCompleteOptions')
304
- ], NileChip.prototype, "onAutoCompleteOptionsChanged", null);
305
- __decorate([
306
- watch('value')
307
- ], NileChip.prototype, "onValueChanged", null);
308
- __decorate([
309
- watch('tags')
310
- ], NileChip.prototype, "onTagsChanged", null);
308
+ property({ attribute: false })
309
+ ], NileChip.prototype, "renderItemFunction", void 0);
311
310
  NileChip = __decorate([
312
311
  customElement('nile-chip')
313
312
  ], NileChip);
@@ -1 +1 @@
1
- {"version":3,"file":"nile-chip.js","sourceRoot":"","sources":["../../../src/nile-chip/nile-chip.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAEL,IAAI,GAGL,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,WAAgC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O,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAkB;AAGjB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAkB;AAGlC;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;qDAAiC;AAEhC;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;6DAAyC;AAExC;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;uCAAmB;AAEhB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCAAyB;AAExB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCAA0B;AAE3B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;8CAA6B;AAEF;IAApD,QAAQ,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAe;AAEV;IAAxD,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CAAmB;AAE7C;IAA7B,QAAQ,CAAC,EAAE,SAAS,EAAC,KAAK,EAAC,CAAC;gDAAoH;AAGjJ;IADC,KAAK,CAAC,qBAAqB,CAAC;4DAU5B;AAGD;IADC,KAAK,CAAC,OAAO,CAAC;8CAId;AAGD;IADC,KAAK,CAAC,MAAM,CAAC;6CAQb;AA9FU,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CA2RpB;;AAED,eAAe,QAAQ,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {\n LitElement,\n html,\n CSSResultArray,\n TemplateResult,\n} from 'lit';\nimport { customElement, query, state, property } from 'lit/decorators.js';\nimport { styles } from './nile-chip.css';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { HasSlotController } from '../internal/slot';\nimport { watch } from '../internal/watch';\nimport NileElement, { NileFormControl } from '../internal/nile-element';\n\ninterface CustomEventDetail {\n value: string;\n}\n\n@customElement('nile-chip')\nexport class NileChip extends NileElement {\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n private readonly hasSlotController = new HasSlotController(\n this,\n 'help-text',\n 'label'\n );\n\n @state() tags: string[] = [];\n\n @state() inputValue: string = '';\n\n @state() isDropdownOpen: boolean = false;\n\n @query('nile-auto-complete') autoComplete!: any;\n\n /** Sets the input to a warning state, changing its visual appearance. */\n @property({ type: Boolean }) warning = false;\n\n /** Sets the input to an error state, changing its visual appearance. */\n @property({ type: Boolean }) error = false;\n\n /** Sets the input to a success state, changing its visual appearance. */\n @property({ type: Boolean }) success = false;\n\n /** Disables the duplicate entries. */\n @property({ type: Boolean }) noDuplicates = false;\n\n /** The input's label. If you need to display HTML, use the `label` slot instead. */\n @property() label = '';\n\n /** Adds a clear button when the input is not empty. */\n @property({ type: Boolean }) acceptUserInput = false;\n\n /** Adds a clear button when the input is not empty. */\n @property({ type: Boolean }) clearable = false;\n\n /** Placeholder text to show as a hint when the input is empty. */\n @property() placeholder = 'type here...';\n\n /** Makes the input readonly. */\n @property({ type: Boolean, reflect: true }) readonly = false;\n\n /** Disables the input. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n // Auto-complete options\n @property({ type: Array }) autoCompleteOptions: any[] = [];\n\n @property({ type: Array }) filteredAutoCompleteOptions: any[] = [];\n\n @property({ type: Array }) value: any[] = [];\n\n @property({ type: Boolean }) noWrap: boolean = false;\n\n @property({ type: Boolean }) loading: boolean = false;\n\n @property({ type: Array }) errorIndexes: number[] = [];\n\n @property({ attribute: 'help-text', reflect: true }) helpText = '';\n\n @property({ attribute: 'error-message', reflect: true }) errorMessage = '';\n\n @property({ attribute:false}) filterFunction: any = (item:string,searchedValue:string)=>item.toLowerCase().includes(searchedValue.toLowerCase());\n\n @watch('autoCompleteOptions')\n onAutoCompleteOptionsChanged() {\n this.filteredAutoCompleteOptions = [...this.autoCompleteOptions];\n\n if (this.noDuplicates) {\n this.filteredAutoCompleteOptions =\n this.filteredAutoCompleteOptions.filter(\n option => !this.value.includes(option)\n );\n }\n }\n\n @watch('value')\n onValueChanged() {\n this.tags = [...this.value];\n this.onTagsChanged();\n }\n\n @watch('tags')\n onTagsChanged() {\n if (this.noDuplicates) {\n this.filteredAutoCompleteOptions =\n this.filteredAutoCompleteOptions.filter(\n option => !this.tags.includes(option)\n );\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.noDuplicates) {\n this.filteredAutoCompleteOptions =\n this.filteredAutoCompleteOptions.filter(\n option => !this.value.includes(option)\n );\n }\n this.emit('nile-init');\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.emit('nile-destroy');\n }\n\n private handleSelect(event: CustomEvent<CustomEventDetail>) {\n // Add the selected value to the tags array only if it doesn't already exist\n if (!this.noDuplicates || !this.tags.includes(event.detail.value)) {\n this.tags = [...this.tags, event.detail.value];\n this.emit('nile-chip-change', { value: this.tags });\n this.resetInput();\n }\n }\n\n private handleRemove(value: string) {\n // Remove the tag from the tags array\n this.tags = this.tags.filter(tag => tag !== value);\n\n if (this.noDuplicates && this.autoCompleteOptions.includes(value)) {\n this.filteredAutoCompleteOptions = [\n ...this.filteredAutoCompleteOptions,\n value,\n ];\n }\n this.emit('nile-chip-change', { value: this.tags });\n }\n\n private handleInputChange(event: CustomEvent<CustomEventDetail>) {\n // Update the input value\n this.inputValue = event.detail.value;\n }\n\n private handleInputKeydown(event: KeyboardEvent) {\n if (!this.acceptUserInput) {\n return;\n }\n\n if(event.key === 'Tab'){\n event.preventDefault()\n }\n \n if (\n (event.key === 'Enter' || event.key === 'Tab' ) \n && this.inputValue \n && (!this.noDuplicates || !this.tags.includes(this.inputValue))\n ) {\n event.preventDefault()\n this.tags = [...this.tags, this.inputValue];\n this.resetInput();\n this.emit('nile-chip-change', { value: this.tags });\n }\n\n if(\n (event.key === 'Enter'|| event.key === 'Tab' ) \n && this.inputValue \n && (this.noDuplicates || this.tags.includes(this.inputValue))\n ){\n this.emit('nile-duplicates-blocked');\n }\n }\n\n private handleFocus() {\n this.isDropdownOpen = true;\n }\n\n private resetInput() {\n // Reset the input-related properties\n this.inputValue = '';\n this.isDropdownOpen = false;\n this.autoComplete.value = '';\n this.autoComplete.handleFocus();\n }\n\n render() {\n // Check if slots are present\n const hasLabelSlot = this.hasSlotController.test('label');\n const hasHelpTextSlot = this.hasSlotController.test('help-text');\n\n // Check if label and help text are present\n const hasLabel = this.label ? true : !!hasLabelSlot;\n\n const hasHelpText = this.helpText ? true : false;\n const hasErrorMessage = this.errorMessage ? true : false;\n\n return html`\n <div\n part=\"form-control\"\n class=${classMap({\n 'form-control': true,\n 'form-control--medium': true,\n 'form-control--has-label': hasLabel,\n 'form-control--has-help-text': hasHelpText,\n 'nile-chip--disabled': this.disabled,\n })}\n >\n <label\n part=\"form-control-label\"\n class=\"form-control__label\"\n for=\"input\"\n aria-hidden=${hasLabel ? 'false' : 'true'}\n >\n <slot name=\"label\">${this.label}</slot>\n </label>\n\n <div\n class=${classMap({\n 'nile-chip': true,\n 'nile-chip--warning': this.warning,\n 'nile-chip--error': this.error,\n 'nile-chip--success': this.success,\n 'nile-chip--no-wrap': this.noWrap,\n })}\n >\n ${this.tags.map(\n (tag, index) => html`\n <nile-tag\n class=${classMap({\n 'nile-chip__tags': true,\n })}\n .variant=${this.errorIndexes.includes(index) ? 'error' : 'normal'}\n @nile-remove=${() => this.handleRemove(tag)}\n removable\n pill\n >\n ${tag}\n </nile-tag>\n `\n )}\n <div class=\"nile-chip__auto-complete\">\n <nile-auto-complete\n .allMenuItems=${this.filteredAutoCompleteOptions}\n .filterFunction=${this.filterFunction}\n .loading=\"${this.loading}\"\n .value=${this.inputValue}\n ?isDropdownOpen=${this.isDropdownOpen}\n .noBorder=${true}\n openOnFocus\n exportparts=\"options__wrapper\"\n .placeholder=${this.placeholder}\n @nile-input=${this.handleInputChange}\n @keydown=${this.handleInputKeydown}\n @nile-focus=${this.handleFocus}\n @nile-complete=${this.handleSelect}\n ></nile-auto-complete>\n </div>\n <slot\n name=\"help-text\"\n part=\"form-control-help-text\"\n id=\"help-text\"\n class=\"form-control__help-text\"\n aria-hidden=${hasHelpText ? 'false' : 'true'}\n >\n ${this.helpText}\n </slot>\n </div>\n ${\n hasHelpText\n ? html`\n <nile-form-help-text>${this.helpText}</nile-form-help-text>\n `\n : ``\n }\n\n ${\n hasErrorMessage\n ? html`\n <nile-form-error-message\n >${this.errorMessage}</nile-form-error-message\n >\n `\n : ``\n }\n </div>\n `;\n }\n}\n\nexport default NileChip;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-chip': NileChip;\n }\n}\n"]}
1
+ {"version":3,"file":"nile-chip.js","sourceRoot":"","sources":["../../../src/nile-chip/nile-chip.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAEL,IAAI,GAIL,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,WAAgC,MAAM,0BAA0B,CAAC;AAOjE,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,WAAW;IAAlC;;QAKY,sBAAiB,GAAG,IAAI,iBAAiB,CACxD,IAAI,EACJ,WAAW,EACX,OAAO,CACR,CAAC;QAEO,SAAI,GAAa,EAAE,CAAC;QAEpB,eAAU,GAAW,EAAE,CAAC;QAExB,mBAAc,GAAY,KAAK,CAAC;QAIzC,yEAAyE;QAC5C,YAAO,G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;IAAX,QAAQ,EAAE;6CAA8B;AAGG;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAkB;AAGjB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAkB;AAGlC;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;qDAAiC;AAEhC;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;6DAAyC;AAExC;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;uCAAmB;AAEhB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCAAyB;AAExB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCAA0B;AAE3B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;8CAA6B;AAEF;IAApD,QAAQ,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAe;AAEV;IAAxD,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CAAmB;AAE7C;IAA7B,QAAQ,CAAC,EAAE,SAAS,EAAC,KAAK,EAAC,CAAC;gDAAoH;AAEnH;IAA7B,QAAQ,CAAC,EAAE,SAAS,EAAC,KAAK,EAAC,CAAC;oDAA4C;AApE9D,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CA2RpB;;AAED,eAAe,QAAQ,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {\n LitElement,\n html,\n CSSResultArray,\n TemplateResult,\n PropertyValues,\n} from 'lit';\nimport { customElement, query, state, property } from 'lit/decorators.js';\nimport { styles } from './nile-chip.css';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { HasSlotController } from '../internal/slot';\nimport NileElement, { NileFormControl } from '../internal/nile-element';\n\ninterface CustomEventDetail {\n value: string;\n}\n\n@customElement('nile-chip')\nexport class NileChip extends NileElement {\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n private readonly hasSlotController = new HasSlotController(\n this,\n 'help-text',\n 'label'\n );\n\n @state() tags: string[] = [];\n\n @state() inputValue: string = '';\n\n @state() isDropdownOpen: boolean = false;\n\n @query('nile-auto-complete') autoComplete!: any;\n\n /** Sets the input to a warning state, changing its visual appearance. */\n @property({ type: Boolean }) warning = false;\n\n /** Sets the input to an error state, changing its visual appearance. */\n @property({ type: Boolean }) error = false;\n\n /** Sets the input to a success state, changing its visual appearance. */\n @property({ type: Boolean }) success = false;\n\n /** Disables the duplicate entries. */\n @property({ type: Boolean }) noDuplicates = false;\n\n /** The input's label. If you need to display HTML, use the `label` slot instead. */\n @property() label = '';\n\n /** Adds a clear button when the input is not empty. */\n @property({ type: Boolean }) acceptUserInput = false;\n\n /** Adds a clear button when the input is not empty. */\n @property({ type: Boolean }) clearable = false;\n\n /** Placeholder text to show as a hint when the input is empty. */\n @property() placeholder = 'type here...';\n\n /** Makes the input readonly. */\n @property({ type: Boolean, reflect: true }) readonly = false;\n\n /** Disables the input. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n // Auto-complete options\n @property({ type: Array }) autoCompleteOptions: any[] = [];\n\n @property({ type: Array }) filteredAutoCompleteOptions: any[] = [];\n\n @property({ type: Array }) value: any[] = [];\n\n @property({ type: Boolean }) noWrap: boolean = false;\n\n @property({ type: Boolean }) loading: boolean = false;\n\n @property({ type: Array }) errorIndexes: number[] = [];\n\n @property({ attribute: 'help-text', reflect: true }) helpText = '';\n\n @property({ attribute: 'error-message', reflect: true }) errorMessage = '';\n\n @property({ attribute:false}) filterFunction: any = (item:string,searchedValue:string)=>item.toLowerCase().includes(searchedValue.toLowerCase());\n\n @property({ attribute:false}) renderItemFunction: any = (item:any)=>item;\n\n protected updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n if (changedProperties.has('autoCompleteOptions')) {\n this.filteredAutoCompleteOptions = [...this.autoCompleteOptions];\n if (this.noDuplicates) {\n this.filteredAutoCompleteOptions =\n this.filteredAutoCompleteOptions.filter(\n option => !this.value.includes(option)\n );\n }\n }\n if (changedProperties.has('value')){\n this.tags = [...this.value];\n this.onTagsChanged();\n }\n if (changedProperties.has('tags')){\n this.onTagsChanged();\n }\n }\n\n connectedCallback() {\n super.connectedCallback();\n if (this.noDuplicates) {\n this.filteredAutoCompleteOptions =\n this.filteredAutoCompleteOptions.filter(\n option => !this.value.includes(option)\n );\n }\n this.emit('nile-init');\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.emit('nile-destroy');\n }\n\n render() {\n // Check if slots are present\n const hasLabelSlot = this.hasSlotController.test('label');\n const hasHelpTextSlot = this.hasSlotController.test('help-text');\n\n // Check if label and help text are present\n const hasLabel = this.label ? true : !!hasLabelSlot;\n\n const hasHelpText = this.helpText ? true : false;\n const hasErrorMessage = this.errorMessage ? true : false;\n\n return html`\n <div\n part=\"form-control\"\n class=${classMap({\n 'form-control': true,\n 'form-control--medium': true,\n 'form-control--has-label': hasLabel,\n 'form-control--has-help-text': hasHelpText,\n 'nile-chip--disabled': this.disabled,\n })}\n >\n <label\n part=\"form-control-label\"\n class=\"form-control__label\"\n for=\"input\"\n aria-hidden=${hasLabel ? 'false' : 'true'}\n >\n <slot name=\"label\">${this.label}</slot>\n </label>\n\n <div\n class=${classMap({\n 'nile-chip': true,\n 'nile-chip--warning': this.warning,\n 'nile-chip--error': this.error,\n 'nile-chip--success': this.success,\n 'nile-chip--no-wrap': this.noWrap,\n })}\n >\n ${this.tags.map(\n (tag, index) => html`\n <nile-tag\n class=${classMap({\n 'nile-chip__tags': true,\n })}\n .variant=${this.errorIndexes.includes(index) ? 'error' : 'normal'}\n @nile-remove=${() => this.handleRemove(tag)}\n removable\n pill\n >\n ${tag}\n </nile-tag>\n `\n )}\n <div class=\"nile-chip__auto-complete\">\n <nile-auto-complete\n .allMenuItems=${this.filteredAutoCompleteOptions}\n .filterFunction=${this.filterFunction}\n .renderItemFunction=${this.renderItemFunction}\n .loading=\"${this.loading}\"\n .value=${this.inputValue}\n ?isDropdownOpen=${this.isDropdownOpen}\n .noBorder=${true}\n openOnFocus\n exportparts=\"options__wrapper\"\n .placeholder=${this.placeholder}\n @nile-input=${this.handleInputChange}\n @keydown=${this.handleInputKeydown}\n @nile-focus=${this.handleFocus}\n @nile-complete=${this.handleSelect}\n ></nile-auto-complete>\n </div>\n <slot\n name=\"help-text\"\n part=\"form-control-help-text\"\n id=\"help-text\"\n class=\"form-control__help-text\"\n aria-hidden=${hasHelpText ? 'false' : 'true'}\n >\n ${this.helpText}\n </slot>\n </div>\n ${\n hasHelpText\n ? html`\n <nile-form-help-text>${this.helpText}</nile-form-help-text>\n `\n : ``\n }\n\n ${\n hasErrorMessage\n ? html`\n <nile-form-error-message\n >${this.errorMessage}</nile-form-error-message\n >\n `\n : ``\n }\n </div>\n `;\n }\n\n private handleSelect(event: CustomEvent<CustomEventDetail>) {\n // Add the selected value to the tags array only if it doesn't already exist\n if (!this.noDuplicates || !this.tags.includes(event.detail.value)) {\n this.tags = [...this.tags, event.detail.value];\n this.emit('nile-chip-change', { value: this.tags });\n this.resetInput();\n }\n }\n\n private handleRemove(value: string) {\n // Remove the tag from the tags array\n this.tags = this.tags.filter(tag => tag !== value);\n\n if (this.noDuplicates && this.autoCompleteOptions.includes(value)) {\n this.filteredAutoCompleteOptions = [\n ...this.filteredAutoCompleteOptions,\n value,\n ];\n }\n this.emit('nile-chip-change', { value: this.tags });\n }\n\n private handleInputChange(event: CustomEvent<CustomEventDetail>) {\n // Update the input value\n this.inputValue = event.detail.value;\n }\n\n private handleInputKeydown(event: KeyboardEvent) {\n if (!this.acceptUserInput) {\n return;\n }\n\n if(event.key === 'Tab'){\n event.preventDefault()\n }\n \n if (\n (event.key === 'Enter' || event.key === 'Tab' ) \n && this.inputValue \n && (!this.noDuplicates || !this.tags.includes(this.inputValue))\n ) {\n event.preventDefault()\n this.tags = [...this.tags, this.inputValue];\n this.resetInput();\n this.emit('nile-chip-change', { value: this.tags });\n }\n\n if(\n (event.key === 'Enter'|| event.key === 'Tab' ) \n && this.inputValue \n && (this.noDuplicates || this.tags.includes(this.inputValue))\n ){\n this.emit('nile-duplicates-blocked');\n }\n }\n\n private handleFocus() {\n this.isDropdownOpen = true;\n }\n\n onTagsChanged() {\n if (this.noDuplicates)\n this.filteredAutoCompleteOptions = this.filteredAutoCompleteOptions.filter(option => !this.tags.includes(option));\n }\n\n\n private resetInput() {\n // Reset the input-related properties\n this.inputValue = '';\n this.isDropdownOpen = false;\n this.autoComplete.value = '';\n this.autoComplete.handleFocus();\n }\n}\n\nexport default NileChip;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-chip': NileChip;\n }\n}\n"]}
@@ -7,7 +7,7 @@ export default css `
7
7
 
8
8
  .form-control--inline-radio ::slotted(nile-radio) {
9
9
  display: inline-block;
10
- margin-right: 24px !important;
10
+ margin-right: 24px;
11
11
  }
12
12
 
13
13
  .form-control {
@@ -1 +1 @@
1
- {"version":3,"file":"nile-radio-group.css.js","sourceRoot":"","sources":["../../../src/nile-radio-group/nile-radio-group.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,eAAe,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6CjB,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport default css`\n\n :host {\n display: block;\n }\n\n .form-control--inline-radio ::slotted(nile-radio) {\n display: inline-block;\n margin-right: 24px !important;\n }\n\n .form-control {\n border: none;\n padding: 0;\n margin: 0;\n }\n\n .form-control__label {\n padding: 0;\n font-size: 14px;\n color: var(--nile-colors-dark-900);\n font-family: var(--nile-font-family-serif);\n font-size: 14px;\n font-style: normal;\n font-weight: 400;\n line-height: 14px;\n letter-spacing: 0.2px;\n }\n\n .radio-group--required .radio-group__label::after {\n content: '*';\n margin-inline-start: -2px;\n }\n\n .visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n`;\n"]}
1
+ {"version":3,"file":"nile-radio-group.css.js","sourceRoot":"","sources":["../../../src/nile-radio-group/nile-radio-group.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,eAAe,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6CjB,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport default css`\n\n :host {\n display: block;\n }\n\n .form-control--inline-radio ::slotted(nile-radio) {\n display: inline-block;\n margin-right: 24px;\n }\n\n .form-control {\n border: none;\n padding: 0;\n margin: 0;\n }\n\n .form-control__label {\n padding: 0;\n font-size: 14px;\n color: var(--nile-colors-dark-900);\n font-family: var(--nile-font-family-serif);\n font-size: 14px;\n font-style: normal;\n font-weight: 400;\n line-height: 14px;\n letter-spacing: 0.2px;\n }\n\n .radio-group--required .radio-group__label::after {\n content: '*';\n margin-inline-start: -2px;\n }\n\n .visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n`;\n"]}