@aquera/nile-elements 0.1.34 → 0.1.35-beta-1.2
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/README.md +29 -8
- package/demo/index.css +7 -4
- package/demo/index.html +20 -36
- package/demo/variables.css +13 -0
- package/demo/variables_v2.css +13 -0
- package/dist/{fixture-161dee0b.cjs.js → fixture-d5b55278.cjs.js} +3 -3
- package/dist/fixture-d5b55278.cjs.js.map +1 -0
- package/dist/{fixture-372df3b0.esm.js → fixture-df8b52d7.esm.js} +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/internal/animate.cjs.js +1 -1
- package/dist/internal/animate.cjs.js.map +1 -1
- package/dist/internal/animate.esm.js +1 -1
- package/dist/nile-accordion/nile-accordian.test.cjs.js +1 -1
- package/dist/nile-accordion/nile-accordian.test.esm.js +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.test.esm.js +1 -1
- package/dist/nile-avatar/nile-avatar.test.cjs.js +1 -1
- package/dist/nile-avatar/nile-avatar.test.esm.js +1 -1
- package/dist/nile-badge/nile-badge.test.cjs.js +1 -1
- package/dist/nile-badge/nile-badge.test.esm.js +1 -1
- package/dist/nile-button/nile-button.test.cjs.js +1 -1
- package/dist/nile-button/nile-button.test.esm.js +1 -1
- package/dist/nile-button-toggle-group/nile-button-toggle-group.test.cjs.js +1 -1
- package/dist/nile-button-toggle-group/nile-button-toggle-group.test.esm.js +1 -1
- package/dist/nile-calendar/nile-calendar.test.cjs.js +1 -1
- package/dist/nile-calendar/nile-calendar.test.esm.js +1 -1
- package/dist/nile-card/nile-card.test.cjs.js +1 -1
- package/dist/nile-card/nile-card.test.esm.js +1 -1
- package/dist/nile-checkbox/nile-checkbox.test.cjs.js +1 -1
- package/dist/nile-checkbox/nile-checkbox.test.esm.js +1 -1
- package/dist/nile-chip/nile-chip.test.cjs.js +1 -1
- package/dist/nile-chip/nile-chip.test.esm.js +1 -1
- package/dist/nile-code-editor/extensionSetup.cjs.js +1 -1
- package/dist/nile-code-editor/extensionSetup.cjs.js.map +1 -1
- package/dist/nile-code-editor/extensionSetup.esm.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.cjs.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -1
- package/dist/nile-code-editor/nile-code-editor.esm.js +2 -2
- package/dist/nile-dialog/nile-dialog.test.cjs.js +1 -1
- package/dist/nile-dialog/nile-dialog.test.esm.js +1 -1
- package/dist/nile-drawer/nile-drawer.test.cjs.js +1 -1
- package/dist/nile-drawer/nile-drawer.test.esm.js +1 -1
- package/dist/nile-dropdown/nile-dropdown.test.cjs.js +1 -1
- package/dist/nile-dropdown/nile-dropdown.test.esm.js +1 -1
- package/dist/nile-empty-state/nile-empty-state.test.cjs.js +1 -1
- package/dist/nile-empty-state/nile-empty-state.test.esm.js +1 -1
- package/dist/nile-error-message/nile-error-message.cjs.js +1 -1
- package/dist/nile-error-message/nile-error-message.cjs.js.map +1 -1
- package/dist/nile-error-message/nile-error-message.css.cjs.js +1 -1
- package/dist/nile-error-message/nile-error-message.css.cjs.js.map +1 -1
- package/dist/nile-error-message/nile-error-message.css.esm.js +6 -4
- package/dist/nile-error-message/nile-error-message.esm.js +4 -4
- package/dist/nile-error-message/nile-error-message.test.cjs.js +1 -1
- package/dist/nile-error-message/nile-error-message.test.esm.js +1 -1
- package/dist/nile-error-notification/nile-error-notification.css.cjs.js +1 -1
- package/dist/nile-error-notification/nile-error-notification.css.cjs.js.map +1 -1
- package/dist/nile-error-notification/nile-error-notification.css.esm.js +1 -1
- package/dist/nile-filter-chip/index.cjs.js +2 -0
- package/dist/nile-filter-chip/index.cjs.js.map +1 -0
- package/dist/nile-filter-chip/index.esm.js +1 -0
- package/dist/nile-filter-chip/nile-filter-chip.cjs.js +2 -0
- package/dist/nile-filter-chip/nile-filter-chip.cjs.js.map +1 -0
- package/dist/nile-filter-chip/nile-filter-chip.css.cjs.js +2 -0
- package/dist/nile-filter-chip/nile-filter-chip.css.cjs.js.map +1 -0
- package/dist/nile-filter-chip/nile-filter-chip.css.esm.js +98 -0
- package/dist/nile-filter-chip/nile-filter-chip.esm.js +34 -0
- package/dist/nile-filter-chip/nile-filter-chip.test.cjs.js +2 -0
- package/dist/nile-filter-chip/nile-filter-chip.test.cjs.js.map +1 -0
- package/dist/nile-filter-chip/nile-filter-chip.test.esm.js +20 -0
- package/dist/nile-form-group/nile-form-group.test.cjs.js +1 -1
- package/dist/nile-form-group/nile-form-group.test.esm.js +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.test.cjs.js +1 -1
- package/dist/nile-form-help-text/nile-form-help-text.test.esm.js +1 -1
- package/dist/nile-hero/nile-hero.test.cjs.js +1 -1
- package/dist/nile-hero/nile-hero.test.esm.js +1 -1
- package/dist/nile-icon/nile-icon.test.cjs.js +1 -1
- package/dist/nile-icon/nile-icon.test.esm.js +1 -1
- package/dist/nile-input/nile-input.test.cjs.js +1 -1
- package/dist/nile-input/nile-input.test.esm.js +1 -1
- package/dist/nile-link/nile-link.test.cjs.js +1 -1
- package/dist/nile-link/nile-link.test.esm.js +1 -1
- package/dist/nile-loader/nile-loader.test.cjs.js +1 -1
- package/dist/nile-loader/nile-loader.test.esm.js +1 -1
- package/dist/nile-popover/nile-popover.test.cjs.js +1 -1
- package/dist/nile-popover/nile-popover.test.esm.js +1 -1
- package/dist/nile-popup/nile-popup.test.cjs.js +1 -1
- package/dist/nile-popup/nile-popup.test.esm.js +1 -1
- package/dist/nile-progress-bar/nile-progress-bar.css.cjs.js +1 -1
- package/dist/nile-progress-bar/nile-progress-bar.css.cjs.js.map +1 -1
- package/dist/nile-progress-bar/nile-progress-bar.css.esm.js +1 -0
- package/dist/nile-progress-bar/nile-progress-bar.test.cjs.js +1 -1
- package/dist/nile-progress-bar/nile-progress-bar.test.esm.js +1 -1
- package/dist/nile-radio/nile-radio.test.cjs.js +1 -1
- package/dist/nile-radio/nile-radio.test.esm.js +1 -1
- package/dist/nile-radio-group/nile-radio-group.test.cjs.js +1 -1
- package/dist/nile-radio-group/nile-radio-group.test.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.esm.js +1 -1
- package/dist/nile-select/nile-select.test.cjs.js +1 -1
- package/dist/nile-select/nile-select.test.esm.js +1 -1
- package/dist/nile-slide-toggle/nile-slide-toggle.test.cjs.js +1 -1
- package/dist/nile-slide-toggle/nile-slide-toggle.test.esm.js +1 -1
- package/dist/nile-tab-group/nile-tab-group.test.cjs.js +1 -1
- package/dist/nile-tab-group/nile-tab-group.test.esm.js +1 -1
- package/dist/nile-table/nile-table.cjs.js.map +1 -1
- package/dist/nile-textarea/nile-textarea.test.cjs.js +1 -1
- package/dist/nile-textarea/nile-textarea.test.esm.js +1 -1
- package/dist/nile-tooltip/index.cjs.js +1 -1
- package/dist/nile-tooltip/index.esm.js +1 -1
- package/dist/nile-tooltip/nile-tooltip-utils.cjs.js +2 -0
- package/dist/nile-tooltip/nile-tooltip-utils.cjs.js.map +1 -0
- package/dist/nile-tooltip/nile-tooltip-utils.esm.js +1 -0
- package/dist/nile-tooltip/nile-tooltip.cjs.js +1 -1
- package/dist/nile-tooltip/nile-tooltip.cjs.js.map +1 -1
- package/dist/nile-tooltip/nile-tooltip.css.cjs.js +1 -1
- package/dist/nile-tooltip/nile-tooltip.css.cjs.js.map +1 -1
- package/dist/nile-tooltip/nile-tooltip.css.esm.js +78 -45
- package/dist/nile-tooltip/nile-tooltip.esm.js +23 -28
- package/dist/nile-tooltip/nile-tooltip.test.cjs.js +2 -0
- package/dist/nile-tooltip/nile-tooltip.test.cjs.js.map +1 -0
- package/dist/nile-tooltip/nile-tooltip.test.esm.js +47 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/nile-code-editor/extensionSetup.d.ts +2 -1
- package/dist/src/nile-code-editor/extensionSetup.js +8 -0
- package/dist/src/nile-code-editor/extensionSetup.js.map +1 -1
- package/dist/src/nile-code-editor/nile-code-editor.d.ts +2 -0
- package/dist/src/nile-code-editor/nile-code-editor.js +12 -3
- package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
- package/dist/src/nile-error-message/nile-error-message.css.js +6 -4
- package/dist/src/nile-error-message/nile-error-message.css.js.map +1 -1
- package/dist/src/nile-error-message/nile-error-message.d.ts +4 -0
- package/dist/src/nile-error-message/nile-error-message.js +20 -0
- package/dist/src/nile-error-message/nile-error-message.js.map +1 -1
- package/dist/src/nile-error-notification/nile-error-notification.css.js +1 -1
- package/dist/src/nile-error-notification/nile-error-notification.css.js.map +1 -1
- package/dist/src/nile-filter-chip/index.d.ts +1 -0
- package/dist/src/nile-filter-chip/index.js +2 -0
- package/dist/src/nile-filter-chip/index.js.map +1 -0
- package/dist/src/nile-filter-chip/nile-filter-chip.css.d.ts +12 -0
- package/dist/src/nile-filter-chip/nile-filter-chip.css.js +110 -0
- package/dist/src/nile-filter-chip/nile-filter-chip.css.js.map +1 -0
- package/dist/src/nile-filter-chip/nile-filter-chip.d.ts +35 -0
- package/dist/src/nile-filter-chip/nile-filter-chip.js +128 -0
- package/dist/src/nile-filter-chip/nile-filter-chip.js.map +1 -0
- package/dist/src/nile-filter-chip/nile-filter-chip.test.d.ts +1 -0
- package/dist/src/nile-filter-chip/nile-filter-chip.test.js +80 -0
- package/dist/src/nile-filter-chip/nile-filter-chip.test.js.map +1 -0
- package/dist/src/nile-progress-bar/nile-progress-bar.css.js +1 -0
- package/dist/src/nile-progress-bar/nile-progress-bar.css.js.map +1 -1
- package/dist/src/nile-select/nile-select.js +1 -1
- package/dist/src/nile-select/nile-select.js.map +1 -1
- package/dist/src/nile-table/nile-table.js.map +1 -1
- package/dist/src/nile-tooltip/nile-tooltip-utils.d.ts +18 -0
- package/dist/src/nile-tooltip/nile-tooltip-utils.js +216 -0
- package/dist/src/nile-tooltip/nile-tooltip-utils.js.map +1 -0
- package/dist/src/nile-tooltip/nile-tooltip.css.js +76 -43
- package/dist/src/nile-tooltip/nile-tooltip.css.js.map +1 -1
- package/dist/src/nile-tooltip/nile-tooltip.d.ts +24 -46
- package/dist/src/nile-tooltip/nile-tooltip.js +235 -232
- package/dist/src/nile-tooltip/nile-tooltip.js.map +1 -1
- package/dist/src/nile-tooltip/nile-tooltip.test.d.ts +1 -0
- package/dist/src/nile-tooltip/nile-tooltip.test.js +148 -0
- package/dist/src/nile-tooltip/nile-tooltip.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/index.ts +2 -1
- package/src/nile-code-editor/extensionSetup.ts +13 -1
- package/src/nile-code-editor/nile-code-editor.ts +9 -4
- package/src/nile-error-message/nile-error-message.css.ts +6 -4
- package/src/nile-error-message/nile-error-message.ts +18 -0
- package/src/nile-error-notification/nile-error-notification.css.ts +1 -1
- package/src/nile-filter-chip/index.ts +1 -0
- package/src/nile-filter-chip/nile-filter-chip.css.ts +115 -0
- package/src/nile-filter-chip/nile-filter-chip.test.ts +92 -0
- package/src/nile-filter-chip/nile-filter-chip.ts +125 -0
- package/src/nile-progress-bar/nile-progress-bar.css.ts +1 -0
- package/src/nile-select/nile-select.ts +1 -1
- package/src/nile-table/nile-table.ts +2 -2
- package/src/nile-tooltip/nile-tooltip-utils.ts +271 -0
- package/src/nile-tooltip/nile-tooltip.css.ts +77 -44
- package/src/nile-tooltip/nile-tooltip.test.ts +168 -0
- package/src/nile-tooltip/nile-tooltip.ts +268 -230
- package/vscode-html-custom-data.json +150 -96
- package/dist/fixture-161dee0b.cjs.js.map +0 -1
package/package.json
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
"description": "Webcomponent nile-elements following open-wc recommendations",
|
4
4
|
"license": "MIT",
|
5
5
|
"author": "nile-elements",
|
6
|
-
"version": "0.1.
|
6
|
+
"version": "0.1.35-beta-1.2",
|
7
7
|
"main": "dist/src/index.js",
|
8
8
|
"type": "module",
|
9
9
|
"module": "dist/src/index.js",
|
@@ -37,6 +37,7 @@
|
|
37
37
|
"./nile-textarea": "./dist/src/nile-textarea/index.js",
|
38
38
|
"./nile-date-picker": "./dist/src/nile-date-picker/index.js",
|
39
39
|
"./nile-error-message": "./dist/src/nile-error-message/index.js",
|
40
|
+
"./nile-filter-chip": "./dist/src/nile-filter-chip/index.js",
|
40
41
|
"./nile-form-error-message": "./dist/src/nile-form-error-message/index.js",
|
41
42
|
"./nile-form-help-text": "./dist/src/nile-form-help-text/index.js",
|
42
43
|
"./nile-calendar": "./dist/src/nile-calendar/index.js",
|
@@ -84,7 +85,6 @@
|
|
84
85
|
"./nile-section-message": "./dist/src/nile-section-message/index.js",
|
85
86
|
"./nile-toolbar": "./dist/src/nile-toolbar/index.js",
|
86
87
|
"./nile-inline-edit": "./dist/src/nile-inline-edit/index.js",
|
87
|
-
"./nile-tour": "./dist/src/nile-tour/index.js",
|
88
88
|
"./nile-table": "./dist/src/nile-table/index.js"
|
89
89
|
},
|
90
90
|
"scripts": {
|
package/src/index.ts
CHANGED
@@ -75,4 +75,5 @@ export { NileTitle } from './nile-title';
|
|
75
75
|
export { NileSectionMessage } from './nile-section-message';
|
76
76
|
export { NileToolbar } from './nile-toolbar';
|
77
77
|
export { NileInlineEdit } from './nile-inline-edit';
|
78
|
-
export { NileTable } from './nile-table';
|
78
|
+
export { NileTable } from './nile-table';
|
79
|
+
export { NileFilterChip } from './nile-filter-chip';
|
@@ -56,7 +56,8 @@ export interface BasicSetupOptions extends MinimalSetupOptions {
|
|
56
56
|
completionKeymap?: boolean;
|
57
57
|
lintKeymap?: boolean;
|
58
58
|
tabSize?: number;
|
59
|
-
readonly?:
|
59
|
+
readonly?: boolean;
|
60
|
+
enableSearch?: boolean;
|
60
61
|
}
|
61
62
|
|
62
63
|
export const isValidSetup = (item: any) => {
|
@@ -88,6 +89,17 @@ export const basicSetup = (options: BasicSetupOptions = {}): Extension[] => {
|
|
88
89
|
isValidSetup(options.crosshairCursor) && extensions.push(crosshairCursor());
|
89
90
|
isValidSetup(options.highlightActiveLine) && extensions.push(highlightActiveLine());
|
90
91
|
isValidSetup(options.highlightSelectionMatches) && extensions.push(highlightSelectionMatches());
|
92
|
+
|
93
|
+
if(!options.enableSearch){
|
94
|
+
extensions.push(
|
95
|
+
keymap.of([{
|
96
|
+
key: "Mod-f", // Ctrl+F (Cmd+F on Mac)
|
97
|
+
run: () => {
|
98
|
+
return true;
|
99
|
+
}
|
100
|
+
}]))
|
101
|
+
}
|
102
|
+
|
91
103
|
if (options.tabSize && typeof options.tabSize === 'number')
|
92
104
|
extensions.push(indentUnit.of(' '.repeat(options.tabSize)));
|
93
105
|
return extensions.concat([keymap.of(keymaps.flat())]).filter(Boolean);
|
@@ -68,9 +68,11 @@ export class NileCodeEditor extends NileElement {
|
|
68
68
|
|
69
69
|
@property({ type: String, reflect: true , attribute: 'error-message' }) errorMessage: string = '';
|
70
70
|
|
71
|
-
@property({ type: Boolean, reflect: true , attribute:
|
71
|
+
@property({ type: Boolean, reflect: true , attribute: true }) error: boolean = false;
|
72
72
|
|
73
|
-
@property({ type: Boolean, reflect: true , attribute:
|
73
|
+
@property({ type: Boolean, reflect: true , attribute: true }) enableSearch: boolean = false;
|
74
|
+
|
75
|
+
@property({ type: Boolean, reflect: true , attribute: true }) noborder: boolean = false;
|
74
76
|
|
75
77
|
@property({ type: Boolean, reflect: true , attribute: true }) multiline: boolean = false;
|
76
78
|
|
@@ -96,6 +98,8 @@ export class NileCodeEditor extends NileElement {
|
|
96
98
|
|
97
99
|
@property({ type: Number, reflect: true , attribute: true}) debounceTimeout: number = 200;
|
98
100
|
|
101
|
+
@property({ type: Boolean, reflect: true , attribute: true}) aboveCursor: boolean = false;
|
102
|
+
|
99
103
|
public view: EditorView;
|
100
104
|
public viewState:EditorState;
|
101
105
|
private timeOut: any = null;
|
@@ -262,6 +266,7 @@ export class NileCodeEditor extends NileElement {
|
|
262
266
|
basicSetup({
|
263
267
|
highlightActiveLine: false,
|
264
268
|
foldGutter: this.enableFoldGutters,
|
269
|
+
enableSearch:this.enableSearch
|
265
270
|
}),
|
266
271
|
lineNumbersExtension,
|
267
272
|
readOnlyExtension,
|
@@ -269,7 +274,7 @@ export class NileCodeEditor extends NileElement {
|
|
269
274
|
customAutoCompletions,
|
270
275
|
placeholderExtension,
|
271
276
|
defaultSyntaxHighlightingExtension,
|
272
|
-
autocompletion(),
|
277
|
+
autocompletion({aboveCursor: this.aboveCursor}),
|
273
278
|
language,
|
274
279
|
customThemeExtension,
|
275
280
|
EditorView.updateListener.of((v: ViewUpdate) => {
|
@@ -565,4 +570,4 @@ function convertToSingleLine(code: string) {
|
|
565
570
|
if (!code) return '';
|
566
571
|
// Remove line breaks and unnecessary whitespace
|
567
572
|
return code.replace(/\s+/g, ' ').trim();
|
568
|
-
}
|
573
|
+
}
|
@@ -16,11 +16,11 @@ export const styles = css`
|
|
16
16
|
|
17
17
|
.nile-error-message {
|
18
18
|
width: 100%;
|
19
|
-
word-break: break-all;
|
20
19
|
font-size: var(--nile-font-size-small);
|
21
20
|
letter-spacing: 0.2px;
|
22
21
|
font-weight: var(--nile-font-weight-regular);
|
23
22
|
line-height: var(--nile-font-size-small);
|
23
|
+
max-width: var(--nile-error-max-width, 535px);
|
24
24
|
}
|
25
25
|
|
26
26
|
.nile-error-message__error {
|
@@ -32,6 +32,8 @@ export const styles = css`
|
|
32
32
|
color: var(--nile-colors-dark-500);
|
33
33
|
margin-top:6px;
|
34
34
|
line-height: 16px;
|
35
|
+
max-height: var(--nile-error-max-height, 48px);
|
36
|
+
overflow-x: auto;
|
35
37
|
}
|
36
38
|
|
37
39
|
.nile-error-message__icon {
|
@@ -54,7 +56,7 @@ export const styles = css`
|
|
54
56
|
border: 1px solid var(--nile-colors-red-500);
|
55
57
|
border-left: 6px solid var(--nile-colors-red-500);
|
56
58
|
border-radius: 4px;
|
57
|
-
margin-top:
|
59
|
+
margin-top: 8px;
|
58
60
|
padding: 12px;
|
59
61
|
background: var(--nile-colors-neutral-100);
|
60
62
|
}
|
@@ -81,10 +83,10 @@ export const styles = css`
|
|
81
83
|
}
|
82
84
|
|
83
85
|
.nile-error-message__response-expanded.expanded {
|
84
|
-
max-height:
|
86
|
+
max-height: var(--nile-error-max-dialog-height, 48px);
|
85
87
|
transition: max-height 0.3s ease-in-out;
|
86
88
|
visibility: visible;
|
87
|
-
padding:
|
89
|
+
padding: 8px;
|
88
90
|
}
|
89
91
|
`;
|
90
92
|
|
@@ -32,6 +32,12 @@ export class NileErrorMessage extends LitElement {
|
|
32
32
|
@property({ type: Boolean })
|
33
33
|
isExpanded: boolean = false;
|
34
34
|
|
35
|
+
@property({ type: String }) maxWidth: string;
|
36
|
+
|
37
|
+
@property({ type: String }) maxHeight: string;
|
38
|
+
|
39
|
+
@property({ type: String }) maxDialogHeight: string;
|
40
|
+
|
35
41
|
// The maximum length before truncation.
|
36
42
|
private readonly MAX_LENGTH: number = 100;
|
37
43
|
|
@@ -46,6 +52,18 @@ export class NileErrorMessage extends LitElement {
|
|
46
52
|
return this.errorResponse;
|
47
53
|
}
|
48
54
|
|
55
|
+
updated(changedProperties: Map<string, any>) {
|
56
|
+
if (changedProperties.has('maxWidth')) {
|
57
|
+
this.style.setProperty('--nile-error-max-width', this.maxWidth);
|
58
|
+
}
|
59
|
+
if (changedProperties.has('maxHeight')) {
|
60
|
+
this.style.setProperty('--nile-error-max-height', this.maxHeight);
|
61
|
+
}
|
62
|
+
if (changedProperties.has('maxDialogHeight')) {
|
63
|
+
this.style.setProperty('--nile-error-max-dialog-height', this.maxDialogHeight);
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
49
67
|
/**
|
50
68
|
* Toggle the expanded state of the error response.
|
51
69
|
*/
|
@@ -0,0 +1 @@
|
|
1
|
+
export { NileFilterChip } from './nile-filter-chip';
|
@@ -0,0 +1,115 @@
|
|
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';
|
9
|
+
|
10
|
+
/**
|
11
|
+
* FilterChip CSS
|
12
|
+
*/
|
13
|
+
|
14
|
+
export const styles = css`
|
15
|
+
|
16
|
+
|
17
|
+
.filter-chips {
|
18
|
+
display: flex;
|
19
|
+
align-items: center;
|
20
|
+
}
|
21
|
+
|
22
|
+
|
23
|
+
.chip {
|
24
|
+
display: inline-flex;
|
25
|
+
align-items: center;
|
26
|
+
padding: 4px 8px;
|
27
|
+
border: 1px solid var(--nile-filter-chip-chip-border-color-stroke);
|
28
|
+
border-radius: 4px;
|
29
|
+
font-size: 14px;
|
30
|
+
background-color: var(--nile-filter-chip-background-default);
|
31
|
+
color: var(--nile-filter-chip-text-default);
|
32
|
+
transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out;
|
33
|
+
cursor: pointer;
|
34
|
+
gap: 6px;
|
35
|
+
margin-right: 6px;
|
36
|
+
}
|
37
|
+
|
38
|
+
.chip:hover {
|
39
|
+
background-color: var(--nile-filter-chip-hover-background);
|
40
|
+
}
|
41
|
+
|
42
|
+
.chip:active {
|
43
|
+
background-color: var(--nile-filter-chip-active-background);
|
44
|
+
border-color: var(--nile-filter-chip-active-border-color-stroke);
|
45
|
+
}
|
46
|
+
|
47
|
+
.icon {
|
48
|
+
color: var(--nile-filter-chip-icon-color-default);
|
49
|
+
display: flex;
|
50
|
+
align-items: center;
|
51
|
+
justify-content: center;
|
52
|
+
vertical-align: middle;
|
53
|
+
position: relative;
|
54
|
+
top: 12px;
|
55
|
+
}
|
56
|
+
|
57
|
+
.label {
|
58
|
+
font-weight: 500;
|
59
|
+
color: var(--nile-filter-chip-label-color-default);
|
60
|
+
}
|
61
|
+
|
62
|
+
nile-badge::part(base) {
|
63
|
+
width: auto;
|
64
|
+
height: 14px;
|
65
|
+
border-radius: 100px;
|
66
|
+
padding: 6px;
|
67
|
+
gap: 10px;
|
68
|
+
font-size: 8px;
|
69
|
+
display: inline-flex;
|
70
|
+
align-items: center;
|
71
|
+
justify-content: center;
|
72
|
+
line-height: 1;
|
73
|
+
}
|
74
|
+
|
75
|
+
.chip-container {
|
76
|
+
display: flex;
|
77
|
+
justify-content: space-between;
|
78
|
+
align-items: center;
|
79
|
+
width: 100%;
|
80
|
+
}
|
81
|
+
|
82
|
+
.clear-all-container {
|
83
|
+
margin-left: 18px;
|
84
|
+
white-space: nowrap;
|
85
|
+
cursor: pointer;
|
86
|
+
}
|
87
|
+
|
88
|
+
|
89
|
+
.value {
|
90
|
+
color: var(--nile-filter-chip-values-color-default);
|
91
|
+
overflow: hidden;
|
92
|
+
text-overflow: ellipsis;
|
93
|
+
white-space: nowrap;
|
94
|
+
max-width: 140px;
|
95
|
+
}
|
96
|
+
|
97
|
+
.close-icon {
|
98
|
+
color: var(--nile-filter-chip-close-icon-color-default);
|
99
|
+
cursor: pointer;
|
100
|
+
display: flex;
|
101
|
+
align-items: center;
|
102
|
+
padding: 2px;
|
103
|
+
border-radius: 50%;
|
104
|
+
transition: background-color 0.2s;
|
105
|
+
}
|
106
|
+
|
107
|
+
.close-icon:hover {
|
108
|
+
background-color: var(--nile-filter-chip-close-icon-hover-background);
|
109
|
+
color: var(--nile-filter-chip-close-icon-hover-color);
|
110
|
+
}
|
111
|
+
`;
|
112
|
+
|
113
|
+
export default [styles];
|
114
|
+
|
115
|
+
|
@@ -0,0 +1,92 @@
|
|
1
|
+
import { fixture, expect, html, oneEvent } from '@open-wc/testing';
|
2
|
+
import './nile-filter-chip';
|
3
|
+
import { NileFilterChip } from './nile-filter-chip';
|
4
|
+
|
5
|
+
describe('<nile-filter-chip>', () => {
|
6
|
+
afterEach(() => {
|
7
|
+
(NileFilterChip as any).activeChips = [];
|
8
|
+
});
|
9
|
+
|
10
|
+
it('registers and unregisters itself in activeChips', async () => {
|
11
|
+
const el = await fixture<NileFilterChip>(html`
|
12
|
+
<nile-filter-chip label="L" text="T"></nile-filter-chip>
|
13
|
+
`);
|
14
|
+
expect((NileFilterChip as any).activeChips).to.include(el);
|
15
|
+
el.remove();
|
16
|
+
await el.updateComplete;
|
17
|
+
expect((NileFilterChip as any).activeChips).to.not.include(el);
|
18
|
+
});
|
19
|
+
|
20
|
+
it('renders fallback label and text', async () => {
|
21
|
+
const el = await fixture<NileFilterChip>(html`
|
22
|
+
<nile-filter-chip label="MyLabel" text="MyText"></nile-filter-chip>
|
23
|
+
`);
|
24
|
+
const label = el.shadowRoot!.querySelector('.label')! as HTMLElement;
|
25
|
+
const value = el.shadowRoot!.querySelector('.value')! as HTMLElement;
|
26
|
+
expect(label.textContent).to.equal('MyLabel:');
|
27
|
+
expect(value.textContent!.trim()).to.equal('MyText');
|
28
|
+
});
|
29
|
+
|
30
|
+
it('renders slotted label and value over fallback', async () => {
|
31
|
+
const el = await fixture<NileFilterChip>(html`
|
32
|
+
<nile-filter-chip>
|
33
|
+
<span slot="label">SLOT-LBL</span>
|
34
|
+
<span slot="value">SLOT-VAL</span>
|
35
|
+
</nile-filter-chip>
|
36
|
+
`);
|
37
|
+
const slottedLabel = el.querySelector('[slot="label"]')! as HTMLElement;
|
38
|
+
const slottedValue = el.querySelector('[slot="value"]')! as HTMLElement;
|
39
|
+
expect(slottedLabel.textContent).to.equal('SLOT-LBL');
|
40
|
+
expect(slottedValue.textContent).to.equal('SLOT-VAL');
|
41
|
+
});
|
42
|
+
|
43
|
+
it('renders an icon when the `icon` property is set', async () => {
|
44
|
+
const el = await fixture<NileFilterChip>(html`
|
45
|
+
<nile-filter-chip icon="★" label="L" text="T"></nile-filter-chip>
|
46
|
+
`);
|
47
|
+
const iconSpan = el.shadowRoot!.querySelector('.icon')! as HTMLElement;
|
48
|
+
expect(iconSpan).to.exist;
|
49
|
+
expect(iconSpan.textContent).to.equal('★');
|
50
|
+
});
|
51
|
+
|
52
|
+
it('does not render a badge when extraCount is zero', async () => {
|
53
|
+
const el = await fixture<NileFilterChip>(html`
|
54
|
+
<nile-filter-chip extraCount="0" label="L" text="T"></nile-filter-chip>
|
55
|
+
`);
|
56
|
+
expect(el.shadowRoot!.querySelector('nile-badge')).to.be.null;
|
57
|
+
});
|
58
|
+
|
59
|
+
it('renders a +badge when extraCount > 0', async () => {
|
60
|
+
const el = await fixture<NileFilterChip>(html`
|
61
|
+
<nile-filter-chip extraCount="5" label="L" text="T"></nile-filter-chip>
|
62
|
+
`);
|
63
|
+
const badge = el.shadowRoot!.querySelector('nile-badge')! as HTMLElement;
|
64
|
+
expect(badge).to.exist;
|
65
|
+
expect(badge.textContent).to.contain('+5');
|
66
|
+
});
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
it('dispatches `nile-click` on chip click', async () => {
|
71
|
+
const el = await fixture<NileFilterChip>(html`
|
72
|
+
<nile-filter-chip label="L" text="T"></nile-filter-chip>
|
73
|
+
`);
|
74
|
+
const chip = el.shadowRoot!.querySelector('.chip')! as HTMLElement;
|
75
|
+
setTimeout(() => chip.click());
|
76
|
+
const ev = await oneEvent(el, 'nile-click');
|
77
|
+
expect(ev.detail).to.deep.equal({ text: 'T', extraCount: 0 });
|
78
|
+
});
|
79
|
+
|
80
|
+
it('dispatches `nile-close` on close icon click and removes itself', async () => {
|
81
|
+
const el = await fixture<NileFilterChip>(html`
|
82
|
+
<nile-filter-chip closable extraCount="2" text="TT"></nile-filter-chip>
|
83
|
+
`);
|
84
|
+
const closeIcon = el.shadowRoot!.querySelector('.close-icon')! as HTMLElement;
|
85
|
+
setTimeout(() => closeIcon.click());
|
86
|
+
const ev = await oneEvent(el, 'nile-close');
|
87
|
+
expect(ev.detail).to.deep.equal({ text: 'TT', extraCount: 2 });
|
88
|
+
expect(document.body.contains(el)).to.be.false;
|
89
|
+
});
|
90
|
+
|
91
|
+
|
92
|
+
});
|
@@ -0,0 +1,125 @@
|
|
1
|
+
import { LitElement, html, css, CSSResultArray, TemplateResult } from 'lit';
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
3
|
+
import NileElement from '../internal/nile-element';
|
4
|
+
import { styles } from './nile-filter-chip.css';
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Nile filter-chip component.
|
8
|
+
*
|
9
|
+
* @tag nile-filter-chip
|
10
|
+
*/
|
11
|
+
@customElement('nile-filter-chip')
|
12
|
+
export class NileFilterChip extends NileElement {
|
13
|
+
@property({ type: String }) label = '';
|
14
|
+
@property({ type: String }) text = '';
|
15
|
+
@property({ type: Number }) extraCount: number = 0;
|
16
|
+
@property({ type: Boolean }) editable = false;
|
17
|
+
@property({ type: Boolean }) closable = false;
|
18
|
+
@property({ type: String }) icon = '';
|
19
|
+
@property({ type: String }) removeIcon = '';
|
20
|
+
|
21
|
+
private static activeChips: NileFilterChip[] = [];
|
22
|
+
|
23
|
+
public static get styles(): CSSResultArray {
|
24
|
+
return [styles];
|
25
|
+
}
|
26
|
+
|
27
|
+
connectedCallback() {
|
28
|
+
super.connectedCallback();
|
29
|
+
this.registerChip();
|
30
|
+
}
|
31
|
+
|
32
|
+
disconnectedCallback() {
|
33
|
+
super.disconnectedCallback();
|
34
|
+
this.unregisterChip();
|
35
|
+
}
|
36
|
+
|
37
|
+
private registerChip() {
|
38
|
+
NileFilterChip.activeChips.push(this);
|
39
|
+
}
|
40
|
+
|
41
|
+
private unregisterChip() {
|
42
|
+
NileFilterChip.activeChips = NileFilterChip.activeChips.filter(
|
43
|
+
(chip) => chip !== this
|
44
|
+
);
|
45
|
+
}
|
46
|
+
|
47
|
+
private handleClose(event: Event) {
|
48
|
+
event.stopPropagation();
|
49
|
+
this.dispatchEvent(
|
50
|
+
new CustomEvent('nile-close', { detail: { text: this.text, extraCount: this.extraCount } })
|
51
|
+
);
|
52
|
+
this.remove();
|
53
|
+
}
|
54
|
+
|
55
|
+
private handleClick() {
|
56
|
+
this.dispatchEvent(
|
57
|
+
new CustomEvent('nile-click', { detail: { text: this.text, extraCount: this.extraCount } })
|
58
|
+
);
|
59
|
+
}
|
60
|
+
|
61
|
+
private getLabelSlot(): TemplateResult {
|
62
|
+
return html`
|
63
|
+
<slot name="label">
|
64
|
+
<span class="label">${this.label}:</span>
|
65
|
+
</slot>
|
66
|
+
`;
|
67
|
+
}
|
68
|
+
|
69
|
+
private getValueSlot(): TemplateResult {
|
70
|
+
return html`
|
71
|
+
<slot name="value">
|
72
|
+
<span class="value">${this.text}</span>
|
73
|
+
</slot>
|
74
|
+
`;
|
75
|
+
}
|
76
|
+
|
77
|
+
private getExtraCountSlot(): TemplateResult {
|
78
|
+
return html`
|
79
|
+
<slot name="suffix">
|
80
|
+
${this.extraCount
|
81
|
+
? html`
|
82
|
+
<nile-badge variant="primary" pilltype="pill-color">
|
83
|
+
+${this.extraCount}
|
84
|
+
</nile-badge>
|
85
|
+
`
|
86
|
+
: html``}
|
87
|
+
</slot>
|
88
|
+
`;
|
89
|
+
}
|
90
|
+
|
91
|
+
private getCloseIconSlot(): TemplateResult {
|
92
|
+
return html`
|
93
|
+
${this.closable
|
94
|
+
? html`
|
95
|
+
<span class="close-icon" @click="${this.handleClose}">
|
96
|
+
<nile-icon name="${this.removeIcon || 'close'}" size="12"></nile-icon>
|
97
|
+
</span>
|
98
|
+
`
|
99
|
+
: html``}
|
100
|
+
`;
|
101
|
+
}
|
102
|
+
|
103
|
+
public render(): TemplateResult {
|
104
|
+
return html`
|
105
|
+
<div class="chip" @click="${this.handleClick}">
|
106
|
+
<slot name="icon">
|
107
|
+
${this.icon ? html`<span class="icon">${this.icon}</span>` : html``}
|
108
|
+
</slot>
|
109
|
+
${this.getLabelSlot()}
|
110
|
+
<slot name="content"></slot>
|
111
|
+
${this.getValueSlot()}
|
112
|
+
${this.getExtraCountSlot()}
|
113
|
+
${this.getCloseIconSlot()}
|
114
|
+
</div>
|
115
|
+
`;
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
export default NileFilterChip;
|
120
|
+
|
121
|
+
declare global {
|
122
|
+
interface HTMLElementTagNameMap {
|
123
|
+
'nile-filter-chip': NileFilterChip;
|
124
|
+
}
|
125
|
+
}
|
@@ -161,7 +161,7 @@ export class NileSelect extends NileElement implements NileFormControl {
|
|
161
161
|
/** Allows more than one option to be selected. */
|
162
162
|
@property({ type: Boolean, reflect: true }) multiple = false;
|
163
163
|
|
164
|
-
@property({ attribute:
|
164
|
+
@property({ attribute: true, reflect: true }) helpText = '';
|
165
165
|
|
166
166
|
@property({ attribute: 'error-message', reflect: true }) errorMessage = '';
|
167
167
|
|
@@ -74,7 +74,7 @@ export class NileTable extends NileElement {
|
|
74
74
|
handleBodyCssUpdate(){
|
75
75
|
if (this.rows.length<2) return;
|
76
76
|
const tableBodies = this.rows;
|
77
|
-
const firstEl=tableBodies[0].shadowRoot?.querySelector<HTMLDivElement>('div.base')
|
77
|
+
const firstEl=tableBodies[0].shadowRoot?.querySelector<HTMLDivElement>('div.base');
|
78
78
|
if(firstEl) {
|
79
79
|
firstEl.style.borderTopRightRadius="var(--nile-radius-radius-xl)";
|
80
80
|
firstEl.style.borderTopLeftRadius = 'var(--nile-radius-radius-xl)';
|
@@ -84,7 +84,7 @@ export class NileTable extends NileElement {
|
|
84
84
|
}
|
85
85
|
tableBodies.forEach((tb,i)=>{
|
86
86
|
if(i>0 && i<tableBodies.length-1){
|
87
|
-
const el=tb.shadowRoot?.querySelector<HTMLDivElement>('div.base')
|
87
|
+
const el=tb.shadowRoot?.querySelector<HTMLDivElement>('div.base');
|
88
88
|
if(el) {
|
89
89
|
el.style.borderTopRightRadius="0px";
|
90
90
|
el.style.borderTopLeftRadius = "0px";
|