smoothly 0.2.2 → 0.2.5

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_51.cjs.entry.js +71 -25
  3. package/dist/cjs/smoothly.cjs.js +1 -1
  4. package/dist/collection/components/menu-options/index.js +64 -3
  5. package/dist/collection/components/option/index.js +35 -1
  6. package/dist/collection/components/option/style.css +6 -0
  7. package/dist/collection/components/picker/index.js +149 -11
  8. package/dist/collection/components/select-demo/index.js +9 -1
  9. package/dist/collection/components/tab/style.css +7 -11
  10. package/dist/collection/components/tab-switch/style.css +2 -1
  11. package/dist/collection/components/table/cell/style.css +2 -2
  12. package/dist/collection/components/table/demo/index.js +11 -9
  13. package/dist/collection/components/table/expandable/cell/index.js +3 -2
  14. package/dist/collection/components/table/expandable/cell/style.css +22 -26
  15. package/dist/collection/components/table/expandable/row/index.js +1 -1
  16. package/dist/collection/components/table/expandable/row/style.css +26 -25
  17. package/dist/collection/components/table/header/style.css +0 -1
  18. package/dist/collection/components/table/row/style.css +1 -1
  19. package/dist/collection/components/table/style.css +3 -8
  20. package/dist/custom-elements/index.js +74 -28
  21. package/dist/esm/loader.js +1 -1
  22. package/dist/esm/smoothly-accordion_51.entry.js +71 -25
  23. package/dist/esm/smoothly.js +1 -1
  24. package/dist/smoothly/{p-9d6a20c4.entry.js → p-332b1c90.entry.js} +1 -1
  25. package/dist/smoothly/smoothly.esm.js +1 -1
  26. package/dist/types/components/menu-options/index.d.ts +5 -0
  27. package/dist/types/components/option/index.d.ts +5 -0
  28. package/dist/types/components/picker/index.d.ts +14 -3
  29. package/dist/types/components.d.ts +17 -0
  30. package/package.json +1 -1
@@ -4,12 +4,16 @@ export class SmoothlyPicker {
4
4
  this.keepFocusOnReRender = false;
5
5
  this.emptyMenuLabel = "No Options";
6
6
  this.multiple = false;
7
+ this.mutable = false;
7
8
  this.options = [];
8
9
  this.selections = [];
9
10
  this.selectNoneName = "Select None";
11
+ this.selectAllName = "Select All";
10
12
  this.selectionName = "items selected";
13
+ this.newOptionLabel = "Add:";
14
+ this.valueValidator = _ => [true, undefined];
11
15
  }
