@kubex/zinc 1.0.24 → 1.0.98
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/.claude/project.md +556 -0
- package/.github/workflows/js_build_and_deploy.yaml +9 -10
- package/dist/custom-elements.json +13431 -8728
- package/dist/vscode.html-custom-data.json +571 -37
- package/dist/web-types.json +1439 -181
- package/dist/zn.d.ts +1642 -661
- package/dist/zn.min.css +1 -1
- package/dist/zn.min.js +1407 -887
- package/docs/_utilities/code-previews.cjs +10 -1
- package/docs/assets/scripts/docs.js +42 -18
- package/docs/data/data-table.json +229 -66
- package/docs/data/empty.json +6 -0
- package/docs/data/products-table.json +41 -193
- package/docs/pages/components/action-bar.md +121 -6
- package/docs/pages/components/alert.md +118 -15
- package/docs/pages/components/animated-button.md +299 -0
- package/docs/pages/components/audio-select.md +534 -0
- package/docs/pages/components/bulk-actions.md +79 -5
- package/docs/pages/components/button-group.md +235 -27
- package/docs/pages/components/button.md +139 -1
- package/docs/pages/components/chart.md +365 -9
- package/docs/pages/components/checkbox.md +387 -58
- package/docs/pages/components/chip.md +253 -33
- package/docs/pages/components/collapsible.md +393 -46
- package/docs/pages/components/cols.md +152 -30
- package/docs/pages/components/confirm.md +182 -16
- package/docs/pages/components/copy-button.md +169 -6
- package/docs/pages/components/data-select.md +194 -15
- package/docs/pages/components/data-table-filter.md +96 -5
- package/docs/pages/components/data-table-search.md +451 -0
- package/docs/pages/components/data-table-sort.md +66 -5
- package/docs/pages/components/data-table.md +727 -66
- package/docs/pages/components/datepicker.md +402 -7
- package/docs/pages/components/defined-label.md +120 -5
- package/docs/pages/components/dialog.md +339 -59
- package/docs/pages/components/dropdown.md +366 -11
- package/docs/pages/components/editor.md +604 -7
- package/docs/pages/components/empty-state.md +315 -16
- package/docs/pages/components/expanding-action.md +212 -28
- package/docs/pages/components/file.md +421 -12
- package/docs/pages/components/filter-container.md +158 -5
- package/docs/pages/components/filter-wrapper.md +167 -6
- package/docs/pages/components/form-group.md +383 -6
- package/docs/pages/components/hover-container.md +237 -6
- package/docs/pages/components/icon-picker.md +121 -0
- package/docs/pages/components/icon.md +454 -48
- package/docs/pages/components/inline-edit.md +787 -19
- package/docs/pages/components/input-group.md +207 -13
- package/docs/pages/components/input.md +194 -0
- package/docs/pages/components/key-container.md +115 -0
- package/docs/pages/components/key.md +101 -0
- package/docs/pages/components/menu.md +512 -6
- package/docs/pages/components/note.md +239 -36
- package/docs/pages/components/opt-group.md +107 -0
- package/docs/pages/components/pagination.md +332 -6
- package/docs/pages/components/pane.md +222 -6
- package/docs/pages/components/panel.md +213 -26
- package/docs/pages/components/popup.md +1354 -6
- package/docs/pages/components/priority-list.md +233 -0
- package/docs/pages/components/progress-bar.md +387 -6
- package/docs/pages/components/radio-group.md +242 -5
- package/docs/pages/components/radio.md +474 -6
- package/docs/pages/components/rating.md +331 -7
- package/docs/pages/components/reveal.md +524 -6
- package/docs/pages/components/scroll-container.md +552 -6
- package/docs/pages/components/select.md +762 -160
- package/docs/pages/components/skeleton.md +473 -30
- package/docs/pages/components/slideout.md +261 -5
- package/docs/pages/components/sp.md +99 -41
- package/docs/pages/components/split-button.md +347 -9
- package/docs/pages/components/split-pane.md +445 -6
- package/docs/pages/components/stat.md +549 -9
- package/docs/pages/components/status-indicator.md +230 -1
- package/docs/pages/components/stepper.md +563 -6
- package/docs/pages/components/tabs.md +439 -13
- package/docs/pages/components/textarea.md +415 -17
- package/docs/pages/components/tile.md +385 -26
- package/docs/pages/components/toggle.md +424 -6
- package/docs/pages/components/tooltip.md +367 -0
- package/docs/pages/components/translation-group.md +210 -0
- package/docs/pages/components/translations.md +319 -18
- package/docs/pages/components/vertical-stepper.md +401 -8
- package/docs/pages/components/well.md +300 -3
- package/docs/pages/getting-started/form-controls.md +162 -0
- package/docs/pages/index.md +116 -15
- package/package.json +5 -6
- package/scss/_global-spacing.scss +4 -0
- package/scss/_root.scss +2 -2
- package/scss/boot.scss +19 -0
- package/scss/shared/layout.scss +5 -0
- package/scss/themes/_light.scss +3 -3
- package/src/components/alert/alert.scss +1 -0
- package/src/components/animated-button/README.md +306 -0
- package/src/components/animated-button/animated-button.component.ts +229 -0
- package/src/components/animated-button/animated-button.scss +228 -0
- package/src/components/animated-button/animated-button.test.ts +143 -0
- package/src/components/animated-button/index.ts +12 -0
- package/src/components/button/button.component.ts +5 -0
- package/src/components/button-group/button-group.component.ts +25 -13
- package/src/components/button-group/button-group.scss +6 -0
- package/src/components/checkbox/checkbox.component.ts +4 -0
- package/src/components/checkbox/checkbox.scss +7 -4
- package/src/components/checkbox-group/checkbox-group.scss +7 -0
- package/src/components/chip/chip.component.ts +7 -2
- package/src/components/chip/chip.scss +16 -2
- package/src/components/collapsible/collapsible.component.ts +27 -20
- package/src/components/cols/cols.component.ts +14 -2
- package/src/components/cols/cols.scss +6 -12
- package/src/components/confirm/confirm.component.ts +7 -0
- package/src/components/copy-button/copy-button.component.ts +12 -11
- package/src/components/data-select/data-select.component.ts +215 -44
- package/src/components/data-select/data-select.scss +66 -6
- package/src/components/data-select/providers/currency-data-provider.ts +20 -6
- package/src/components/data-select/providers/provider.ts +1 -0
- package/src/components/data-select/providers/us-state-data-provider.ts +68 -0
- package/src/components/data-table/data-table.component.ts +82 -23
- package/src/components/data-table-search/data-table-search.component.ts +184 -0
- package/src/components/data-table-search/data-table-search.scss +17 -0
- package/src/components/data-table-search/data-table-search.test.ts +11 -0
- package/src/components/data-table-search/index.ts +12 -0
- package/src/components/datepicker/datepicker.component.ts +347 -13
- package/src/components/dialog/dialog.component.ts +1 -1
- package/src/components/empty-state/empty-state.scss +6 -1
- package/src/components/header/header.scss +3 -3
- package/src/components/icon/icon.component.ts +23 -1
- package/src/components/icon/icon.scss +23 -0
- package/src/components/icon-picker/brand-icons.ts +24 -0
- package/src/components/icon-picker/icon-picker.component.ts +407 -0
- package/src/components/icon-picker/icon-picker.scss +205 -0
- package/src/components/icon-picker/index.ts +12 -0
- package/src/components/icon-picker/line-icons.ts +612 -0
- package/src/components/icon-picker/material-icons.ts +14543 -0
- package/src/components/inline-edit/inline-edit.component.ts +190 -46
- package/src/components/inline-edit/inline-edit.scss +29 -0
- package/src/components/inline-edit/inline-edit.test.ts +314 -1
- package/src/components/input/input.component.ts +328 -5
- package/src/components/input/input.scss +100 -4
- package/src/components/input-group/input-group.component.ts +28 -7
- package/src/components/input-group/input-group.scss +48 -10
- package/src/components/item/item.component.ts +11 -2
- package/src/components/item/item.scss +7 -0
- package/src/components/key/index.ts +12 -0
- package/src/components/key/key.component.ts +47 -0
- package/src/components/key/key.scss +38 -0
- package/src/components/key-container/index.ts +12 -0
- package/src/components/key-container/key-container.component.ts +142 -0
- package/src/components/key-container/key-container.scss +33 -0
- package/src/components/menu-item/menu-item.component.ts +20 -0
- package/src/components/menu-item/menu-item.scss +69 -2
- package/src/components/navbar/navbar.component.ts +103 -8
- package/src/components/navbar/navbar.scss +6 -1
- package/src/components/opt-group/index.ts +12 -0
- package/src/components/opt-group/opt-group.component.ts +74 -0
- package/src/components/opt-group/opt-group.scss +37 -0
- package/src/components/opt-group/opt-group.test.ts +27 -0
- package/src/components/option/option.component.ts +1 -16
- package/src/components/option/option.scss +4 -0
- package/src/components/panel/panel.component.ts +10 -8
- package/src/components/panel/panel.scss +20 -0
- package/src/components/priority-list/index.ts +12 -0
- package/src/components/priority-list/priority-list.component.ts +611 -0
- package/src/components/priority-list/priority-list.scss +185 -0
- package/src/components/priority-list/priority-list.test.ts +139 -0
- package/src/components/progress-bar/progress-bar.component.ts +22 -16
- package/src/components/radio/radio.scss +10 -3
- package/src/components/select/select.component.ts +812 -72
- package/src/components/select/select.scss +108 -2
- package/src/components/select/select.test.ts +147 -2
- package/src/components/settings-container/settings-container.component.ts +44 -19
- package/src/components/settings-container/settings-container.scss +1 -1
- package/src/components/skeleton/skeleton.component.ts +6 -1
- package/src/components/slideout/slideout.scss +8 -3
- package/src/components/sp/sp.component.ts +3 -1
- package/src/components/sp/sp.scss +19 -0
- package/src/components/stepper/stepper.component.ts +16 -10
- package/src/components/textarea/textarea.scss +0 -4
- package/src/components/tile/tile.component.ts +12 -3
- package/src/components/tile/tile.scss +1 -1
- package/src/components/timer/timer.component.ts +15 -2
- package/src/components/toggle/toggle.component.ts +29 -26
- package/src/components/toggle/toggle.scss +13 -1
- package/src/components/translation-group/index.ts +12 -0
- package/src/components/translation-group/translation-group.component.ts +207 -0
- package/src/components/translation-group/translation-group.scss +8 -0
- package/src/components/translations/translations.component.ts +90 -42
- package/src/components/translations/translations.scss +5 -1
- package/src/components/vertical-stepper/vertical-stepper.component.ts +14 -9
- package/src/events/events.ts +12 -7
- package/src/events/zn-language-change.ts +7 -0
- package/src/events/zn-purchase.ts +11 -0
- package/src/events/zn-redirect.ts +7 -0
- package/src/events/zn-reorder.ts +7 -0
- package/src/events/zn-search-change.ts +11 -0
- package/src/events/zn-submit.ts +1 -1
- package/src/form-control.scss +4 -0
- package/src/internal/form-navigation.ts +510 -0
- package/src/internal/form.ts +6 -0
- package/src/zinc.ts +91 -83
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {classMap} from "lit/directives/class-map.js";
|
|
2
|
-
import {type CSSResultGroup, html, type HTMLTemplateResult, unsafeCSS} from 'lit';
|
|
3
|
-
import {defaultValue} from "../../internal/default-value";
|
|
4
|
-
import {FormControlController} from "../../internal/form";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
2
|
+
import { type CSSResultGroup, html, type HTMLTemplateResult, type PropertyValues, unsafeCSS } from 'lit';
|
|
3
|
+
import { defaultValue } from "../../internal/default-value";
|
|
4
|
+
import { FormControlController } from "../../internal/form";
|
|
5
|
+
import { HasSlotController } from "../../internal/slot";
|
|
6
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
7
|
+
import { property, query, state } from 'lit/decorators.js';
|
|
8
|
+
import { watch } from "../../internal/watch";
|
|
8
9
|
import ZincElement from '../../internal/zinc-element';
|
|
9
10
|
import ZnSelect from "../select";
|
|
10
|
-
import type {ZincFormControl} from '../../internal/zinc-element';
|
|
11
|
+
import type { ZincFormControl } from '../../internal/zinc-element';
|
|
11
12
|
import type ZnInput from "../input";
|
|
12
13
|
|
|
13
14
|
import styles from './inline-edit.scss';
|
|
@@ -22,8 +23,9 @@ import styles from './inline-edit.scss';
|
|
|
22
23
|
*
|
|
23
24
|
* @event zn-event-name - Emitted as an example.
|
|
24
25
|
*
|
|
25
|
-
* @slot -
|
|
26
|
+
* @slot - Default slot. When `input-type` is `select`, accepts `zn-option` elements to define select options. If provided, takes precedence over the `options` property.
|
|
26
27
|
* @slot example - An example slot.
|
|
28
|
+
* @slot help-text - Text that describes how to use the input. Alternatively, you can use the `help-text` attribute.
|
|
27
29
|
*
|
|
28
30
|
* @csspart base - The component's base wrapper.
|
|
29
31
|
*
|
|
@@ -34,47 +36,94 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
|
|
|
34
36
|
|
|
35
37
|
private readonly formControlController = new FormControlController(this, {
|
|
36
38
|
defaultValue: (control: ZnInlineEdit) => control.defaultValue,
|
|
39
|
+
value: (control: ZnInlineEdit) => {
|
|
40
|
+
if (control.multiple) {
|
|
41
|
+
const val = typeof control.value === 'string'
|
|
42
|
+
? control.value.split(' ').filter(v => v !== '')
|
|
43
|
+
: control.value;
|
|
44
|
+
return val.length > 0 ? val : '';
|
|
45
|
+
}
|
|
46
|
+
return control.value;
|
|
47
|
+
},
|
|
37
48
|
});
|
|
49
|
+
private readonly hasSlotController = new HasSlotController(this, 'help-text', '[default]');
|
|
38
50
|
|
|
39
|
-
@property(
|
|
51
|
+
@property() value: string | string[] = '';
|
|
40
52
|
|
|
41
53
|
@property() name: string;
|
|
42
54
|
|
|
43
|
-
@property({reflect: true}) placeholder: string;
|
|
55
|
+
@property({ reflect: true }) placeholder: string;
|
|
44
56
|
|
|
45
|
-
@property({attribute: 'edit-text'}) editText: string;
|
|
57
|
+
@property({ attribute: 'edit-text' }) editText: string;
|
|
46
58
|
|
|
47
|
-
@property({type: Boolean}) disabled: boolean
|
|
59
|
+
@property({ type: Boolean }) disabled: boolean
|
|
48
60
|
|
|
49
|
-
@property({type: Boolean}) inline: boolean
|
|
61
|
+
@property({ type: Boolean }) inline: boolean
|
|
50
62
|
|
|
51
|
-
@property({type: Boolean}) padded: boolean
|
|
63
|
+
@property({ type: Boolean }) padded: boolean
|
|
52
64
|
|
|
53
|
-
@property({reflect: true}) size: 'small' | 'medium' | 'large' = 'medium';
|
|
65
|
+
@property({ reflect: true }) size: 'small' | 'medium' | 'large' = 'medium';
|
|
54
66
|
|
|
55
|
-
@property({type: Boolean}) required: boolean
|
|
67
|
+
@property({ type: Boolean }) required: boolean
|
|
56
68
|
|
|
57
69
|
@property() pattern: string;
|
|
58
70
|
|
|
59
|
-
@property({
|
|
71
|
+
@property({ type: Boolean, reflect: true }) multiple: boolean;
|
|
60
72
|
|
|
61
|
-
@property({type:
|
|
73
|
+
@property({ type: Boolean }) clearable: boolean;
|
|
62
74
|
|
|
63
|
-
@property(
|
|
75
|
+
@property() min: string | number;
|
|
64
76
|
|
|
65
|
-
@property(
|
|
77
|
+
@property() max: string | number;
|
|
78
|
+
|
|
79
|
+
@property() step: number | 'any';
|
|
80
|
+
|
|
81
|
+
@property({ attribute: "input-type" }) inputType: 'select' | 'text' | 'data-select' | 'number' | 'textarea' = 'text';
|
|
82
|
+
|
|
83
|
+
@property({ type: Object }) options: { [key: string]: string } = {};
|
|
84
|
+
|
|
85
|
+
@property({ attribute: 'provider' }) selectProvider: string;
|
|
86
|
+
|
|
87
|
+
@property({ attribute: 'icon-position', type: Boolean }) iconPosition: 'start' | 'end' | 'none' = 'none';
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The URL to fetch options from. When set , the component fetches JSON from this URL and renders the results as
|
|
91
|
+
* options. The expected format is an array of objects with `key` and `value` properties:
|
|
92
|
+
* `[{"key": "us", "value": "United States"}, ...]`
|
|
93
|
+
* When not set, the component works exactly as before using slotted `<zn-option>` elements.
|
|
94
|
+
* Only works with type select.
|
|
95
|
+
*/
|
|
96
|
+
@property({ attribute: 'data-uri' }) dataUri: string;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Context data to send as a header when fetching options from the URL specified by the `src` property.
|
|
100
|
+
*/
|
|
101
|
+
@property({ attribute: 'context-data' }) contextData: string;
|
|
102
|
+
|
|
103
|
+
/** Enables search/filtering on select inputs. */
|
|
104
|
+
@property({ type: Boolean }) search: boolean;
|
|
66
105
|
|
|
67
106
|
/** The input's help text. If you need to display HTML, use the `help-text` slot instead. **/
|
|
68
|
-
@property({attribute: 'help-text'}) helpText: string = '';
|
|
107
|
+
@property({ attribute: 'help-text' }) helpText: string = '';
|
|
69
108
|
|
|
109
|
+
/** The text direction for the input (ltr or rtl) **/
|
|
110
|
+
@property() dir: 'ltr' | 'rtl' | 'auto' = 'auto';
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Specifies what permission the browser has to provide assistance in filling out form field values. Refer to
|
|
114
|
+
* [this page on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) for available values.
|
|
115
|
+
*/
|
|
116
|
+
@property() autocomplete: string;
|
|
70
117
|
|
|
71
118
|
@state() private hasFocus: boolean;
|
|
72
119
|
|
|
73
120
|
@state() private isEditing: boolean;
|
|
74
121
|
|
|
122
|
+
private _valueBeforeEdit: string | string[];
|
|
123
|
+
|
|
75
124
|
@query('.ai__input') input: ZnInput | ZnSelect;
|
|
76
125
|
|
|
77
|
-
@defaultValue('value') defaultValue: string;
|
|
126
|
+
@defaultValue('value') defaultValue: string | string[];
|
|
78
127
|
|
|
79
128
|
get validity(): ValidityState {
|
|
80
129
|
return this.input?.validity;
|
|
@@ -105,8 +154,8 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
|
|
|
105
154
|
document.addEventListener('keydown', this.escKeyHandler);
|
|
106
155
|
document.addEventListener('keydown', this.submitKeyHandler);
|
|
107
156
|
document.addEventListener('click', this.mouseEventHandler);
|
|
108
|
-
this.addEventListener('mousedown', this.captureMouseDown, {capture: true});
|
|
109
|
-
this.addEventListener('keydown', this.captureKeyDown, {capture: true});
|
|
157
|
+
this.addEventListener('mousedown', this.captureMouseDown, { capture: true });
|
|
158
|
+
this.addEventListener('keydown', this.captureKeyDown, { capture: true });
|
|
110
159
|
}
|
|
111
160
|
|
|
112
161
|
disconnectedCallback() {
|
|
@@ -123,13 +172,23 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
|
|
|
123
172
|
this.input.addEventListener('onclick', this.handleEditClick);
|
|
124
173
|
}
|
|
125
174
|
|
|
126
|
-
|
|
175
|
+
protected willUpdate(changedProperties: PropertyValues) {
|
|
176
|
+
if (changedProperties.has('value') || changedProperties.has('multiple')) {
|
|
177
|
+
if (this.multiple && typeof this.value === 'string') {
|
|
178
|
+
this.value = this.value.split(' ').filter(v => v !== '');
|
|
179
|
+
} else if (!this.multiple && Array.isArray(this.value)) {
|
|
180
|
+
this.value = (this.value as string[]).join(' ');
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
@watch('value', { waitUntilFirstUpdate: true })
|
|
127
186
|
async handleValueChange() {
|
|
128
187
|
await this.updateComplete;
|
|
129
188
|
this.formControlController.updateValidity();
|
|
130
189
|
}
|
|
131
190
|
|
|
132
|
-
@watch('isEditing', {waitUntilFirstUpdate: true})
|
|
191
|
+
@watch('isEditing', { waitUntilFirstUpdate: true })
|
|
133
192
|
async handleIsEditingChange() {
|
|
134
193
|
await this.updateComplete;
|
|
135
194
|
if (this.input instanceof ZnSelect && !this.isEditing) {
|
|
@@ -139,24 +198,29 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
|
|
|
139
198
|
|
|
140
199
|
mouseEventHandler = (e: MouseEvent) => {
|
|
141
200
|
if (this.isEditing && !this.contains(e.target as Node)) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
201
|
+
const hasChanged = Array.isArray(this.value)
|
|
202
|
+
? JSON.stringify(this.value) !== JSON.stringify(this._valueBeforeEdit)
|
|
203
|
+
: this.value !== this._valueBeforeEdit;
|
|
204
|
+
|
|
205
|
+
if (!hasChanged) {
|
|
206
|
+
this.isEditing = false;
|
|
207
|
+
this.input.blur();
|
|
208
|
+
}
|
|
145
209
|
}
|
|
146
210
|
};
|
|
147
211
|
|
|
148
212
|
escKeyHandler = (e: KeyboardEvent) => {
|
|
149
213
|
if (e.key === 'Escape' && this.isEditing) {
|
|
150
214
|
this.isEditing = false;
|
|
151
|
-
this.value = this.
|
|
215
|
+
this.value = this._valueBeforeEdit;
|
|
152
216
|
this.input.blur();
|
|
153
217
|
}
|
|
154
218
|
};
|
|
155
219
|
|
|
156
220
|
submitKeyHandler = (e: KeyboardEvent) => {
|
|
157
|
-
if (e.key === 'Enter' && this.isEditing) {
|
|
221
|
+
if (e.key === 'Enter' && this.isEditing && !e.shiftKey) {
|
|
158
222
|
this.isEditing = false;
|
|
159
|
-
this.emit('zn-submit', {detail: {value: this.value, element: this}});
|
|
223
|
+
this.emit('zn-submit', { detail: { value: this.value, element: this } });
|
|
160
224
|
this.formControlController.submit();
|
|
161
225
|
this.input.blur();
|
|
162
226
|
}
|
|
@@ -181,20 +245,23 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
|
|
|
181
245
|
if (this.disabled) {
|
|
182
246
|
return;
|
|
183
247
|
}
|
|
248
|
+
if (!this.isEditing) {
|
|
249
|
+
this._valueBeforeEdit = this.value;
|
|
250
|
+
}
|
|
184
251
|
this.isEditing = true;
|
|
185
252
|
}
|
|
186
253
|
|
|
187
254
|
handleSubmitClick = (e: MouseEvent) => {
|
|
188
255
|
e.preventDefault();
|
|
189
256
|
this.isEditing = false;
|
|
190
|
-
this.emit('zn-submit', {detail: {value: this.value, element: this}});
|
|
257
|
+
this.emit('zn-submit', { detail: { value: this.value, element: this } });
|
|
191
258
|
this.formControlController.submit();
|
|
192
259
|
};
|
|
193
260
|
|
|
194
261
|
handleCancelClick = (e: MouseEvent) => {
|
|
195
262
|
e.preventDefault();
|
|
196
263
|
this.isEditing = false;
|
|
197
|
-
this.value = this.
|
|
264
|
+
this.value = this._valueBeforeEdit;
|
|
198
265
|
};
|
|
199
266
|
|
|
200
267
|
handleBlur = () => {
|
|
@@ -205,12 +272,31 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
|
|
|
205
272
|
if (this.disabled || !this.isEditing) {
|
|
206
273
|
return;
|
|
207
274
|
}
|
|
275
|
+
|
|
208
276
|
this.value = (e.target as (HTMLInputElement | HTMLSelectElement)).value;
|
|
209
277
|
this.emit('zn-input');
|
|
210
278
|
};
|
|
211
279
|
|
|
280
|
+
private moveSlottedOptionsToSelect() {
|
|
281
|
+
if (!(this.input instanceof ZnSelect)) return;
|
|
282
|
+
|
|
283
|
+
const options = Array.from(this.querySelectorAll('zn-option'));
|
|
284
|
+
options.forEach(option => {
|
|
285
|
+
this.input.appendChild(option);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
handleSlotChange = async () => {
|
|
290
|
+
await this.updateComplete;
|
|
291
|
+
if (this.input instanceof ZnSelect) {
|
|
292
|
+
this.moveSlottedOptionsToSelect();
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
|
|
212
296
|
protected render() {
|
|
213
297
|
const hasEditText = this.editText;
|
|
298
|
+
const hasHelpTextSlot = this.hasSlotController.test('help-text');
|
|
299
|
+
const hasHelpText = this.helpText ? true : hasHelpTextSlot;
|
|
214
300
|
|
|
215
301
|
// Default input type to select if options are provided
|
|
216
302
|
if (Object.keys(this.options).length > 0) {
|
|
@@ -233,6 +319,9 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
|
|
|
233
319
|
case 'number':
|
|
234
320
|
input = this._getNumberInput();
|
|
235
321
|
break;
|
|
322
|
+
case 'textarea':
|
|
323
|
+
input = this._getTextAreaInput();
|
|
324
|
+
break
|
|
236
325
|
default:
|
|
237
326
|
input = this._getTextInput();
|
|
238
327
|
}
|
|
@@ -245,7 +334,7 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
|
|
|
245
334
|
'ai--disabled': this.disabled,
|
|
246
335
|
'ai--inline': this.inline,
|
|
247
336
|
'ai--padded': this.padded,
|
|
248
|
-
})}">
|
|
337
|
+
})}" dir="ltr">
|
|
249
338
|
|
|
250
339
|
<div class="ai__left" @click="${this.disabled ? undefined : this.handleEditClick}">
|
|
251
340
|
${input}
|
|
@@ -271,10 +360,44 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
|
|
|
271
360
|
<zn-button type="button" @click="${this.handleCancelClick}" icon="close" size="x-small" icon-size="20"
|
|
272
361
|
color="secondary"></zn-button>`}
|
|
273
362
|
</div>
|
|
274
|
-
</div
|
|
363
|
+
</div>
|
|
364
|
+
|
|
365
|
+
${this.isEditing && hasHelpText ? html`
|
|
366
|
+
<div
|
|
367
|
+
part="form-control-help-text"
|
|
368
|
+
id="help-text"
|
|
369
|
+
class="form-control__help-text"
|
|
370
|
+
aria-hidden="false">
|
|
371
|
+
<slot name="help-text">${this.helpText}</slot>
|
|
372
|
+
</div>
|
|
373
|
+
` : ''}
|
|
374
|
+
|
|
375
|
+
${this.inputType === 'select' ? html`
|
|
376
|
+
<div style="display: none;">
|
|
377
|
+
<slot @slotchange="${this.handleSlotChange}"></slot>
|
|
378
|
+
</div>
|
|
379
|
+
` : ''}`;
|
|
275
380
|
}
|
|
276
381
|
|
|
277
382
|
|
|
383
|
+
protected _getTextAreaInput(): HTMLTemplateResult {
|
|
384
|
+
return html`
|
|
385
|
+
<zn-textarea
|
|
386
|
+
class="ai__input"
|
|
387
|
+
name="${this.name}"
|
|
388
|
+
size="${this.size}"
|
|
389
|
+
resize="auto"
|
|
390
|
+
rows="1"
|
|
391
|
+
.value="${this.value}"
|
|
392
|
+
placeholder="${this.placeholder}"
|
|
393
|
+
pattern=${ifDefined(this.pattern)}
|
|
394
|
+
autocomplete=${ifDefined(this.autocomplete)}
|
|
395
|
+
dir="${this.dir}"
|
|
396
|
+
@zn-input="${this.handleInput}"
|
|
397
|
+
@zn-blur="${this.handleBlur}">
|
|
398
|
+
</zn-textarea>`;
|
|
399
|
+
}
|
|
400
|
+
|
|
278
401
|
protected _getTextInput(): HTMLTemplateResult {
|
|
279
402
|
return html`
|
|
280
403
|
<zn-input type="text"
|
|
@@ -283,8 +406,10 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
|
|
|
283
406
|
size="${this.size}"
|
|
284
407
|
value="${this.value}"
|
|
285
408
|
placeholder="${this.placeholder}"
|
|
286
|
-
help-text="${ifDefined(this.helpText)}"
|
|
287
409
|
pattern=${ifDefined(this.pattern)}
|
|
410
|
+
autocomplete=${ifDefined(this.autocomplete)}
|
|
411
|
+
required=${ifDefined(this.required)}
|
|
412
|
+
dir="${this.dir}"
|
|
288
413
|
@zn-input="${this.handleInput}"
|
|
289
414
|
@zn-blur="${this.handleBlur}">
|
|
290
415
|
</zn-input>`;
|
|
@@ -298,27 +423,44 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
|
|
|
298
423
|
size="${this.size}"
|
|
299
424
|
value="${this.value}"
|
|
300
425
|
placeholder="${this.placeholder}"
|
|
301
|
-
help-text="${ifDefined(this.helpText)}"
|
|
302
426
|
pattern=${ifDefined(this.pattern)}
|
|
427
|
+
autocomplete=${ifDefined(this.autocomplete)}
|
|
428
|
+
min=${ifDefined(this.min)}
|
|
429
|
+
max=${ifDefined(this.max)}
|
|
430
|
+
step=${ifDefined(this.step)}
|
|
431
|
+
required=${ifDefined(this.required)}
|
|
432
|
+
dir="${this.dir}"
|
|
303
433
|
@zn-input="${this.handleInput}"
|
|
304
434
|
@zn-blur="${this.handleBlur}">
|
|
305
435
|
</zn-input>`;
|
|
306
436
|
}
|
|
307
437
|
|
|
308
438
|
protected _getSelectInput(): HTMLTemplateResult {
|
|
439
|
+
const hasSlottedOptions = this.hasSlotController.test('[default]');
|
|
440
|
+
const value = this.multiple && Array.isArray(this.value) ? (this.value as string[]).join(' ') : this.value;
|
|
441
|
+
|
|
309
442
|
return html`
|
|
310
443
|
<zn-select class="ai__input"
|
|
311
444
|
name="${this.name}"
|
|
312
|
-
value="${
|
|
313
|
-
help-text="${ifDefined(this.helpText)}"
|
|
445
|
+
value="${ifDefined(value)}"
|
|
314
446
|
size="${this.size}"
|
|
315
447
|
placeholder="${this.placeholder}"
|
|
448
|
+
required=${ifDefined(this.required)}
|
|
449
|
+
dir="${this.dir}"
|
|
450
|
+
multiple=${ifDefined(this.multiple)}
|
|
451
|
+
clearable=${ifDefined(this.isEditing ? this.clearable : undefined)}
|
|
452
|
+
?search=${this.search}
|
|
453
|
+
non-removable
|
|
454
|
+
data-uri=${ifDefined(this.dataUri)}
|
|
455
|
+
context-data=${ifDefined(this.contextData)}
|
|
316
456
|
@zn-input="${this.handleInput}"
|
|
317
457
|
@zn-blur="${this.handleBlur}">
|
|
318
|
-
${
|
|
319
|
-
|
|
320
|
-
${
|
|
321
|
-
|
|
458
|
+
${!hasSlottedOptions
|
|
459
|
+
? Object.keys(this.options).map(key => html`
|
|
460
|
+
<zn-option value="${key}">
|
|
461
|
+
${this.options[key]}
|
|
462
|
+
</zn-option>`)
|
|
463
|
+
: ''}
|
|
322
464
|
</zn-select>`
|
|
323
465
|
}
|
|
324
466
|
|
|
@@ -328,9 +470,11 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
|
|
|
328
470
|
name="${this.name}"
|
|
329
471
|
value="${this.value}"
|
|
330
472
|
icon-position="${ifDefined(this.iconPosition)}"
|
|
331
|
-
help-text="${ifDefined(this.helpText)}"
|
|
332
473
|
size="${this.size}"
|
|
333
474
|
provider="${this.selectProvider}"
|
|
475
|
+
clearable=${ifDefined(this.isEditing ? this.clearable : undefined)}
|
|
476
|
+
required=${ifDefined(this.required)}
|
|
477
|
+
dir="${this.dir}"
|
|
334
478
|
@zn-input="${this.handleInput}"
|
|
335
479
|
@zn-blur="${this.handleBlur}">
|
|
336
480
|
</zn-data-select>`;
|
|
@@ -59,6 +59,22 @@
|
|
|
59
59
|
&__input {
|
|
60
60
|
height: unset;
|
|
61
61
|
opacity: 1;
|
|
62
|
+
|
|
63
|
+
// Force left alignment for RTL text inputs
|
|
64
|
+
&[dir="rtl"]::part(input),
|
|
65
|
+
&[dir="rtl"]::part(textarea),
|
|
66
|
+
&[dir="rtl"]::part(combobox) {
|
|
67
|
+
text-align: left;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Hide webkit spin buttons for number inputs when not editing
|
|
72
|
+
&:not(.ai--editing) {
|
|
73
|
+
.ai__input::part(input)::-webkit-inner-spin-button,
|
|
74
|
+
.ai__input::part(input)::-webkit-outer-spin-button {
|
|
75
|
+
-webkit-appearance: none;
|
|
76
|
+
margin: 0;
|
|
77
|
+
}
|
|
62
78
|
}
|
|
63
79
|
|
|
64
80
|
&--padded {
|
|
@@ -150,3 +166,16 @@
|
|
|
150
166
|
}
|
|
151
167
|
}
|
|
152
168
|
|
|
169
|
+
zn-textarea::part(textarea) {
|
|
170
|
+
resize: none;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.ai:not(.ai--editing) {
|
|
174
|
+
zn-textarea::part(textarea) {
|
|
175
|
+
box-shadow: none;
|
|
176
|
+
padding-left: 0;
|
|
177
|
+
padding-right: 0;
|
|
178
|
+
min-height: 35px;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|