@design.estate/dees-catalog 1.0.227 → 1.0.228

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@design.estate/dees-catalog",
3
- "version": "1.0.227",
3
+ "version": "1.0.228",
4
4
  "private": false,
5
5
  "description": "website for lossless.com",
6
6
  "main": "dist_ts_web/index.js",
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@design.estate/dees-catalog',
6
- version: '1.0.227',
6
+ version: '1.0.228',
7
7
  description: 'website for lossless.com'
8
8
  }
@@ -0,0 +1,28 @@
1
+ import { html } from '@design.estate/dees-element';
2
+
3
+ export const demoFunc = () => html`
4
+ <dees-chips
5
+ selectionMode="none"
6
+ .selectableChips=${[
7
+ { key: 'account1', value: 'Payment Account 1' },
8
+ { key: 'account2', value: 'PaymentAccount2' },
9
+ { key: 'account3', value: 'Payment Account 3' }
10
+ ]}
11
+ ></dees-chips>
12
+ <dees-chips
13
+ selectionMode="single"
14
+ .selectableChips=${[
15
+ { key: 'account1', value: 'Payment Account 1' },
16
+ { key: 'account2', value: 'PaymentAccount2' },
17
+ { key: 'account3', value: 'Payment Account 3' }
18
+ ]}
19
+ ></dees-chips>
20
+ <dees-chips
21
+ selectionMode="multiple"
22
+ .selectableChips=${[
23
+ { key: 'account1', value: 'Payment Account 1' },
24
+ { key: 'account2', value: 'PaymentAccount2' },
25
+ { key: 'account3', value: 'Payment Account 3' }
26
+ ]}
27
+ ></dees-chips>
28
+ `;
@@ -11,6 +11,7 @@ import {
11
11
  } from '@design.estate/dees-element';
12
12
 
13
13
  import * as domtools from '@design.estate/dees-domtools';
14
+ import { demoFunc } from './dees-chips.demo.js';
14
15
 
15
16
  declare global {
16
17
  interface HTMLElementTagNameMap {
@@ -18,29 +19,27 @@ declare global {
18
19
  }
19
20
  }
20
21
 
22
+ type Tag = { key: string, value: string };
23
+
21
24
  @customElement('dees-chips')
22
25
  export class DeesChips extends DeesElement {
23
- public static demo = () => html`
24
- <dees-chips .selectableChips=${['Payment Account 1', 'PaymentAccount2', 'Payment Account 3']}></dees-chips>
25
- <dees-chips selectionMode="multiple" .selectableChips=${['Payment Account 1', 'PaymentAccount2', 'Payment Account 3']}></dees-chips>
26
-
27
- `;
26
+ public static demo = demoFunc;
28
27
 
29
28
  @property()
30
- public selectionMode: 'single' | 'multiple' = 'single';
29
+ public selectionMode: 'none' | 'single' | 'multiple' = 'single';
31
30
 
32
31
  @property({
33
32
  type: Array
34
33
  })
35
- public selectableChips: string[] = [];
34
+ public selectableChips: Tag[] = [];
36
35
 
37
36
  @property()
38
- public selectedChip: string = null;
37
+ public selectedChip: Tag = null;
39
38
 
40
39
  @property({
41
40
  type: Array
42
41
  })
43
- public selectedChips: string[] = [];
42
+ public selectedChips: Tag[] = [];
44
43
 
45
44
 
46
45
  constructor() {
@@ -57,18 +56,23 @@ export class DeesChips extends DeesElement {
57
56
  }
58
57
 
59
58
  .mainbox {
60
-
59
+ user-select: none;
61
60
  }
62
61
 
63
62
  .chip {
64
- background: #494949;
65
- display: inline-block;
66
- padding: 8px 12px;
67
- font-size: 14px;
63
+ border-top: ${cssManager.bdTheme('1px solid #CCC', '1px solid #444')};
64
+ background: #333333;
65
+ display: inline-flex;
66
+ height: 20px;
67
+ line-height: 20px;
68
+ padding: 0px 8px;
69
+ font-size: 12px;
68
70
  color: #fff;
69
71
  border-radius: 40px;
70
72
  margin-right: 4px;
71
73
  margin-bottom: 8px;
74
+ position: relative;
75
+ overflow: hidden;
72
76
  }
73
77
 
74
78
  .chip:hover {
@@ -79,6 +83,16 @@ export class DeesChips extends DeesElement {
79
83
  .chip.selected {
80
84
  background: #00A3FF;
81
85
  }
86
+
87
+ .chipKey {
88
+ background: rgba(0,0,0,0.3);
89
+ height: 100%;
90
+ display: inline-block;
91
+ margin-left: -8px;
92
+ padding-left: 8px;
93
+ padding-right: 8px;
94
+ margin-right: 8px;
95
+ }
82
96
 
83
97
  `,
84
98
  ];
@@ -86,9 +100,9 @@ export class DeesChips extends DeesElement {
86
100
  public render(): TemplateResult {
87
101
  return html`
88
102
  <div class="mainbox">
89
- ${this.selectableChips.map(chipArg => html`
90
- <div @click=${() => this.selectChip(chipArg)} class="chip ${this.selectedChip === chipArg || this.selectedChips.includes(chipArg) ? 'selected' : ''}">
91
- ${chipArg}
103
+ ${this.selectableChips.map(chip => html`
104
+ <div @click=${() => this.selectChip(chip)} class="chip ${this.isSelected(chip) ? 'selected' : ''}">
105
+ ${chip.key ? html`<div class="chipKey">${chip.key}</div>` : html``}${chip.value}
92
106
  </div>
93
107
  `)}
94
108
  </div>
@@ -102,20 +116,32 @@ export class DeesChips extends DeesElement {
102
116
  }
103
117
  }
104
118
 
105
- public async selectChip(chipArg: string) {
119
+ private isSelected(chip: Tag): boolean {
120
+ if (this.selectionMode === 'single') {
121
+ return this.selectedChip?.key === chip.key;
122
+ } else {
123
+ return this.selectedChips.some(selected => selected.key === chip.key);
124
+ }
125
+ }
126
+
127
+ public async selectChip(chip: Tag) {
128
+ if (this.selectionMode === 'none') {
129
+ return;
130
+ }
131
+
106
132
  if (this.selectionMode === 'single') {
107
- if (this.selectedChip === chipArg) {
133
+ if (this.isSelected(chip)) {
108
134
  this.selectedChip = null;
109
135
  this.selectedChips = [];
110
136
  } else {
111
- this.selectedChip = chipArg;
112
- this.selectedChips = [chipArg];
137
+ this.selectedChip = chip;
138
+ this.selectedChips = [chip];
113
139
  }
114
140
  } else if(this.selectionMode === 'multiple') {
115
- if (this.selectedChips.includes(chipArg)) {
116
- this.selectedChips = this.selectedChips.filter(chipArg2 => chipArg !== chipArg2)
141
+ if (this.isSelected(chip)) {
142
+ this.selectedChips = this.selectedChips.filter(selected => selected.key !== chip.key);
117
143
  } else {
118
- this.selectedChips.push(chipArg);
144
+ this.selectedChips = [...this.selectedChips, chip];
119
145
  }
120
146
  this.requestUpdate();
121
147
  }