smoothly 0.2.3 → 0.2.6

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 +69 -24
  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 +129 -10
  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 -2
  16. package/dist/collection/components/table/expandable/row/style.css +18 -24
  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 +72 -27
  21. package/dist/esm/loader.js +1 -1
  22. package/dist/esm/smoothly-accordion_51.entry.js +69 -24
  23. package/dist/esm/smoothly.js +1 -1
  24. package/dist/smoothly/{p-6e8e1fb1.entry.js → p-dfc1b7ca.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 +13 -3
  29. package/dist/types/components.d.ts +15 -0
  30. package/package.json +1 -1
@@ -4,13 +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";
10
11
  this.selectAllName = "Select All";
11
12
  this.selectionName = "items selected";
13
+ this.newOptionLabel = "Add:";
14
+ this.valueValidator = _ => [true, undefined];
12
15
  }
13
- isOpenChangeHander() {
16
+ isOpenChangeHandler() {
14
17
  if (this.isOpen == false) {
15
18
  this.menuClose.emit(this.selections);
16
19
  }
@@ -22,10 +25,26 @@ export class SmoothlyPicker {
22
25
  this.keepFocusOnReRender = false;
23
26
  }
24
27
  }
25
- optionSelectHander(event) {
28
+ optionSelectHandler(event) {
26
29
  this.toggle(event.detail);
27
30
  event.stopPropagation();
28
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
+ }
29
48
  toggle(option) {
30
49
  option.value == "select-none"
31
50
  ? this.toggleAll()
@@ -60,9 +79,19 @@ export class SmoothlyPicker {
60
79
  }
61
80
  toggleHighlighted() {
62
81
  var _a;
63
- (_a = this.menuElement) === null || _a === void 0 ? void 0 : _a.getHighlighted().then((result) => {
64
- result && this.toggle(result);
65
- });
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
+ });
66
95
  }
67
96
  highlightDefault() {
68
97
  var _a;
@@ -141,7 +170,7 @@ export class SmoothlyPicker {
141
170
  : this.selections.map(selection => selection.name).join(", "), onKeyDown: e => this.onKeyDown(e), onInput: (e) => this.onInput(e) }),
142
171
  h("smoothly-icon", { class: "down", name: "chevron-down", size: "tiny" }),
143
172
  h("smoothly-icon", { class: "up", name: "chevron-up", size: "tiny" })),
144
- 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 })));
145
174
  }
146
175
  static get is() { return "smoothly-picker"; }
147
176
  static get encapsulation() { return "shadow"; }
@@ -222,6 +251,24 @@ export class SmoothlyPicker {
222
251
  "reflect": true,
223
252
  "defaultValue": "false"
224
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
+ },
225
272
  "optionStyle": {
226
273
  "type": "any",
227
274
  "mutable": false,
@@ -368,10 +415,50 @@ export class SmoothlyPicker {
368
415
  "attribute": "selection-name",
369
416
  "reflect": false,
370
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]"
371
457
  }
372
458
  }; }
373
459
  static get states() { return {
374
- "isOpen": {}
460
+ "isOpen": {},
461
+ "empty": {}
375
462
  }; }
376
463
  static get events() { return [{
377
464
  "method": "menuClose",
@@ -393,18 +480,50 @@ export class SmoothlyPicker {
393
480
  }
394
481
  }
395
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
+ }
396
503
  }]; }
397
504
  static get elementRef() { return "element"; }
398
505
  static get watchers() { return [{
399
506
  "propName": "selections",
400
- "methodName": "isOpenChangeHander"
507
+ "methodName": "isOpenChangeHandler"
401
508
  }, {
402
509
  "propName": "isOpen",
403
- "methodName": "isOpenChangeHander"
510
+ "methodName": "isOpenChangeHandler"
404
511
  }]; }
405
512
  static get listeners() { return [{
406
513
  "name": "optionSelect",
407
- "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",
408
527
  "target": undefined,
409
528
  "capture": false,
410
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,8 +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,
23
- h("smoothly-icon", { name: "chevron-forward", size: "tiny" })),
22
+ h("smoothly-icon", { name: "chevron-forward", size: "tiny" }),
24
23
  h("tr", { ref: e => (this.expansionElement = e) },
25
24
  h("td", { colSpan: 999, class: !this.open ? "hide" : "" },
26
25
  h("div", { class: "slot-detail" },
@@ -1,43 +1,37 @@
1
1
  :host {
2
2
  display: table-row;
3
- border: 1px solid rgb(var(--smoothly-default-color));
4
3
  cursor: pointer;
5
- box-sizing: border-box;
6
- }
7
- .hide {
8
- display: none;
4
+ line-height: 1.5rem;
9
5
  }
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
+ margin-top: -1rem;
17
+ margin-left: -1rem;
28
18
  transition: transform 0.2s;
29
19
  }
30
20
  :host[open] smoothly-icon {
31
21
  transform: rotate(90deg);
32
22
  }
33
- :host[open] smoothly-table-cell {
34
- padding-bottom: 0.5rem;
23
+
24
+ .hide {
25
+ display: none;
35
26
  }
36
- :host[open] {
27
+ .slot-detail {
37
28
  position: relative;
38
- z-index: 3;
39
29
  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));
30
+ width: 104%;
31
+ left: -2%;
32
+ border-left-style: solid;
33
+ border-left-color: rgb(var(--smoothly-tertiary-color));
34
+ box-shadow: 0px 0px 4px 2px rgb(var(--smoothly-dark-color));
35
+ box-sizing: border-box;
36
+ padding: 0.5rem 2%;
43
37
  }
@@ -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
  }