12
- isOpenChangeHander() {
16
+ isOpenChangeHandler() {
13
17
  if (this.isOpen == false) {
14
18
  this.menuClose.emit(this.selections);
15
19
  }
@@ -21,10 +25,26 @@ export class SmoothlyPicker {
21
25
  this.keepFocusOnReRender = false;
22
26
  }
23
27
  }
24
- optionSelectHander(event) {
28
+ optionSelectHandler(event) {
25
29
  this.toggle(event.detail);
26
30
  event.stopPropagation();
27
31
  }
32
+ optionAddHandler(event) {
33
+ if (this.mutable) {
34
+ const [status, notice] = this.valueValidator(event.detail.value);
35
+ if (status) {
36
+ const option = Object.assign({}, event.detail);
37
+ this.options = [...this.options, option];
38
+ this.select(option);
39
+ }
40
+ notice && this.notice.emit(notice);
41
+ }
42
+ event.stopPropagation();
43
+ }
44
+ emptyHandler(event) {
45
+ this.empty = event.detail;
46
+ event.stopPropagation();
47
+ }
28
48
  toggle(option) {
29
49
  option.value == "select-none"
30
50
  ? this.toggleAll()
@@ -59,9 +79,19 @@ export class SmoothlyPicker {
59
79
  }
60
80
  toggleHighlighted() {
61
81
  var _a;
62
- (_a = this.menuElement) === null || _a === void 0 ? void 0 : _a.getHighlighted().then((result) => {
63
- result && this.toggle(result);
64
- });
82
+ if (this.mutable && this.empty) {
83
+ const [status, notice] = this.valueValidator(this.inputElement.value);
84
+ if (status) {
85
+ const option = { name: this.inputElement.value, value: this.inputElement.value };
86
+ this.options = [...this.options, option];
87
+ this.select(option);
88
+ }
89
+ notice && this.notice.emit(notice);
90
+ }
91
+ else
92
+ (_a = this.menuElement) === null || _a === void 0 ? void 0 : _a.getHighlighted().then((result) => {
93
+ result && this.toggle(result);
94
+ });
65
95
  }
66
96
  highlightDefault() {
67
97
  var _a;
@@ -123,7 +153,7 @@ export class SmoothlyPicker {
123
153
  ? [
124
154
  {
125
155
  value: "select-none",
126
- name: this.selectNoneName,
156
+ name: this.selections.length == this.options.length ? this.selectNoneName : this.selectAllName,
127
157
  left: this.getCheckHtml(this.selections.length == ((_c = this.options) === null || _c === void 0 ? void 0 : _c.length)),
128
158
  divider: true,
129
159
  },
@@ -140,7 +170,7 @@ export class SmoothlyPicker {
140
170
  : this.selections.map(selection => selection.name).join(", "), onKeyDown: e => this.onKeyDown(e), onInput: (e) => this.onInput(e) }),
141
171
  h("smoothly-icon", { class: "down", name: "chevron-down", size: "tiny" }),
142
172
  h("smoothly-icon", { class: "up", name: "chevron-up", size: "tiny" })),
143
- 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 })));
173
+ 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 })));
144
174
  }
145
175
  static get is() { return "smoothly-picker"; }
146
176
  static get encapsulation() { return "shadow"; }
@@ -221,6 +251,24 @@ export class SmoothlyPicker {
221
251
  "reflect": true,
222
252
  "defaultValue": "false"
223
253
  },
254
+ "mutable": {
255
+ "type": "boolean",
256
+ "mutable": false,
257
+ "complexType": {
258
+ "original": "boolean",
259
+ "resolved": "boolean",
260
+ "references": {}
261
+ },
262
+ "required": false,
263
+ "optional": false,
264
+ "docs": {
265
+ "tags": [],
266
+ "text": ""
267
+ },
268
+ "attribute": "mutable",
269
+ "reflect": false,
270
+ "defaultValue": "false"
271
+ },
224
272
  "optionStyle": {
225
273
  "type": "any",
226
274
  "mutable": false,
@@ -332,6 +380,24 @@ export class SmoothlyPicker {
332
380
  "reflect": false,
333
381
  "defaultValue": "\"Select None\""
334
382
  },
383
+ "selectAllName": {
384
+ "type": "string",
385
+ "mutable": true,
386
+ "complexType": {
387
+ "original": "string",
388
+ "resolved": "string",
389
+ "references": {}
390
+ },
391
+ "required": false,
392
+ "optional": false,
393
+ "docs": {
394
+ "tags": [],
395
+ "text": ""
396
+ },
397
+ "attribute": "select-all-name",
398
+ "reflect": false,
399
+ "defaultValue": "\"Select All\""
400
+ },
335
401
  "selectionName": {
336
402
  "type": "string",
337
403
  "mutable": true,
@@ -349,10 +415,50 @@ export class SmoothlyPicker {
349
415
  "attribute": "selection-name",
350
416
  "reflect": false,
351
417
  "defaultValue": "\"items selected\""
418
+ },
419
+ "newOptionLabel": {
420
+ "type": "string",
421
+ "mutable": true,
422
+ "complexType": {
423
+ "original": "string",
424
+ "resolved": "string",
425
+ "references": {}
426
+ },
427
+ "required": false,
428
+ "optional": false,
429
+ "docs": {
430
+ "tags": [],
431
+ "text": ""
432
+ },
433
+ "attribute": "new-option-label",
434
+ "reflect": false,
435
+ "defaultValue": "\"Add:\""
436
+ },
437
+ "valueValidator": {
438
+ "type": "unknown",
439
+ "mutable": false,
440
+ "complexType": {
441
+ "original": "(value: any) => [boolean, Notice | undefined]",
442
+ "resolved": "(value: any) => [boolean, Notice | undefined]",
443
+ "references": {
444
+ "Notice": {
445
+ "location": "import",
446
+ "path": "../../model"
447
+ }
448
+ }
449
+ },
450
+ "required": false,
451
+ "optional": false,
452
+ "docs": {
453
+ "tags": [],
454
+ "text": ""
455
+ },
456
+ "defaultValue": "_ => [true, undefined]"
352
457
  }
353
458
  }; }
