smoothly 0.2.11 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/smoothly-accordion_50.cjs.entry.js +41 -30
  3. package/dist/cjs/smoothly.cjs.js +1 -1
  4. package/dist/collection/components/app-demo/index.js +10 -10
  5. package/dist/collection/components/display-amount/index.js +22 -1
  6. package/dist/collection/components/display-demo/index.js +9 -0
  7. package/dist/collection/components/menu-options/index.js +31 -10
  8. package/dist/collection/components/option/index.js +81 -6
  9. package/dist/collection/components/option/style.css +31 -35
  10. package/dist/collection/components/picker/index.js +26 -21
  11. package/dist/collection/components/select-demo/index.js +4 -4
  12. package/dist/collection/components/skeleton/index.js +1 -1
  13. package/dist/collection/model/{OptionType.js → Option.js} +0 -0
  14. package/dist/custom-elements/index.js +46 -35
  15. package/dist/esm/loader.js +1 -1
  16. package/dist/esm/smoothly-accordion_50.entry.js +41 -30
  17. package/dist/esm/smoothly.js +1 -1
  18. package/dist/smoothly/p-b92b1eb7.entry.js +1 -0
  19. package/dist/smoothly/smoothly.esm.js +1 -1
  20. package/dist/types/components/display-amount/index.d.ts +1 -0
  21. package/dist/types/components/menu-options/index.d.ts +10 -6
  22. package/dist/types/components/option/index.d.ts +7 -0
  23. package/dist/types/components/picker/index.d.ts +11 -10
  24. package/dist/types/components.d.ts +22 -11
  25. package/dist/types/index.d.ts +1 -1
  26. package/dist/types/model/Option.d.ts +7 -0
  27. package/dist/types/model/index.d.ts +1 -1
  28. package/package.json +1 -1
  29. package/dist/smoothly/p-956089d5.entry.js +0 -1
  30. package/dist/types/model/OptionType.d.ts +0 -8
@@ -3,28 +3,35 @@ export class SmoothlyOption {
3
3
  constructor() {
4
4
  this.dataHighlight = false;
5
5
  this.divider = false;
6
+ this.toggle = false;
7
+ this.checked = false;
6
8
  }
7
9
  onHover(event) {
8
10
  this.optionHover.emit({ name: this.name, value: this.value });
9
11
  }
10
12
  onSelect(event) {
11
- if (this.value)
13
+ if (this.value) {
12
14
  this.new
13
15
  ? this.optionAdd.emit({ name: this.name, value: this.value })
14
- : this.optionSelect.emit({ name: this.name, value: this.value });
16
+ : !this.toggle || (this.toggle && !this.checked)
17
+ ? this.optionSelect.emit({ name: this.name, value: this.value })
18
+ : this.optionUnselect.emit({ name: this.name, value: this.value });
19
+ this.toggle && (this.checked = !this.checked);
20
+ }
15
21
  else
16
22
  throw `smoothly-option ${this.element.innerHTML} lacks value-property and can therefore not be selected`;
17
23
  }
18
24
  render() {
19
25
  return (h(Host, { onMouseDown: (e) => this.onSelect(e), onMouseOver: (e) => this.onHover(e) },
20
- h("slot", { name: "left" }),
21
- h("div", { class: "middle" }, this.name),
22
- h("slot", { name: "right" })));
26
+ this.toggle && h("smoothly-icon", { name: this.checked ? "checkbox" : "square-outline" }),
27
+ h("div", { class: "name" }, this.name),
28
+ h("smoothly-quiet", null,
29
+ h("slot", { name: "hint" }))));
23
30
  }
24
31
  static get is() { return "smoothly-option"; }
25
32
  static get encapsulation() { return "shadow"; }
26
33
  static get originalStyleUrls() { return {
27
- "$": ["style.scss"]
34
+ "$": ["style.css"]
28
35
  }; }
