smoothly 0.2.3 → 0.2.4
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/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/smoothly-accordion_51.cjs.entry.js +57 -12
- package/dist/cjs/smoothly.cjs.js +1 -1
- package/dist/collection/components/menu-options/index.js +64 -3
- package/dist/collection/components/option/index.js +35 -1
- package/dist/collection/components/option/style.css +6 -0
- package/dist/collection/components/picker/index.js +129 -10
- package/dist/collection/components/select-demo/index.js +9 -1
- package/dist/custom-elements/index.js +60 -15
- package/dist/esm/loader.js +1 -1
- package/dist/esm/smoothly-accordion_51.entry.js +57 -12
- package/dist/esm/smoothly.js +1 -1
- package/dist/smoothly/{p-6e8e1fb1.entry.js → p-a302008c.entry.js} +1 -1
- package/dist/smoothly/smoothly.esm.js +1 -1
- package/dist/types/components/menu-options/index.d.ts +5 -0
- package/dist/types/components/option/index.d.ts +5 -0
- package/dist/types/components/picker/index.d.ts +13 -3
- package/dist/types/components.d.ts +15 -0
- package/package.json +1 -1
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["smoothly-google-font.cjs",[[2,"smoothly-google-font",{"value":[1]}]]],["smoothly-radio-group.cjs",[[4,"smoothly-radio-group",{"orientation":[513]}]]],["smoothly-reorder.cjs",[[0,"smoothly-reorder"]]],["smoothly-trigger-sink.cjs",[[6,"smoothly-trigger-sink",{"context":[16],"destination":[1],"filter":[1]},[[0,"trigger","TriggerListener"]]]]],["smoothly-trigger-source.cjs",[[6,"smoothly-trigger-source",{"listen":[1]}]]],["smoothly-accordion_51.cjs",[[0,"smoothly-app-demo",{"baseUrl":[1,"base-url"]}],[0,"smoothly-input-demo"],[2,"smoothly-select-demo",null,[[0,"selectionChanged","handleSelectionChanged"]]],[0,"smoothly-display-demo"],[2,"smoothly-table-demo"],[4,"smoothly-app",{"color":[1]}],[0,"smoothly-dialog-demo"],[2,"smoothly-icon-demo"],[6,"smoothly-button",{"color":[513],"expand":[513],"fill":[513],"disabled":[516],"type":[513],"link":[1],"download":[4]}],[4,"smoothly-room",{"label":[1],"icon":[1],"path":[1],"to":[1]}],[2,"smoothly-input-date-range",{"value":[1025],"start":[1025],"end":[1025],"max":[1025],"min":[1025],"open":[1028],"showLabel":[516,"show-label"]},[[0,"startChanged","onStartChanged"],[0,"endChanged","onEndChanged"],[0,"dateRangeSet","onDateRangeSet"]]],[6,"smoothly-notifier",{"notices":[32]},[[0,"notice","onNotice"],[0,"remove","onRemove"]]],[1,"smoothly-picker",{"maxMenuHeight":[1,"max-menu-height"],"maxHeight":[1,"max-height"],"emptyMenuLabel":[1025,"empty-menu-label"],"multiple":[516],"optionStyle":[8,"option-style"],"options":[16],"labelSetting":[513,"label-setting"],"label":[513],"selections":[1040],"selectNoneName":[1025,"select-none-name"],"selectAllName":[1025,"select-all-name"],"selectionName":[1025,"selection-name"],"isOpen":[32]},[[0,"optionSelect","
|
|
17
|
+
return index.bootstrapLazy([["smoothly-google-font.cjs",[[2,"smoothly-google-font",{"value":[1]}]]],["smoothly-radio-group.cjs",[[4,"smoothly-radio-group",{"orientation":[513]}]]],["smoothly-reorder.cjs",[[0,"smoothly-reorder"]]],["smoothly-trigger-sink.cjs",[[6,"smoothly-trigger-sink",{"context":[16],"destination":[1],"filter":[1]},[[0,"trigger","TriggerListener"]]]]],["smoothly-trigger-source.cjs",[[6,"smoothly-trigger-source",{"listen":[1]}]]],["smoothly-accordion_51.cjs",[[0,"smoothly-app-demo",{"baseUrl":[1,"base-url"]}],[0,"smoothly-input-demo"],[2,"smoothly-select-demo",null,[[0,"selectionChanged","handleSelectionChanged"]]],[0,"smoothly-display-demo"],[2,"smoothly-table-demo"],[4,"smoothly-app",{"color":[1]}],[0,"smoothly-dialog-demo"],[2,"smoothly-icon-demo"],[6,"smoothly-button",{"color":[513],"expand":[513],"fill":[513],"disabled":[516],"type":[513],"link":[1],"download":[4]}],[4,"smoothly-room",{"label":[1],"icon":[1],"path":[1],"to":[1]}],[2,"smoothly-input-date-range",{"value":[1025],"start":[1025],"end":[1025],"max":[1025],"min":[1025],"open":[1028],"showLabel":[516,"show-label"]},[[0,"startChanged","onStartChanged"],[0,"endChanged","onEndChanged"],[0,"dateRangeSet","onDateRangeSet"]]],[6,"smoothly-notifier",{"notices":[32]},[[0,"notice","onNotice"],[0,"remove","onRemove"]]],[1,"smoothly-picker",{"maxMenuHeight":[1,"max-menu-height"],"maxHeight":[1,"max-height"],"emptyMenuLabel":[1025,"empty-menu-label"],"multiple":[516],"mutable":[4],"optionStyle":[8,"option-style"],"options":[16],"labelSetting":[513,"label-setting"],"label":[513],"selections":[1040],"selectNoneName":[1025,"select-none-name"],"selectAllName":[1025,"select-all-name"],"selectionName":[1025,"selection-name"],"newOptionLabel":[1025,"new-option-label"],"valueValidator":[16],"isOpen":[32],"empty":[32]},[[0,"optionSelect","optionSelectHandler"],[0,"optionAdd","optionAddHandler"],[0,"menuEmpty","emptyHandler"]]],[6,"smoothly-dialog",{"color":[513],"open":[1540],"closable":[516],"header":[513]},[[0,"trigger","TriggerListener"]]],[6,"smoothly-table-expandable-row",{"align":[1],"open":[1540]},[[0,"click","onClick"]]],[2,"smoothly-backtotop",{"opacity":[1],"bottom":[1],"right":[1],"visible":[32]}],[2,"smoothly-checkbox",{"selectAll":[4,"select-all"],"size":[1],"intermediate":[1540],"selected":[1540],"disabled":[1540],"t":[32]}],[6,"smoothly-submit",{"processing":[1540],"color":[513],"expand":[513],"fill":[513],"disabled":[516],"prevent":[4],"submit":[64]},[[0,"click","handleSubmit"]]],[6,"smoothly-table-expandable-cell",{"align":[1],"open":[1540]},[[0,"click","onClick"]]],[0,"smoothly-urlencoded",{"data":[1]}],[6,"smoothly-accordion",{"value":[1025]},[[0,"smoothlyOpen","handleOpenClose"],[0,"smoothlyClose","handleOpenClose"],[0,"smoothlyAccordionItemDidLoad","onAccordionItemDidLoad"],[0,"smoothlyAccordionItemDidUnload","onAccordionItemDidUnload"]]],[6,"smoothly-accordion-item",{"name":[1],"brand":[1],"open":[1540]}],[2,"smoothly-display",{"type":[1],"value":[8],"currency":[1],"country":[1]}],[2,"smoothly-display-amount",{"amount":[8],"currency":[1]}],[2,"smoothly-frame",{"url":[1],"name":[1],"origin":[1],"send":[64]}],[6,"smoothly-popup",{"visible":[1540],"direction":[1537],"cssVariables":[32]}],[6,"smoothly-quiet",{"color":[1]}],[6,"smoothly-radio",{"name":[1],"value":[1],"checked":[1540],"tabIndex":[2,"tab-index"]}],[6,"smoothly-select",{"identifier":[1],"background":[513],"value":[1025]}],[2,"smoothly-skeleton",{"widths":[16],"width":[1],"color":[1],"period":[2],"distance":[1],"align":[513]}],[2,"smoothly-svg",{"url":[513],"size":[513],"color":[1]}],[6,"smoothly-table",null,[[0,"expansionLoad","handleEvents"],[0,"expansionOpen","handleEvents"]]],[6,"smoothly-table-header",{"name":[1]}],[6,"smoothly-table-row",null,[[0,"expansionLoad","onExpansionLoad"],[0,"expansionOpen","onExpansionOpen"]]],[6,"smoothly-input-date",{"value":[1025],"open":[1028],"max":[1025],"min":[1025],"disabled":[1028]},[[0,"dateSet","dateSetHandler"]]],[1,"smoothly-menu-options",{"emptyMenuLabel":[1025,"empty-menu-label"],"newOptionLabel":[1,"new-option-label"],"maxMenuHeight":[1,"max-menu-height"],"order":[4],"optionStyle":[8,"option-style"],"options":[1040],"resetHighlightOnOptionsChange":[1028,"reset-highlight-on-options-change"],"mutable":[4],"filteredOptions":[32],"highlightIndex":[32],"keyword":[32],"moveHighlight":[64],"setHighlight":[64],"getHighlighted":[64],"filterOptions":[64]},[[0,"optionHover","optionHoverHandler"]]],[2,"smoothly-notification",{"notice":[16],"tick":[32]},[[0,"trigger","onTrigger"]]],[2,"smoothly-display-date-time",{"datetime":[1]}],[6,"smoothly-tab",{"label":[1],"open":[1540]},[[0,"click","onClick"]]],[6,"smoothly-tab-switch",{"selectedElement":[32]},[[0,"expansionOpen","openChanged"]]],[6,"smoothly-table-cell"],[0,"smoothly-tuple",{"tuple":[16]}],[1,"smoothly-option",{"aliases":[513],"dataHighlight":[1540,"data-highlight"],"name":[1537],"value":[1537],"divider":[1540],"new":[4]}],[2,"smoothly-spinner",{"active":[516],"size":[513]}],[2,"smoothly-calendar",{"month":[1025],"value":[1025],"start":[1025],"end":[1025],"max":[1025],"min":[1025],"doubleInput":[516,"double-input"],"firstSelected":[32]}],[6,"smoothly-input",{"name":[513],"value":[1032],"type":[513],"required":[1540],"minLength":[1026,"min-length"],"showLabel":[516,"show-label"],"maxLength":[1026,"max-length"],"autocomplete":[1028],"pattern":[1040],"placeholder":[1025],"disabled":[1028],"readonly":[1028],"currency":[513],"initialValue":[32],"getFormData":[64],"setKeepFocusOnReRender":[64],"setSelectionRange":[64]}],[2,"smoothly-input-month",{"value":[1025]}],[6,"smoothly-selector",{"opened":[32],"selectedElement":[32],"missing":[32],"filter":[32]},[[0,"click","onClick"],[0,"itemSelected","onItemSelected"],[0,"keydown","onKeyDown"]]],[6,"smoothly-item",{"value":[8],"selected":[1540],"filter":[64]},[[0,"click","onClick"]]],[6,"smoothly-trigger",{"color":[513],"expand":[513],"fill":[513],"disabled":[516],"type":[513],"name":[1],"value":[8]},[[0,"click","onClick"]]],[2,"smoothly-icon",{"color":[513],"fill":[513],"name":[1],"size":[513],"toolTip":[1,"tool-tip"],"document":[32]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -46251,12 +46251,15 @@ const styleCss$o = ":host{max-height:18.75rem;width:85%;max-height:var(--max-men
|
|
|
46251
46251
|
const SmoothlyMenuOptions = class {
|
|
46252
46252
|
constructor(hostRef) {
|
|
46253
46253
|
index.registerInstance(this, hostRef);
|
|
46254
|
+
this.menuEmpty = index.createEvent(this, "menuEmpty", 7);
|
|
46254
46255
|
this.filteredOptions = [];
|
|
46255
46256
|
this.highlightIndex = 0;
|
|
46256
46257
|
this.emptyMenuLabel = "No Options";
|
|
46258
|
+
this.newOptionLabel = "Add:";
|
|
46257
46259
|
this.order = false;
|
|
46258
46260
|
this.options = [];
|
|
46259
46261
|
this.resetHighlightOnOptionsChange = true;
|
|
46262
|
+
this.mutable = false;
|
|
46260
46263
|
}
|
|
46261
46264
|
optionsChangeHandler(newOptions) {
|
|
46262
46265
|
this.highlightIndex = this.resetHighlightOnOptionsChange ? 0 : this.highlightIndex;
|
|
@@ -46295,6 +46298,7 @@ const SmoothlyMenuOptions = class {
|
|
|
46295
46298
|
return result;
|
|
46296
46299
|
}
|
|
46297
46300
|
async filterOptions(keyword, excludeValues = []) {
|
|
46301
|
+
this.keyword = keyword;
|
|
46298
46302
|
const keywordLowercase = keyword.toLowerCase();
|
|
46299
46303
|
this.filteredOptions = [];
|
|
46300
46304
|
for (const option of this.options) {
|
|
@@ -46302,6 +46306,7 @@ const SmoothlyMenuOptions = class {
|
|
|
46302
46306
|
const isVisible = names.toLowerCase().includes(keywordLowercase) && !excludeValues.includes(option.value);
|
|
46303
46307
|
isVisible && this.filteredOptions.push(option);
|
|
46304
46308
|
}
|
|
46309
|
+
this.menuEmpty.emit(!this.filteredOptions.length);
|
|
46305
46310
|
this.order && this.sortOptions(keyword);
|
|
46306
46311
|
}
|
|
46307
46312
|
sortOptions(keyword) {
|
|
@@ -46338,7 +46343,7 @@ const SmoothlyMenuOptions = class {
|
|
|
46338
46343
|
}
|
|
46339
46344
|
}
|
|
46340
46345
|
render() {
|
|
46341
|
-
return (index.h(index.Host, { style: { "--max-menu-height": this.maxMenuHeight } }, this.filteredOptions.length > 0 ? (this.filteredOptions.map((option, index$1) => (index.h("smoothly-option", { style: this.optionStyle, ref: el => index$1 == 0 && (this.firstOptionsElement = el !== null && el !== void 0 ? el : this.firstOptionsElement), value: option.value, name: option.name, divider: option.divider, "data-highlight": this.highlightIndex == index$1 }, option.left ? index.h("div", { slot: "left" }, option.left) : undefined, option.right ? index.h("div", { slot: "right" }, option.right) : undefined)))) : (index.h("div", null, this.emptyMenuLabel))));
|
|
46346
|
+
return (index.h(index.Host, { style: { "--max-menu-height": this.maxMenuHeight } }, this.filteredOptions.length > 0 ? (this.filteredOptions.map((option, index$1) => (index.h("smoothly-option", { style: this.optionStyle, ref: el => index$1 == 0 && (this.firstOptionsElement = el !== null && el !== void 0 ? el : this.firstOptionsElement), value: option.value, name: option.name, divider: option.divider, "data-highlight": this.highlightIndex == index$1 }, option.left ? index.h("div", { slot: "left" }, option.left) : undefined, option.right ? index.h("div", { slot: "right" }, option.right) : undefined)))) : this.mutable ? (index.h("smoothly-option", { style: this.optionStyle, ref: el => (this.firstOptionsElement = el !== null && el !== void 0 ? el : this.firstOptionsElement), value: this.keyword, name: this.keyword, "data-highlight": 0, new: true }, index.h("div", { slot: "left" }, index.h("smoothly-icon", { name: "square-outline", size: "small" }), " ", this.newOptionLabel))) : (index.h("div", null, this.emptyMenuLabel))));
|
|
46342
46347
|
}
|
|
46343
46348
|
get element() { return index.getElement(this); }
|
|
46344
46349
|
static get watchers() { return {
|
|
@@ -46429,13 +46434,14 @@ const Notifier = class {
|
|
|
46429
46434
|
};
|
|
46430
46435
|
Notifier.style = styleCss$m;
|
|
46431
46436
|
|
|
46432
|
-
const styleCss$l = ":host{display:flex;flex-direction:row;align-items:center;justify-content:flex-start;padding:0.7em 1em;margin-left:1px;margin-right:1px;background-color:transparent;position:relative}:host([data-highlight]){background-color:rgb(var(--smoothly-default-shade))}:host>div.middle{padding-left:0.5em;flex-shrink:1;width:100%}:host([divider]){margin-bottom:0.5em}::slotted([slot=right]){font-style:italic;white-space:nowrap}:host([divider])::after{position:absolute;height:1px;width:100%;left:0;bottom:-0.25em;content:\"\";background-color:rgba(var(--smoothly-dark-color))}";
|
|
46437
|
+
const styleCss$l = ":host{display:flex;flex-direction:row;align-items:center;justify-content:flex-start;padding:0.7em 1em;margin-left:1px;margin-right:1px;background-color:transparent;position:relative}:host([data-highlight]){background-color:rgb(var(--smoothly-default-shade))}:host>div.middle{padding-left:0.5em;flex-shrink:1;width:100%}:host([divider]){margin-bottom:0.5em}::slotted([slot=right]){font-style:italic;white-space:nowrap}:host([divider])::after{position:absolute;height:1px;width:100%;left:0;bottom:-0.25em;content:\"\";background-color:rgba(var(--smoothly-dark-color))}::slotted([slot=left]){display:flex;align-items:center;gap:1ch}";
|
|
46433
46438
|
|
|
46434
46439
|
const SmoothlyOption = class {
|
|
46435
46440
|
constructor(hostRef) {
|
|
46436
46441
|
index.registerInstance(this, hostRef);
|
|
46437
46442
|
this.optionHover = index.createEvent(this, "optionHover", 7);
|
|
46438
46443
|
this.optionSelect = index.createEvent(this, "optionSelect", 7);
|
|
46444
|
+
this.optionAdd = index.createEvent(this, "optionAdd", 7);
|
|
46439
46445
|
this.dataHighlight = false;
|
|
46440
46446
|
this.divider = false;
|
|
46441
46447
|
}
|
|
@@ -46444,7 +46450,9 @@ const SmoothlyOption = class {
|
|
|
46444
46450
|
}
|
|
46445
46451
|
onSelect(event) {
|
|
46446
46452
|
if (this.value)
|
|
46447
|
-
this.
|
|
46453
|
+
this.new
|
|
46454
|
+
? this.optionAdd.emit({ name: this.name, value: this.value })
|
|
46455
|
+
: this.optionSelect.emit({ name: this.name, value: this.value });
|
|
46448
46456
|
else
|
|
46449
46457
|
throw `smoothly-option ${this.element.innerHTML} lacks value-property and can therefore not be selected`;
|
|
46450
46458
|
}
|
|
@@ -46461,16 +46469,20 @@ const SmoothlyPicker = class {
|
|
|
46461
46469
|
constructor(hostRef) {
|
|
46462
46470
|
index.registerInstance(this, hostRef);
|
|
46463
46471
|
this.menuClose = index.createEvent(this, "menuClose", 7);
|
|
46472
|
+
this.notice = index.createEvent(this, "notice", 7);
|
|
46464
46473
|
this.keepFocusOnReRender = false;
|
|
46465
46474
|
this.emptyMenuLabel = "No Options";
|
|
46466
46475
|
this.multiple = false;
|
|
46476
|
+
this.mutable = false;
|
|
46467
46477
|
this.options = [];
|
|
46468
46478
|
this.selections = [];
|
|
46469
46479
|
this.selectNoneName = "Select None";
|
|
46470
46480
|
this.selectAllName = "Select All";
|
|
46471
46481
|
this.selectionName = "items selected";
|
|
46482
|
+
this.newOptionLabel = "Add:";
|
|
46483
|
+
this.valueValidator = _ => [true, undefined];
|
|
46472
46484
|
}
|
|
46473
|
-
|
|
46485
|
+
isOpenChangeHandler() {
|
|
46474
46486
|
if (this.isOpen == false) {
|
|
46475
46487
|
this.menuClose.emit(this.selections);
|
|
46476
46488
|
}
|
|
@@ -46482,10 +46494,26 @@ const SmoothlyPicker = class {
|
|
|
46482
46494
|
this.keepFocusOnReRender = false;
|
|
46483
46495
|
}
|
|
46484
46496
|
}
|
|
46485
|
-
|
|
46497
|
+
optionSelectHandler(event) {
|
|
46486
46498
|
this.toggle(event.detail);
|
|
46487
46499
|
event.stopPropagation();
|
|
46488
46500
|
}
|
|
46501
|
+
optionAddHandler(event) {
|
|
46502
|
+
if (this.mutable) {
|
|
46503
|
+
const [status, notice] = this.valueValidator(event.detail.value);
|
|
46504
|
+
if (status) {
|
|
46505
|
+
const option = Object.assign({}, event.detail);
|
|
46506
|
+
this.options = [...this.options, option];
|
|
46507
|
+
this.select(option);
|
|
46508
|
+
}
|
|
46509
|
+
notice && this.notice.emit(notice);
|
|
46510
|
+
}
|
|
46511
|
+
event.stopPropagation();
|
|
46512
|
+
}
|
|
46513
|
+
emptyHandler(event) {
|
|
46514
|
+
this.empty = event.detail;
|
|
46515
|
+
event.stopPropagation();
|
|
46516
|
+
}
|
|
46489
46517
|
toggle(option) {
|
|
46490
46518
|
option.value == "select-none"
|
|
46491
46519
|
? this.toggleAll()
|
|
@@ -46520,9 +46548,19 @@ const SmoothlyPicker = class {
|
|
|
46520
46548
|
}
|
|
46521
46549
|
toggleHighlighted() {
|
|
46522
46550
|
var _a;
|
|
46523
|
-
(
|
|
46524
|
-
|
|
46525
|
-
|
|
46551
|
+
if (this.mutable && this.empty) {
|
|
46552
|
+
const [status, notice] = this.valueValidator(this.inputElement.value);
|
|
46553
|
+
if (status) {
|
|
46554
|
+
const option = { name: this.inputElement.value, value: this.inputElement.value };
|
|
46555
|
+
this.options = [...this.options, option];
|
|
46556
|
+
this.select(option);
|
|
46557
|
+
}
|
|
46558
|
+
notice && this.notice.emit(notice);
|
|
46559
|
+
}
|
|
46560
|
+
else
|
|
46561
|
+
(_a = this.menuElement) === null || _a === void 0 ? void 0 : _a.getHighlighted().then((result) => {
|
|
46562
|
+
result && this.toggle(result);
|
|
46563
|
+
});
|
|
46526
46564
|
}
|
|
46527
46565
|
highlightDefault() {
|
|
46528
46566
|
var _a;
|
|
@@ -46594,12 +46632,12 @@ const SmoothlyPicker = class {
|
|
|
46594
46632
|
];
|
|
46595
46633
|
return (index.h(index.Host, { style: cssVariables, "has-selection": this.selections.length > 0, "is-open": this.isOpen ? "" : undefined, onMouseDown: (e) => e.preventDefault(), onClick: () => this.onClick() }, index.h("div", null, index.h("smoothly-icon", { class: "search", name: "search-outline", size: "tiny" }), index.h("label", null, this.label), index.h("input", { type: "text", ref: (el) => (this.inputElement = el ? el : this.inputElement), onFocus: () => this.highlightDefault(), onBlur: () => this.onBlur(), placeholder: this.selections.length > 3
|
|
46596
46634
|
? this.selections.length.toString() + " " + this.selectionName
|
|
46597
|
-
: this.selections.map(selection => selection.name).join(", "), onKeyDown: e => this.onKeyDown(e), onInput: (e) => this.onInput(e) }), index.h("smoothly-icon", { class: "down", name: "chevron-down", size: "tiny" }), index.h("smoothly-icon", { class: "up", name: "chevron-up", size: "tiny" })), index.h("smoothly-menu-options", { style: { width: "100%" }, optionStyle: Object.assign({}, this.optionStyle), order: false, emptyMenuLabel: this.emptyMenuLabel, "max-menu-height": this.maxMenuHeight, ref: (el) => (this.menuElement = el !== null && el !== void 0 ? el : this.menuElement), onClick: e => e.stopPropagation(), resetHighlightOnOptionsChange: false, options: options })));
|
|
46635
|
+
: this.selections.map(selection => selection.name).join(", "), onKeyDown: e => this.onKeyDown(e), onInput: (e) => this.onInput(e) }), index.h("smoothly-icon", { class: "down", name: "chevron-down", size: "tiny" }), index.h("smoothly-icon", { class: "up", name: "chevron-up", size: "tiny" })), index.h("smoothly-menu-options", { style: { width: "100%" }, optionStyle: Object.assign({}, this.optionStyle), order: false, emptyMenuLabel: this.emptyMenuLabel, newOptionLabel: this.newOptionLabel, "max-menu-height": this.maxMenuHeight, mutable: this.mutable, ref: (el) => (this.menuElement = el !== null && el !== void 0 ? el : this.menuElement), onClick: e => e.stopPropagation(), resetHighlightOnOptionsChange: false, options: options })));
|
|
46598
46636
|
}
|
|
46599
46637
|
get element() { return index.getElement(this); }
|
|
46600
46638
|
static get watchers() { return {
|
|
46601
|
-
"selections": ["
|
|
46602
|
-
"isOpen": ["
|
|
46639
|
+
"selections": ["isOpenChangeHandler"],
|
|
46640
|
+
"isOpen": ["isOpenChangeHandler"]
|
|
46603
46641
|
}; }
|
|
46604
46642
|
};
|
|
46605
46643
|
SmoothlyPicker.style = styleCss$k;
|
|
@@ -46747,7 +46785,7 @@ const SmoothlySelectDemo = class {
|
|
|
46747
46785
|
{ name: "Scary Kraken", value: "kraken" },
|
|
46748
46786
|
] }),
|
|
46749
46787
|
index.h("br", null),
|
|
46750
|
-
index.h("smoothly-picker", { label: "", "empty-menu-label": "Sorry, we're out of options.", "max-height": "58px", multiple: true, options: [
|
|
46788
|
+
index.h("smoothly-picker", { label: "Multiple", "empty-menu-label": "Sorry, we're out of options.", "max-height": "58px", multiple: true, options: [
|
|
46751
46789
|
{ name: "Big Dog", value: "dog", aliases: ["WOFF"] },
|
|
46752
46790
|
{ name: "Cat Stevens", value: "cat", aliases: ["moew"] },
|
|
46753
46791
|
{ name: "Noble Pig", value: "pig" },
|
|
@@ -46761,6 +46799,13 @@ const SmoothlySelectDemo = class {
|
|
|
46761
46799
|
{ name: "Scary Kraken", value: "kraken" },
|
|
46762
46800
|
] }),
|
|
46763
46801
|
index.h("br", null),
|
|
46802
|
+
index.h("smoothly-picker", { label: "Multiple mutable", "max-height": "58px", multiple: true, mutable: true, newOptionLabel: "Invite:", options: [
|
|
46803
|
+
{ name: "john@example.com", value: "john@example.com" },
|
|
46804
|
+
{ name: "jane@example.com", value: "jane@example.com" },
|
|
46805
|
+
{ name: "james@example.com", value: "james@example.com" },
|
|
46806
|
+
{ name: "jessie@example.com", value: "jessie@example.com" },
|
|
46807
|
+
], valueValidator: (email) => email.match(/^\w+@\w+/) ? [true, undefined] : [false, Notice.Notice.failed("Incorrectly formatted email")] }),
|
|
46808
|
+
index.h("br", null),
|
|
46764
46809
|
index.h("smoothly-picker", { label: "Single select", multiple: false, "max-menu-height": "200px", options: [
|
|
46765
46810
|
{ name: "Dog", value: "dog", aliases: ["WOFF"], right: "Woof 🐶" },
|
|
46766
46811
|
{ name: "Cat", value: "cat", aliases: ["moew"] },
|
package/dist/cjs/smoothly.cjs.js
CHANGED
|
@@ -15,5 +15,5 @@ const patchBrowser = () => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(options => {
|
|
18
|
-
return index.bootstrapLazy([["smoothly-google-font.cjs",[[2,"smoothly-google-font",{"value":[1]}]]],["smoothly-radio-group.cjs",[[4,"smoothly-radio-group",{"orientation":[513]}]]],["smoothly-reorder.cjs",[[0,"smoothly-reorder"]]],["smoothly-trigger-sink.cjs",[[6,"smoothly-trigger-sink",{"context":[16],"destination":[1],"filter":[1]},[[0,"trigger","TriggerListener"]]]]],["smoothly-trigger-source.cjs",[[6,"smoothly-trigger-source",{"listen":[1]}]]],["smoothly-accordion_51.cjs",[[0,"smoothly-app-demo",{"baseUrl":[1,"base-url"]}],[0,"smoothly-input-demo"],[2,"smoothly-select-demo",null,[[0,"selectionChanged","handleSelectionChanged"]]],[0,"smoothly-display-demo"],[2,"smoothly-table-demo"],[4,"smoothly-app",{"color":[1]}],[0,"smoothly-dialog-demo"],[2,"smoothly-icon-demo"],[6,"smoothly-button",{"color":[513],"expand":[513],"fill":[513],"disabled":[516],"type":[513],"link":[1],"download":[4]}],[4,"smoothly-room",{"label":[1],"icon":[1],"path":[1],"to":[1]}],[2,"smoothly-input-date-range",{"value":[1025],"start":[1025],"end":[1025],"max":[1025],"min":[1025],"open":[1028],"showLabel":[516,"show-label"]},[[0,"startChanged","onStartChanged"],[0,"endChanged","onEndChanged"],[0,"dateRangeSet","onDateRangeSet"]]],[6,"smoothly-notifier",{"notices":[32]},[[0,"notice","onNotice"],[0,"remove","onRemove"]]],[1,"smoothly-picker",{"maxMenuHeight":[1,"max-menu-height"],"maxHeight":[1,"max-height"],"emptyMenuLabel":[1025,"empty-menu-label"],"multiple":[516],"optionStyle":[8,"option-style"],"options":[16],"labelSetting":[513,"label-setting"],"label":[513],"selections":[1040],"selectNoneName":[1025,"select-none-name"],"selectAllName":[1025,"select-all-name"],"selectionName":[1025,"selection-name"],"isOpen":[32]},[[0,"optionSelect","
|
|
18
|
+
return index.bootstrapLazy([["smoothly-google-font.cjs",[[2,"smoothly-google-font",{"value":[1]}]]],["smoothly-radio-group.cjs",[[4,"smoothly-radio-group",{"orientation":[513]}]]],["smoothly-reorder.cjs",[[0,"smoothly-reorder"]]],["smoothly-trigger-sink.cjs",[[6,"smoothly-trigger-sink",{"context":[16],"destination":[1],"filter":[1]},[[0,"trigger","TriggerListener"]]]]],["smoothly-trigger-source.cjs",[[6,"smoothly-trigger-source",{"listen":[1]}]]],["smoothly-accordion_51.cjs",[[0,"smoothly-app-demo",{"baseUrl":[1,"base-url"]}],[0,"smoothly-input-demo"],[2,"smoothly-select-demo",null,[[0,"selectionChanged","handleSelectionChanged"]]],[0,"smoothly-display-demo"],[2,"smoothly-table-demo"],[4,"smoothly-app",{"color":[1]}],[0,"smoothly-dialog-demo"],[2,"smoothly-icon-demo"],[6,"smoothly-button",{"color":[513],"expand":[513],"fill":[513],"disabled":[516],"type":[513],"link":[1],"download":[4]}],[4,"smoothly-room",{"label":[1],"icon":[1],"path":[1],"to":[1]}],[2,"smoothly-input-date-range",{"value":[1025],"start":[1025],"end":[1025],"max":[1025],"min":[1025],"open":[1028],"showLabel":[516,"show-label"]},[[0,"startChanged","onStartChanged"],[0,"endChanged","onEndChanged"],[0,"dateRangeSet","onDateRangeSet"]]],[6,"smoothly-notifier",{"notices":[32]},[[0,"notice","onNotice"],[0,"remove","onRemove"]]],[1,"smoothly-picker",{"maxMenuHeight":[1,"max-menu-height"],"maxHeight":[1,"max-height"],"emptyMenuLabel":[1025,"empty-menu-label"],"multiple":[516],"mutable":[4],"optionStyle":[8,"option-style"],"options":[16],"labelSetting":[513,"label-setting"],"label":[513],"selections":[1040],"selectNoneName":[1025,"select-none-name"],"selectAllName":[1025,"select-all-name"],"selectionName":[1025,"selection-name"],"newOptionLabel":[1025,"new-option-label"],"valueValidator":[16],"isOpen":[32],"empty":[32]},[[0,"optionSelect","optionSelectHandler"],[0,"optionAdd","optionAddHandler"],[0,"menuEmpty","emptyHandler"]]],[6,"smoothly-dialog",{"color":[513],"open":[1540],"closable":[516],"header":[513]},[[0,"trigger","TriggerListener"]]],[6,"smoothly-table-expandable-row",{"align":[1],"open":[1540]},[[0,"click","onClick"]]],[2,"smoothly-backtotop",{"opacity":[1],"bottom":[1],"right":[1],"visible":[32]}],[2,"smoothly-checkbox",{"selectAll":[4,"select-all"],"size":[1],"intermediate":[1540],"selected":[1540],"disabled":[1540],"t":[32]}],[6,"smoothly-submit",{"processing":[1540],"color":[513],"expand":[513],"fill":[513],"disabled":[516],"prevent":[4],"submit":[64]},[[0,"click","handleSubmit"]]],[6,"smoothly-table-expandable-cell",{"align":[1],"open":[1540]},[[0,"click","onClick"]]],[0,"smoothly-urlencoded",{"data":[1]}],[6,"smoothly-accordion",{"value":[1025]},[[0,"smoothlyOpen","handleOpenClose"],[0,"smoothlyClose","handleOpenClose"],[0,"smoothlyAccordionItemDidLoad","onAccordionItemDidLoad"],[0,"smoothlyAccordionItemDidUnload","onAccordionItemDidUnload"]]],[6,"smoothly-accordion-item",{"name":[1],"brand":[1],"open":[1540]}],[2,"smoothly-display",{"type":[1],"value":[8],"currency":[1],"country":[1]}],[2,"smoothly-display-amount",{"amount":[8],"currency":[1]}],[2,"smoothly-frame",{"url":[1],"name":[1],"origin":[1],"send":[64]}],[6,"smoothly-popup",{"visible":[1540],"direction":[1537],"cssVariables":[32]}],[6,"smoothly-quiet",{"color":[1]}],[6,"smoothly-radio",{"name":[1],"value":[1],"checked":[1540],"tabIndex":[2,"tab-index"]}],[6,"smoothly-select",{"identifier":[1],"background":[513],"value":[1025]}],[2,"smoothly-skeleton",{"widths":[16],"width":[1],"color":[1],"period":[2],"distance":[1],"align":[513]}],[2,"smoothly-svg",{"url":[513],"size":[513],"color":[1]}],[6,"smoothly-table",null,[[0,"expansionLoad","handleEvents"],[0,"expansionOpen","handleEvents"]]],[6,"smoothly-table-header",{"name":[1]}],[6,"smoothly-table-row",null,[[0,"expansionLoad","onExpansionLoad"],[0,"expansionOpen","onExpansionOpen"]]],[6,"smoothly-input-date",{"value":[1025],"open":[1028],"max":[1025],"min":[1025],"disabled":[1028]},[[0,"dateSet","dateSetHandler"]]],[1,"smoothly-menu-options",{"emptyMenuLabel":[1025,"empty-menu-label"],"newOptionLabel":[1,"new-option-label"],"maxMenuHeight":[1,"max-menu-height"],"order":[4],"optionStyle":[8,"option-style"],"options":[1040],"resetHighlightOnOptionsChange":[1028,"reset-highlight-on-options-change"],"mutable":[4],"filteredOptions":[32],"highlightIndex":[32],"keyword":[32],"moveHighlight":[64],"setHighlight":[64],"getHighlighted":[64],"filterOptions":[64]},[[0,"optionHover","optionHoverHandler"]]],[2,"smoothly-notification",{"notice":[16],"tick":[32]},[[0,"trigger","onTrigger"]]],[2,"smoothly-display-date-time",{"datetime":[1]}],[6,"smoothly-tab",{"label":[1],"open":[1540]},[[0,"click","onClick"]]],[6,"smoothly-tab-switch",{"selectedElement":[32]},[[0,"expansionOpen","openChanged"]]],[6,"smoothly-table-cell"],[0,"smoothly-tuple",{"tuple":[16]}],[1,"smoothly-option",{"aliases":[513],"dataHighlight":[1540,"data-highlight"],"name":[1537],"value":[1537],"divider":[1540],"new":[4]}],[2,"smoothly-spinner",{"active":[516],"size":[513]}],[2,"smoothly-calendar",{"month":[1025],"value":[1025],"start":[1025],"end":[1025],"max":[1025],"min":[1025],"doubleInput":[516,"double-input"],"firstSelected":[32]}],[6,"smoothly-input",{"name":[513],"value":[1032],"type":[513],"required":[1540],"minLength":[1026,"min-length"],"showLabel":[516,"show-label"],"maxLength":[1026,"max-length"],"autocomplete":[1028],"pattern":[1040],"placeholder":[1025],"disabled":[1028],"readonly":[1028],"currency":[513],"initialValue":[32],"getFormData":[64],"setKeepFocusOnReRender":[64],"setSelectionRange":[64]}],[2,"smoothly-input-month",{"value":[1025]}],[6,"smoothly-selector",{"opened":[32],"selectedElement":[32],"missing":[32],"filter":[32]},[[0,"click","onClick"],[0,"itemSelected","onItemSelected"],[0,"keydown","onKeyDown"]]],[6,"smoothly-item",{"value":[8],"selected":[1540],"filter":[64]},[[0,"click","onClick"]]],[6,"smoothly-trigger",{"color":[513],"expand":[513],"fill":[513],"disabled":[516],"type":[513],"name":[1],"value":[8]},[[0,"click","onClick"]]],[2,"smoothly-icon",{"color":[513],"fill":[513],"name":[1],"size":[513],"toolTip":[1,"tool-tip"],"document":[32]}]]]], options);
|
|
19
19
|
});
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { Component, Element, h, Host, Listen, Method, Prop, State, Watch } from "@stencil/core";
|
|
1
|
+
import { Component, Element, Event, h, Host, Listen, Method, Prop, State, Watch } from "@stencil/core";
|
|
2
2
|
export class SmoothlyMenuOptions {
|
|
3
3
|
constructor() {
|
|
4
4
|
this.filteredOptions = [];
|
|
5
5
|
this.highlightIndex = 0;
|
|
6
6
|
this.emptyMenuLabel = "No Options";
|
|
7
|
+
this.newOptionLabel = "Add:";
|
|
7
8
|
this.order = false;
|
|
8
9
|
this.options = [];
|
|
9
10
|
this.resetHighlightOnOptionsChange = true;
|
|
11
|
+
this.mutable = false;
|
|
10
12
|
}
|
|
11
13
|
optionsChangeHandler(newOptions) {
|
|
12
14
|
this.highlightIndex = this.resetHighlightOnOptionsChange ? 0 : this.highlightIndex;
|
|
@@ -45,6 +47,7 @@ export class SmoothlyMenuOptions {
|
|
|
45
47
|
return result;
|
|
46
48
|
}
|
|
47
49
|
async filterOptions(keyword, excludeValues = []) {
|
|
50
|
+
this.keyword = keyword;
|
|
48
51
|
const keywordLowercase = keyword.toLowerCase();
|
|
49
52
|
this.filteredOptions = [];
|
|
50
53
|
for (const option of this.options) {
|
|
@@ -52,6 +55,7 @@ export class SmoothlyMenuOptions {
|
|
|
52
55
|
const isVisible = names.toLowerCase().includes(keywordLowercase) && !excludeValues.includes(option.value);
|
|
53
56
|
isVisible && this.filteredOptions.push(option);
|
|
54
57
|
}
|
|
58
|
+
this.menuEmpty.emit(!this.filteredOptions.length);
|
|
55
59
|
this.order && this.sortOptions(keyword);
|
|
56
60
|
}
|
|
57
61
|
sortOptions(keyword) {
|
|
@@ -90,7 +94,11 @@ export class SmoothlyMenuOptions {
|
|
|
90
94
|
render() {
|
|
91
95
|
return (h(Host, { style: { "--max-menu-height": this.maxMenuHeight } }, this.filteredOptions.length > 0 ? (this.filteredOptions.map((option, index) => (h("smoothly-option", { style: this.optionStyle, ref: el => index == 0 && (this.firstOptionsElement = el !== null && el !== void 0 ? el : this.firstOptionsElement), value: option.value, name: option.name, divider: option.divider, "data-highlight": this.highlightIndex == index },
|
|
92
96
|
option.left ? h("div", { slot: "left" }, option.left) : undefined,
|
|
93
|
-
option.right ? h("div", { slot: "right" }, option.right) : undefined)))) : (h("
|
|
97
|
+
option.right ? h("div", { slot: "right" }, option.right) : undefined)))) : this.mutable ? (h("smoothly-option", { style: this.optionStyle, ref: el => (this.firstOptionsElement = el !== null && el !== void 0 ? el : this.firstOptionsElement), value: this.keyword, name: this.keyword, "data-highlight": 0, new: true },
|
|
98
|
+
h("div", { slot: "left" },
|
|
99
|
+
h("smoothly-icon", { name: "square-outline", size: "small" }),
|
|
100
|
+
" ",
|
|
101
|
+
this.newOptionLabel))) : (h("div", null, this.emptyMenuLabel))));
|
|
94
102
|
}
|
|
95
103
|
static get is() { return "smoothly-menu-options"; }
|
|
96
104
|
static get encapsulation() { return "shadow"; }
|
|
@@ -119,6 +127,24 @@ export class SmoothlyMenuOptions {
|
|
|
119
127
|
"reflect": false,
|
|
120
128
|
"defaultValue": "\"No Options\""
|
|
121
129
|
},
|
|
130
|
+
"newOptionLabel": {
|
|
131
|
+
"type": "string",
|
|
132
|
+
"mutable": false,
|
|
133
|
+
"complexType": {
|
|
134
|
+
"original": "string",
|
|
135
|
+
"resolved": "string",
|
|
136
|
+
"references": {}
|
|
137
|
+
},
|
|
138
|
+
"required": false,
|
|
139
|
+
"optional": false,
|
|
140
|
+
"docs": {
|
|
141
|
+
"tags": [],
|
|
142
|
+
"text": ""
|
|
143
|
+
},
|
|
144
|
+
"attribute": "new-option-label",
|
|
145
|
+
"reflect": false,
|
|
146
|
+
"defaultValue": "\"Add:\""
|
|
147
|
+
},
|
|
122
148
|
"maxMenuHeight": {
|
|
123
149
|
"type": "string",
|
|
124
150
|
"mutable": false,
|
|
@@ -209,12 +235,47 @@ export class SmoothlyMenuOptions {
|
|
|
209
235
|
"attribute": "reset-highlight-on-options-change",
|
|
210
236
|
"reflect": false,
|
|
211
237
|
"defaultValue": "true"
|
|
238
|
+
},
|
|
239
|
+
"mutable": {
|
|
240
|
+
"type": "boolean",
|
|
241
|
+
"mutable": false,
|
|
242
|
+
"complexType": {
|
|
243
|
+
"original": "boolean",
|
|
244
|
+
"resolved": "boolean",
|
|
245
|
+
"references": {}
|
|
246
|
+
},
|
|
247
|
+
"required": false,
|
|
248
|
+
"optional": false,
|
|
249
|
+
"docs": {
|
|
250
|
+
"tags": [],
|
|
251
|
+
"text": ""
|
|
252
|
+
},
|
|
253
|
+
"attribute": "mutable",
|
|
254
|
+
"reflect": false,
|
|
255
|
+
"defaultValue": "false"
|
|
212
256
|
}
|
|
213
257
|
}; }
|
|
214
258
|
static get states() { return {
|
|
215
259
|
"filteredOptions": {},
|
|
216
|
-
"highlightIndex": {}
|
|
260
|
+
"highlightIndex": {},
|
|
261
|
+
"keyword": {}
|
|
217
262
|
}; }
|
|
263
|
+
static get events() { return [{
|
|
264
|
+
"method": "menuEmpty",
|
|
265
|
+
"name": "menuEmpty",
|
|
266
|
+
"bubbles": true,
|
|
267
|
+
"cancelable": true,
|
|
268
|
+
"composed": true,
|
|
269
|
+
"docs": {
|
|
270
|
+
"tags": [],
|
|
271
|
+
"text": ""
|
|
272
|
+
},
|
|
273
|
+
"complexType": {
|
|
274
|
+
"original": "boolean",
|
|
275
|
+
"resolved": "boolean",
|
|
276
|
+
"references": {}
|
|
277
|
+
}
|
|
278
|
+
}]; }
|
|
218
279
|
static get methods() { return {
|
|
219
280
|
"moveHighlight": {
|
|
220
281
|
"complexType": {
|
|
@@ -9,7 +9,9 @@ export class SmoothlyOption {
|
|
|
9
9
|
}
|
|
10
10
|
onSelect(event) {
|
|
11
11
|
if (this.value)
|
|
12
|
-
this.
|
|
12
|
+
this.new
|
|
13
|
+
? this.optionAdd.emit({ name: this.name, value: this.value })
|
|
14
|
+
: this.optionSelect.emit({ name: this.name, value: this.value });
|
|
13
15
|
else
|
|
14
16
|
throw `smoothly-option ${this.element.innerHTML} lacks value-property and can therefore not be selected`;
|
|
15
17
|
}
|
|
@@ -114,6 +116,23 @@ export class SmoothlyOption {
|
|
|
114
116
|
"attribute": "divider",
|
|
115
117
|
"reflect": true,
|
|
116
118
|
"defaultValue": "false"
|
|
119
|
+
},
|
|
120
|
+
"new": {
|
|
121
|
+
"type": "boolean",
|
|
122
|
+
"mutable": false,
|
|
123
|
+
"complexType": {
|
|
124
|
+
"original": "boolean",
|
|
125
|
+
"resolved": "boolean | undefined",
|
|
126
|
+
"references": {}
|
|
127
|
+
},
|
|
128
|
+
"required": false,
|
|
129
|
+
"optional": true,
|
|
130
|
+
"docs": {
|
|
131
|
+
"tags": [],
|
|
132
|
+
"text": ""
|
|
133
|
+
},
|
|
134
|
+
"attribute": "new",
|
|
135
|
+
"reflect": false
|
|
117
136
|
}
|
|
118
137
|
}; }
|
|
119
138
|
static get events() { return [{
|
|
@@ -146,6 +165,21 @@ export class SmoothlyOption {
|
|
|
146
165
|
"resolved": "{ value: any; name: string; }",
|
|
147
166
|
"references": {}
|
|
148
167
|
}
|
|
168
|
+
}, {
|
|
169
|
+
"method": "optionAdd",
|
|
170
|
+
"name": "optionAdd",
|
|
171
|
+
"bubbles": true,
|
|
172
|
+
"cancelable": true,
|
|
173
|
+
"composed": true,
|
|
174
|
+
"docs": {
|
|
175
|
+
"tags": [],
|
|
176
|
+
"text": ""
|
|
177
|
+
},
|
|
178
|
+
"complexType": {
|
|
179
|
+
"original": "{ name: string; value: string }",
|
|
180
|
+
"resolved": "{ name: string; value: string; }",
|
|
181
|
+
"references": {}
|
|
182
|
+
}
|
|
149
183
|
}]; }
|
|
150
184
|
static get elementRef() { return "element"; }
|
|
151
185
|
}
|