354
459
  static get states() { return {
355
- "isOpen": {}
460
+ "isOpen": {},
461
+ "empty": {}
356
462
  }; }
357
463
  static get events() { return [{
358
464
  "method": "menuClose",
@@ -374,18 +480,50 @@ export class SmoothlyPicker {
374
480
  }
375
481
  }
376
482
  }
483
+ }, {
484
+ "method": "notice",
485
+ "name": "notice",
486
+ "bubbles": true,
487
+ "cancelable": true,
488
+ "composed": true,
489
+ "docs": {
490
+ "tags": [],
491
+ "text": ""
492
+ },
493
+ "complexType": {
494
+ "original": "Notice",
495
+ "resolved": "Notice",
496
+ "references": {
497
+ "Notice": {
498
+ "location": "import",
499
+ "path": "../../model"
500
+ }
501
+ }
502
+ }
377
503
  }]; }
378
504
  static get elementRef() { return "element"; }
379
505
  static get watchers() { return [{
380
506
  "propName": "selections",
381
- "methodName": "isOpenChangeHander"
507
+ "methodName": "isOpenChangeHandler"
382
508
  }, {
383
509
  "propName": "isOpen",
384
- "methodName": "isOpenChangeHander"
510
+ "methodName": "isOpenChangeHandler"
385
511
  }]; }