29
36
  static get styleUrls() { return {
30
37
  "$": ["style.css"]
@@ -117,6 +124,23 @@ export class SmoothlyOption {
117
124
  "reflect": true,
118
125
  "defaultValue": "false"
119
126
  },
127
+ "checkbox": {
128
+ "type": "boolean",
129
+ "mutable": false,
130
+ "complexType": {
131
+ "original": "boolean",
132
+ "resolved": "boolean",
133
+ "references": {}
134
+ },
135
+ "required": false,
136
+ "optional": false,
137
+ "docs": {
138
+ "tags": [],
139
+ "text": ""
140
+ },
141
+ "attribute": "checkbox",
142
+ "reflect": false
143
+ },
120
144
  "new": {
121
145
  "type": "boolean",
122
146
  "mutable": false,
@@ -133,6 +157,42 @@ export class SmoothlyOption {
133
157
  },
134
158
  "attribute": "new",
135
159
  "reflect": false
160
+ },
161
+ "toggle": {
162
+ "type": "boolean",
163
+ "mutable": false,
164
+ "complexType": {
165
+ "original": "boolean",
166
+ "resolved": "boolean",
167
+ "references": {}
168
+ },
169
+ "required": false,
170
+ "optional": false,
171
+ "docs": {
172
+ "tags": [],
173
+ "text": ""
174
+ },
175
+ "attribute": "toggle",
176
+ "reflect": false,
177
+ "defaultValue": "false"
178
+ },
179
+ "checked": {
180
+ "type": "boolean",
181
+ "mutable": true,
182
+ "complexType": {
183
+ "original": "boolean",
184
+ "resolved": "boolean",
185
+ "references": {}
186
+ },
187
+ "required": false,
188
+ "optional": false,
189
+ "docs": {
190
+ "tags": [],
191
+ "text": ""
192
+ },
193
+ "attribute": "checked",
194
+ "reflect": false,
195
+ "defaultValue": "false"
136
196
  }
137
197
  }; }
138
198
  static get events() { return [{
@@ -165,6 +225,21 @@ export class SmoothlyOption {
165
225
  "resolved": "{ value: any; name: string; }",
166
226
  "references": {}
167
227
  }
228
+ }, {
229
+ "method": "optionUnselect",
230
+ "name": "optionUnselect",
231
+ "bubbles": true,
232
+ "cancelable": true,
233
+ "composed": true,
234
+ "docs": {
235
+ "tags": [],
236
+ "text": ""
237
+ },
238
+ "complexType": {
239
+ "original": "{ value: any; name: string }",
240
+ "resolved": "{ value: any; name: string; }",
241
+ "references": {}
242
+ }
168
243
  }, {
169
244
  "method": "optionAdd",
170
245
  "name": "optionAdd",
@@ -1,46 +1,42 @@
1
1
  :host {
2
- display: flex;
3
- flex-direction: row;
4
- align-items: center;
5
- justify-content: flex-start;
6
- padding: 0.7em 1em;
7
- margin-left: 1px;
8
- margin-right: 1px;
9
- background-color: transparent;
10
- position: relative;
2
+ display: flex;
3
+ flex-direction: row;
4
+ align-items: center;
5
+ justify-content: flex-start;
6
+ padding: 0.7em 1em;
7
+ margin-left: 1px;
8
+ margin-right: 1px;
9
+ background-color: transparent;
10
+ position: relative;
11
11
  }
12
-
13
12
  :host([data-highlight]) {
14
- background-color: rgb(var(--smoothly-default-shade));
13
+ background-color: rgb(var(--smoothly-default-shade));
15
14
  }
16
-
17
- :host > div.middle {
18
- padding-left: 0.5em;
19
- flex-shrink: 1;
20
- width: 100%;
15
+ :host > div.name {
16
+ padding-left: 0.5em;
17
+ flex-shrink: 1;
18
+ width: 100%;
21
19
  }
22
-
23
20
  :host([divider]) {
24
- margin-bottom: 0.5em;
21
+ margin-bottom: 0.5em;
25
22
  }
26
-
27
23
  ::slotted([slot=right]) {
28
- font-style: italic;
29
- white-space: nowrap;
24
+ font-style: italic;
25
+ white-space: nowrap;
30
26
  }
31
-
32
27
  :host([divider])::after {
33
- position: absolute;
34
- height: 1px;
35
- width: 100%;
36
- left: 0;
37
- bottom: -0.25em;
38
- content: "";
39
- background-color: rgba(var(--smoothly-dark-color));
28
+ position: absolute;
29
+ height: 1px;
30
+ width: 100%;
31
+ left: 0;
32
+ bottom: -0.25em;
33
+ content: "";
34
+ background-color: rgba(var(--smoothly-dark-color));
35
+ }
36
+ ::slotted([slot=hint]) {
37
+ display: flex;
38
+ align-items: center;
39
+ gap: 1ch;
40
+ font-style: italic;
41
+ white-space: nowrap;
40
42
  }
41
-
42
- ::slotted([slot=left]) {
43
- display: flex;
44
- align-items: center;
45
- gap: 1ch;
46
- }
@@ -4,6 +4,7 @@ export class SmoothlyPicker {
4
4
  this.keepFocusOnReRender = false;
5
5
  this.disabled = false;
6
6
  this.readonly = false;
7
+ this.maxMenuHeight = "inherit";
7
8
  this.emptyMenuLabel = "No Options";
8
9
  this.multiple = false;
9
10
  this.mutable = false;
@@ -140,17 +141,14 @@ export class SmoothlyPicker {
140
141
  this.isOpen = false;
141
142
  this.filterOptions();
142
143
  }
143
- getCheckHtml(checked) {
144
- return checked ? (h("smoothly-icon", { name: "checkbox", size: "small" })) : (h("smoothly-icon", { name: "square-outline", size: "small" }));
145
- }
146
144
  render() {
147
- var _a, _b, _c, _d;
145
+ var _a, _b, _c;
148
146
  const cssVariables = {
149
147
  "--max-height": (_a = this.maxHeight) !== null && _a !== void 0 ? _a : "inherit",
150
148
  "--label-display": this.labelSetting == "hide" ? "none" : "absolute",
151
149
  };
152
150
  (_b = this.options) === null || _b === void 0 ? void 0 : _b.forEach(o => {
153
- o.left = this.getCheckHtml(this.selections.map(s => s.value).includes(o.value));
151
+ o.checked = this.selections.map(s => s.value).includes(o.value);
154
152
  });
155
153
  const options = [
156
154
  ...(this.multiple
@@ -158,12 +156,12 @@ export class SmoothlyPicker {
158
156
  {
159
157
  value: "select-none",
160
158
  name: this.selections.length == this.options.length ? this.selectNoneName : this.selectAllName,
161
- left: this.getCheckHtml(this.selections.length == ((_c = this.options) === null || _c === void 0 ? void 0 : _c.length)),
159
+ checked: this.selections.length == this.options.length,
162
160
  divider: true,
163
161
  },
164
162
  ]
165
163
  : []),
166
- ...((_d = this.options) !== null && _d !== void 0 ? _d : []),
164
+ ...((_c = this.options) !== null && _c !== void 0 ? _c : []),
167
165
  ];
168
166
  return (h(Host, { style: cssVariables, "has-selection": this.selections.length > 0, "is-open": this.isOpen ? "" : undefined, onMouseDown: (e) => e.preventDefault(), onClick: () => this.onClick() },
169
167
  h("div", null,
@@ -174,7 +172,7 @@ export class SmoothlyPicker {
174
172
  : this.selections.map(selection => selection.name).join(", "), onKeyDown: e => this.onKeyDown(e), onInput: (e) => this.onInput(e) }),
175
173
  h("smoothly-icon", { part: "chevron", class: "down", name: "chevron-down", size: "tiny" }),
176
174
  h("smoothly-icon", { part: "chevron", class: "up", name: "chevron-up", size: "tiny" })),
177
- h("smoothly-menu-options", { part: "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 })));
175
+ h("smoothly-menu-options", { part: "menu-options", style: { width: "100%" }, toggle: true, 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 })));
178
176
  }
179
177
  static get is() { return "smoothly-picker"; }
180
178
  static get encapsulation() { return "shadow"; }
@@ -225,8 +223,8 @@ export class SmoothlyPicker {
225
223
  "type": "string",
226
224
  "mutable": false,
227
225
  "complexType": {
228
- "original": "\"inherit\"",
229
- "resolved": "\"inherit\"",
226
+ "original": "string",
227
+ "resolved": "string",
230
228
  "references": {}
231
229
  },
232
230
  "required": false,
@@ -236,7 +234,8 @@ export class SmoothlyPicker {
236
234
  "text": ""
237
235
  },
238
236
  "attribute": "max-menu-height",
239
- "reflect": false
237
+ "reflect": false,
238
+ "defaultValue": "\"inherit\""
240
239
  },
241
240
  "maxHeight": {
242
241
  "type": "string",
@@ -328,12 +327,12 @@ export class SmoothlyPicker {
328
327
  },
329
328
  "options": {
330
329
  "type": "unknown",
331
- "mutable": false,
330
+ "mutable": true,
332
331
  "complexType": {
333
- "original": "OptionType[]",
334
- "resolved": "OptionType[]",
332
+ "original": "(Option & { checked?: boolean })[]",
333
+ "resolved": "(Option & { checked?: boolean | undefined; })[]",
335
334
  "references": {
336
- "OptionType": {
335
+ "Option": {
337
336
  "location": "import",
338
337
  "path": "../../model"
339
338
  }
@@ -385,10 +384,10 @@ export class SmoothlyPicker {
385
384
  "type": "unknown",
386
385
  "mutable": true,
387
386
  "complexType": {
388
- "original": "OptionType[]",
389
- "resolved": "OptionType[]",
387
+ "original": "Option[]",
388
+ "resolved": "Option[]",
390
389
  "references": {
391
- "OptionType": {
390
+ "Option": {
392
391
  "location": "import",
393
392
  "path": "../../model"
394
393
  }
@@ -511,10 +510,10 @@ export class SmoothlyPicker {
511
510
  "text": ""
512
511
  },
513
512
  "complexType": {
514
- "original": "OptionType[]",
515
- "resolved": "OptionType[]",
513
+ "original": "Option[]",
514
+ "resolved": "Option[]",
516
515
  "references": {
517
- "OptionType": {
516
+ "Option": {
518
517
  "location": "import",
519
518
  "path": "../../model"
520
519
  }
@@ -552,6 +551,12 @@ export class SmoothlyPicker {
552
551
  "target": undefined,
553
552
  "capture": false,
554
553
  "passive": false
554
+ }, {
555
+ "name": "optionUnselect",
556
+ "method": "optionSelectHandler",
557
+ "target": undefined,
558
+ "capture": false,
559
+ "passive": false
555
560
  }, {
556
561
  "name": "optionAdd",
557
562
  "method": "optionAddHandler",
@@ -50,11 +50,11 @@ export class SmoothlySelectDemo {
50
50
  h("smoothly-item", { value: "11" }, "November"),
51
51
  h("smoothly-item", { value: "12" }, "December")),
52
52
  h("button", { onClick: () => this.alertf() }, "press here"),
53
- h("smoothly-picker", { label: "Filter", "empty-menu-label": "Sorry, we're out of options.", "max-height": "58px", multiple: true, options: [
53
+ h("smoothly-picker", { label: "Filter", "empty-menu-label": "Sorry, we're out of options.", "max-height": "58px", maxMenuHeight: "20rem", multiple: true, options: [
54
54
  { name: "Big Dog", value: "dog", aliases: ["WOFF"] },
55
- { name: "Cat Stevens", value: "cat", aliases: ["moew"] },
55
+ { name: "Cat Stevens", value: "cat", aliases: ["moew"], hint: "moew" },
56
56
  { name: "Noble Pig", value: "pig" },
57
- { name: "Turtle Wax", value: "turtle" },
57
+ { name: "Turtle Wax", value: "turtle", hint: "slow" },
58
58
  { name: "Spider Man", value: "spider" },
59
59
  { name: "Phoenix Order Long Wooord", value: "phoenix" },
60
60
  { name: "Horse Back", value: "horse" },
@@ -86,7 +86,7 @@ export class SmoothlySelectDemo {
86
86
  ], valueValidator: (email) => email.match(/^\w+@\w+/) ? [true, undefined] : [false, Notice.failed("Incorrectly formatted email")] }),
87
87
  h("br", null),
88
88
  h("smoothly-picker", { label: "Single select", multiple: false, "max-menu-height": "200px", options: [
89
- { name: "Dog", value: "dog", aliases: ["WOFF"], right: "Woof 🐶" },
89
+ { name: "Dog", value: "dog", aliases: ["WOFF"], hint: "Woof 🐶" },
90
90
  { name: "Cat", value: "cat", aliases: ["moew"] },
91
91
  { name: "Pig", value: "pig" },
92
92
  { name: "Turtle", value: "turtle" },
@@ -40,7 +40,7 @@ export class SmoothlySkeleton {
40
40
  },
41
41
  "width": {
42
42
  "type": "string",
43
- "mutable": false,
43
+ "mutable": true,
44
44
  "complexType": {
45
45
  "original": "string",
46
46
  "resolved": "string",