386
512
  static get listeners() { return [{
387
513
  "name": "optionSelect",
388
- "method": "optionSelectHander",
514
+ "method": "optionSelectHandler",
515
+ "target": undefined,
516
+ "capture": false,
517
+ "passive": false
518
+ }, {
519
+ "name": "optionAdd",
520
+ "method": "optionAddHandler",
521
+ "target": undefined,
522
+ "capture": false,
523
+ "passive": false
524
+ }, {
525
+ "name": "menuEmpty",
526
+ "method": "emptyHandler",
389
527
  "target": undefined,
390
528
  "capture": false,
391
529
  "passive": false
@@ -1,4 +1,5 @@
1
1
  import { Component, h, Listen } from "@stencil/core";
2
+ import { Notice } from "../../model";
2
3
  export class SmoothlySelectDemo {
3
4
  constructor() {
4
5
  this.currencies = ["SEK", "EUR"];
@@ -63,7 +64,7 @@ export class SmoothlySelectDemo {
63
64
  { name: "Scary Kraken", value: "kraken" },
64
65
  ] }),
65
66
  h("br", null),
66
- h("smoothly-picker", { label: "", "empty-menu-label": "Sorry, we're out of options.", "max-height": "58px", multiple: true, options: [
67
+ h("smoothly-picker", { label: "Multiple", "empty-menu-label": "Sorry, we're out of options.", "max-height": "58px", multiple: true, options: [
67
68
  { name: "Big Dog", value: "dog", aliases: ["WOFF"] },
68
69
  { name: "Cat Stevens", value: "cat", aliases: ["moew"] },
69
70
  { name: "Noble Pig", value: "pig" },
@@ -77,6 +78,13 @@ export class SmoothlySelectDemo {
77
78
  { name: "Scary Kraken", value: "kraken" },
78
79
  ] }),
79
80
  h("br", null),
81
+ h("smoothly-picker", { label: "Multiple mutable", "max-height": "58px", multiple: true, mutable: true, newOptionLabel: "Invite:", options: [
82
+ { name: "john@example.com", value: "john@example.com" },
83
+ { name: "jane@example.com", value: "jane@example.com" },
84
+ { name: "james@example.com", value: "james@example.com" },
85
+ { name: "jessie@example.com", value: "jessie@example.com" },
86
+ ], valueValidator: (email) => email.match(/^\w+@\w+/) ? [true, undefined] : [false, Notice.failed("Incorrectly formatted email")] }),
87
+ h("br", null),
80
88
  h("smoothly-picker", { label: "Single select", multiple: false, "max-menu-height": "200px", options: [
81
89
  { name: "Dog", value: "dog", aliases: ["WOFF"], right: "Woof 🐶" },
82
90
  { name: "Cat", value: "cat", aliases: ["moew"] },
@@ -1,18 +1,14 @@
1
- :host:not([open]) > label {
2
- background-color: rgb(var(--smoothly-dark-shade));
1
+ :host([open]) {
2
+ border-bottom: 3px solid rgb(var(--smoothly-primary-color));
3
+ box-sizing: border-box;
4
+ margin-bottom: -3px;
3
5
  }
4
6
  .hide {
5
7
  display: none;
6
8
  }
7
9
  label {
8
10
  display: block;
9
- padding: 1em;
10
- background-color: rgb(var(--smoothly-default-shade));
11
- border-top-left-radius: 0.3rem;
12
- border-top-right-radius: 0.3rem;
13
- width: 6.25rem;
14
- }
15
- div {
16
- background-color: rgb(var(--smoothly-default-shade));
17
- padding: 1em;
11
+ padding: .5rem;
12
+ background-color: transparent;
13
+ width: auto;
18
14
  }
@@ -1,5 +1,6 @@
1
1
  :host {
2
2
  display: flex;
3
3
  flex-direction: row;
4
- margin: 1em 1em 0em 0em;
4
+ justify-content: space-around;
5
+ border-bottom: 3px solid rgb(var(--smoothly-default-shade));
5
6
  }
@@ -1,6 +1,6 @@
1
1
  :host {
2
2
  display: table-cell;
3
- vertical-align: middle;
4
3
  line-height: 1.5rem;
5
- padding: 0.2rem 0 0.2rem 1rem;
4
+ white-space: nowrap;
5
+ padding: 0.3rem 0 0.3rem 1rem;
6
6
  }
@@ -7,8 +7,7 @@ export class TableDemo {
7
7
  h("smoothly-table-header", null, "Header A"),
8
8
  h("smoothly-table-header", null, "Header B"),
9
9
  h("smoothly-table-header", null, "Header C"),
10
- h("smoothly-table-header", null, "Header D"),
11
- h("smoothly-table-header", null)),
10
+ h("smoothly-table-header", null, "Header D")),
12
11
  h("smoothly-table-row", null,
13
12
  h("smoothly-table-expandable-cell", null,
14
13
  "normal row (exp.cell)",
@@ -39,19 +38,22 @@ export class TableDemo {
39
38
  h("div", { slot: "detail" }, "expandable row content"))),
40
39
  h("smoothly-table", null,
41
40
  h("smoothly-table-row", null,
42
- h("smoothly-table-header", null, "Header A"),
43
- h("smoothly-table-header", null)),
41
+ h("smoothly-table-header", null, "Header A")),
44
42
  h("smoothly-table-expandable-row", null,
45
- "A Content",
43
+ h("smoothly-table-cell", null, "A Content"),
46
44
  h("div", { slot: "detail" },
47
45
  h("smoothly-tab-switch", null,
48
- h("smoothly-tab", { label: "1", open: true },
46
+ h("smoothly-tab", { label: "innertable 1", open: true },
47
+ h("smoothly-table", null,
48
+ h("smoothly-table-row", null,
49
+ h("smoothly-table-header", null, "Header B")),
50
+ h("smoothly-table-expandable-row", null, "B Content"))),
51
+ h("smoothly-tab", { label: "innertable 2" },
49
52
  h("smoothly-table", null,
50
53
  h("smoothly-table-row", null,
51
- h("smoothly-table-header", null, "Header B"),
52
- h("smoothly-table-header", null)),
54
+ h("smoothly-table-header", null, "Header C")),
53
55
  h("smoothly-table-expandable-row", null,
54
- h("smoothly-table-cell", null, "B Content")))))))),
56
+ h("smoothly-table-cell", null, "C Content")))))))),
55
57
  ];
56
58
  }
57
59
  static get is() { return "smoothly-table-demo"; }
@@ -24,8 +24,9 @@ export class TableExpandableCell {
24
24
  }
25
25
  render() {
26
26
  return (h(Host, { style: { textAlign: this.align } },
27
- h("slot", null),
28
- h("smoothly-icon", { name: "chevron-forward", size: "tiny" }),
27
+ h("aside", null,
28
+ h("smoothly-icon", { name: "chevron-forward", size: "tiny" }),
29
+ h("slot", null)),
29
30
  h("tr", { ref: e => (this.expansionElement = e) },
30
31
  h("td", { colSpan: 999, class: !this.open ? "hide" : "" },
31
32
  h("div", { class: "slot-detail" },
@@ -1,44 +1,40 @@
1
1
  :host {
2
2
  display: table-cell;
3
- vertical-align: middle;
4
- line-height: 1.5em;
3
+ padding: 0.3rem 0 0.3rem 0;
5
4
  cursor: pointer;
6
- padding: 0.2em 0 0.2em;
7
- border-style: solid solid none solid;
8
- border-width: 2px;
9
- border-color: rgb(var(--smoothly-default-color));
10
- }
11
- .hide {
12
- display: none;
5
+ line-height: 1.5rem;
13
6
  }
14
7
  :host[open] {
15
8
  position: relative;
16
9
  z-index: 3;
17
10
  background-color: rgb(var(--smoothly-default-color));
18
- border-style: solid solid none solid;
19
- border-width: 2px;
20
- border-color: rgb(var(--smoothly-dark-color));
11
+ border: 2px solid rgb(var(--smoothly-dark-color));
12
+ border-bottom: none;
13
+ }
14
+ :host smoothly-icon {
15
+ width: 0.6rem;
16
+ float: left;
17
+ padding: 0 0.3rem;
18
+ transition: transform 0.2s;
19
+ }
20
+ :host[open] smoothly-icon {
21
+ transform: rotate(90deg);
22
+ }
23
+ aside {
24
+ display: flex;
21
25
  }
26
+ .hide {
27
+ display: none;
28
+ }
29
+
22
30
  .slot-detail {
23
31
  position: relative;
24
32
  background-color: rgb(var(--smoothly-default-color));
25
33
  width: 104%;
26
34
  left: -2%;
27
- border-left-style: solid;
28
- border-left-color: rgb(var(--smoothly-tertiary-color));
35
+ border-left: 2px solid rgb(var(--smoothly-tertiary-color));
29
36
  box-shadow: 0px 0px 5px 4px rgb(var(--smoothly-dark-color), 0.5);
30
37
  box-sizing: border-box;
31
38
  padding: 0.5rem 2%;
32
39
  }
33
- :host smoothly-icon {
34
- width: 0.6rem;
35
- height: 1rem;
36
- float: left;
37
- padding-left: 0.2rem;
38
- padding-right: 0.2rem;
39
- padding-bottom: 0.5rem;
40
- transition: transform 0.2s;
41
- }
42
- :host[open] smoothly-icon {
43
- transform: rotate(90deg);
44
- }
40
+
@@ -19,7 +19,7 @@ export class TableExpandableRow {
19
19
  render() {
20
20
  return (h(Host, { style: { textAlign: this.align } },
21
21
  h("slot", null),
22
- h("smoothly-table-cell", null,
22
+ h("aside", null,
23
23
  h("smoothly-icon", { name: "chevron-forward", size: "tiny" })),
24
24
  h("tr", { ref: e => (this.expansionElement = e) },
25
25
  h("td", { colSpan: 999, class: !this.open ? "hide" : "" },
@@ -1,43 +1,44 @@
1
1
  :host {
2
- display: table-row;
3
- border: 1px solid rgb(var(--smoothly-default-color));
2
+ display: table-row-group;
4
3
  cursor: pointer;
5
- box-sizing: border-box;
4
+ line-height: 1.5rem;
6
5
  }
7
- .hide {
8
- display: none;
9
- }
10
- .slot-detail {
6
+ :host[open] {
11
7
  position: relative;
8
+ z-index: 3;
12
9
  background-color: rgb(var(--smoothly-default-color));
13
- width: 104%;
14
- left: -2%;
15
- border-left-style: solid;
16
- border-left-color: rgb(var(--smoothly-tertiary-color));
17
- box-shadow: 0px 0px 5px 2px rgb(var(--smoothly-dark-color), 0.5);
18
- box-sizing: border-box;
19
- padding: 0.5rem 2%;
10
+ border: 2px solid rgb(var(--smoothly-dark-color));
11
+ border-bottom: none;
20
12
  }
21
13
  :host smoothly-icon {
22
14
  width: 0.6rem;
23
15
  height: 1rem;
24
- float: left;
25
- padding-left: 0.2rem;
26
- padding-right: 0.2rem;
27
- padding-bottom: 0.5rem;
16
+ position: absolute;
17
+ right: 1rem;
18
+ top: -1.8rem;
28
19
  transition: transform 0.2s;
29
20
  }
30
21
  :host[open] smoothly-icon {
31
22
  transform: rotate(90deg);
32
23
  }
33
- :host[open] smoothly-table-cell {
34
- padding-bottom: 0.5rem;
24
+
25
+ aside {
26
+ display: table-row;
27
+ position: relative;
35
28
  }
36
- :host[open] {
29
+
30
+ .hide {
31
+ display: none;
32
+ }
33
+ .slot-detail {
37
34
  position: relative;
38
- z-index: 3;
39
35
  background-color: rgb(var(--smoothly-default-color));
40
- border-style: solid;
41
- border-width: 5px;
42
- box-shadow: inset 2px 0px 0px 0px rgb(var(--smoothly-dark-color)), inset 0px 2px 0px 0px rgb(var(--smoothly-dark-color)), inset -2px 0px 0px 0px rgb(var(--smoothly-dark-color)), inset 0px 0px 0px 2px rgb(var(--smoothly-default-color));
36
+ width: 104%;
37
+ left: -2%;
38
+ border-left-style: solid;
39
+ border-left-color: rgb(var(--smoothly-tertiary-color));
40
+ box-shadow: 0px 0px 4px 2px rgb(var(--smoothly-dark-color));
41
+ box-sizing: border-box;
42
+ padding: 0.5rem 2%;
43
43
  }
44
+
@@ -5,5 +5,4 @@
5
5
  border-bottom: 1px solid rgb(var(--smoothly-dark-color));
6
6
  padding-left: 1rem;
7
7
  font-weight: bold;
8
- margin-bottom: 5rem;
9
8
  }
@@ -1,7 +1,7 @@
1
1
  :host {
2
2
  display: table-row;
3
- border: 1px solid rgb(var(--smoothly-dark-color), 0.5);
4
3
  cursor: default;
4
+ line-height: 1.5rem;
5
5
  }
6
6
  .hide {
7
7
  display: none;
@@ -1,14 +1,9 @@
1
1
  :host {
2
2
  display: table;
3
- text-align: left;
3
+ border-collapse: collapse;
4
4
  border: 1px solid rgb(var(--smoothly-dark-color));
5
- width: 80%;
5
+ width: var(--table-width, 80%);
6
6
  box-sizing: border-box;
7
7
  background-color: rgb(var(--smoothly-default-color));
8
- margin: 1rem 9.5%;
9
- padding-bottom: 0.5rem;
10
- }
11
- .slot-detail > div {
12
- padding: 10rem 0;
13
- margin-left: 10rem;
8
+ margin: auto;
14
9
  }