@digital-realty/ix-tile-picker 2.3.15 → 2.4.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.
@@ -1 +1,277 @@
1
- import{__decorate}from"tslib";import"@digital-realty/ix-search-bar";import"@material/web/elevation/elevation.js";import{css,LitElement,html,nothing}from"lit";import{property}from"lit/decorators.js";import{classMap}from"lit/directives/class-map.js";let IxTilePickerStyles=css`:host{justify-content:space-between;align-items:center;border:1px solid #d3d3d3;border-width:1px 0;padding:1rem 0;box-sizing:border-box}*,:after,:before{box-sizing:inherit}.tiles{display:grid;grid-template-columns:repeat(auto-fill,minmax(calc(var(--tile-base-font-size,1rem) * 14),1fr));grid-gap:1em}.tile{display:flex;flex-direction:column;padding:var(--tile-padding-top,var(--tile-padding-vertical,var(--tile-padding,1em))) var(--tile-padding-right,var(--tile-padding-horizontal,var(--tile-padding,1em))) var(--tile-padding-bottom,var(--tile-padding-vertical,var(--tile-padding,0))) var(--tile-padding-left,var(--tile-padding-horizontal,var(--tile-padding,1em)));font-size:var(--tile-base-font-size,1rem);color:#333;background-color:var(--tile-background-color,#fff)}.tile.-disabled{--tile-background-color:#f5f5f5}.tile.-hidden{display:none}.tile__header{flex:0 0 auto;position:relative;display:flex;justify-content:space-between;align-items:flex-start;padding-bottom:.5em;margin-bottom:.5em;border-bottom:1px solid #d3d3d3}.tile-heading{display:flex;flex-direction:column-reverse;margin:0;padding:0}.tile-heading__label{font-size:.8125em;line-height:1.5385em;color:rgba(51,51,51,.7)}.tile-heading__value{margin:0;font-size:1.125em;line-height:1.3333em}.tile__body{flex:1 0 auto;padding-bottom:.5em}.tile__footer{flex:0 0 auto;padding:var(--tile-footer-padding-top,var(--tile-footer-padding-vertical,var(--tile-footer-padding,1em))) var(--tile-footer-padding-right,var(--tile-footer-padding-horizontal,var(--tile-footer-padding,0))) var(--tile-footer-padding-bottom,var(--tile-footer-padding-vertical,var(--tile-footer-padding,1em))) var(--tile-footer-padding-left,var(--tile-footer-padding-horizontal,var(--tile-footer-padding,0)));border-top:1px solid #d3d3d3}.tile__footer.-full-bleed{margin-left:calc(var(--tile-padding-left,var(--tile-padding-horizontal,var(--tile-padding,1em))) * -1);margin-right:calc(var(--tile-padding-right,var(--tile-padding-horizontal,var(--tile-padding,1em))) * -1);margin-bottom:calc(var(--tile-padding-bottom,var(--tile-padding-vertical,var(--tile-padding,0))) * -1);margin-top:0}.tile-radio-btn{position:relative;padding:0;border-top:none}.tile-radio-btn__input{position:absolute;top:0;left:0;opacity:0;z-index:-1}.tile-radio-btn__input:focus{outline:0}.tile-radio-btn__label{display:block;padding:1em;text-align:center;background-color:#d6eef7;background-color:var(--tile-radio-btn-bg-color,#d6eef7);color:inherit;color:var(--tile-radio-btn-text-color,inherit);cursor:pointer}.tile-radio-btn__input:focus~.tile-radio-btn__label{box-shadow:0 -4px 0 0 #007399 inset;box-shadow:0 -4px 0 0 var(--tile-radio-btn-focus-accent-color,#007399) inset}@media (hover:hover){.tile-radio-btn__label:hover{background-color:#abdcef;background-color:var(--tile-radio-btn-hover-bg-color,var(--tile-radio-btn-bg-color,#abdcef));color:inherit;color:var(--tile-radio-btn-hover-text-color,var(--tile-radio-btn-text-color,inherit))}}.tile-radio-btn__label.-checked{background-color:#09c;background-color:var(--tile-radio-btn-selected-bg-color,#09c);color:#fff;color:var(--tile-radio-btn-selected-text-color,var(--tile-radio-btn-text-color,#fff));opacity:0}.tile-radio-btn__input:checked~.tile-radio-btn__label.-checked{opacity:1;cursor:default}.tile-radio-btn__label.-disabled{background-image:repeating-linear-gradient(-30deg,transparent 0,transparent 3px,rgba(0,0,0,.1) 3px,rgba(0,0,0,.1) 4px);background-color:#d3d3d3;background-color:var(--tile-radio-btn-disabled-bg-color,#d3d3d3);color:#888;color:var(--tile-radio-btn-disabled-text-color,var(--tile-radio-btn-text-color,#888));cursor:not-allowed}.surface{position:relative;--md-elevation-level:2}`;class IxTilePicker extends LitElement{constructor(){super(...arguments),this.items=[],this.searchFields=[],this.foundItems=[],this.onSelectTile=void 0,this.onResultsFound=void 0,this.disabledText="Disabled",this.selectedText="Selected",this.chooseText="Choose",this.value=""}static get styles(){return[IxTilePickerStyles]}connectedCallback(){super.connectedCallback(),this.foundItems=this.items}filterTiles(i){this.foundItems=this.items.map(e=>{var t;return{...e,hidden:!(null!=(t=null==i?void 0:i.detail)&&t.items.includes(e))}}),this.onResultsFound&&this.onResultsFound(this.foundItems)}handleClick(e){e=e.target,this.value=e.value||"",this.onSelectTile&&this.onSelectTile(this.value),e=this.foundItems.find(e=>e.id===this.value);e&&this.renderRadioButtonLabel(e),this.requestUpdate()}getRadioButtonLabelText(e){return e.disabled?e.disabledButtonText||this.disabledText:e.id===this.value?this.selectedText:this.chooseText}getRadioButtonLabelClass(e){return classMap({"-disabled":(null==e?void 0:e.disabled)||!1,"-checked":e.id===this.value,"-unselected":e.id!==this.value})}renderRadioButtonLabel(e){return html`<label for="tile-${e.id}" class="tile-radio-btn__label ${this.getRadioButtonLabelClass(e)}" aria-hidden="true">${this.getRadioButtonLabelText(e)}</label>`}render(){return html`<ix-search-bar .items="${this.items}" .searchFields="${this.searchFields}" @onResultsFound="${this.filterTiles}"></ix-search-bar><div class="tiles">${this.foundItems.length?this.foundItems.map((e,t)=>html`<div class="tile surface ${classMap({"-disabled":(null==e?void 0:e.disabled)||!1,"-hidden":(null==e?void 0:e.hidden)||!1})}"><md-elevation></md-elevation><header class="tile__header" aria-hidden="true"><dl class="tile-heading" id="tileLabel${t}"><dt class="tile-heading__label"><slot name="label-${e.id}"></slot></dt><dd class="tile-heading__value"><slot name="value-${e.id}"></slot></dd></dl></header><div class="tile__body" aria-hidden="true" id="tileDescription${t}"><slot name="body-${e.id}"></slot></div><span class="tile__footer -full-bleed tile-radio-btn"><input id="tile-${e.id}" type="radio" class="tile-radio-btn__input" name="picked-tile" aria-labelledby="tileLabel${t}" aria-describedby="tileDescription${t}" .value="${(null==e?void 0:e.id)||""}" @click="${this.handleClick}" ?disabled="${e.disabled}"> ${this.renderRadioButtonLabel(e)}</span></div>`):nothing}</div>`}}__decorate([property({type:Array})],IxTilePicker.prototype,"items",void 0),__decorate([property({type:Array})],IxTilePicker.prototype,"searchFields",void 0),__decorate([property({type:Array})],IxTilePicker.prototype,"foundItems",void 0),__decorate([property({attribute:!1})],IxTilePicker.prototype,"onSelectTile",void 0),__decorate([property({attribute:!1})],IxTilePicker.prototype,"onResultsFound",void 0),__decorate([property()],IxTilePicker.prototype,"disabledText",void 0),__decorate([property()],IxTilePicker.prototype,"selectedText",void 0),__decorate([property()],IxTilePicker.prototype,"chooseText",void 0),window.customElements.define("ix-tile-picker",IxTilePicker);
1
+ import{__decorate as e}from"tslib";import"@digital-realty/ix-search-bar";import"@material/web/elevation/elevation.js";import{css as t,LitElement as i,html as o,nothing as l}from"lit";import{property as a}from"lit/decorators.js";import{classMap as d}from"lit/directives/class-map.js";const r=t`
2
+ :host {
3
+ justify-content: space-between;
4
+ align-items: center;
5
+ border: 1px solid lightgrey;
6
+ border-width: 1px 0;
7
+ padding: 1rem 0;
8
+ box-sizing: border-box;
9
+ }
10
+
11
+ *,
12
+ :before,
13
+ :after {
14
+ box-sizing: inherit;
15
+ }
16
+
17
+ .tiles {
18
+ display: grid;
19
+ grid-template-columns: repeat(
20
+ auto-fill,
21
+ minmax(calc(var(--tile-base-font-size, 1rem) * 14), 1fr)
22
+ );
23
+ grid-gap: 1em;
24
+ }
25
+
26
+ .tile {
27
+ display: flex;
28
+ flex-direction: column;
29
+ padding: var(
30
+ --tile-padding-top,
31
+ var(--tile-padding-vertical, var(--tile-padding, 1em))
32
+ )
33
+ var(
34
+ --tile-padding-right,
35
+ var(--tile-padding-horizontal, var(--tile-padding, 1em))
36
+ )
37
+ var(
38
+ --tile-padding-bottom,
39
+ var(--tile-padding-vertical, var(--tile-padding, 0))
40
+ )
41
+ var(
42
+ --tile-padding-left,
43
+ var(--tile-padding-horizontal, var(--tile-padding, 1em))
44
+ );
45
+ font-size: var(--tile-base-font-size, 1rem);
46
+ color: rgba(51, 51, 51, 1);
47
+ background-color: var(--tile-background-color, #fff);
48
+ }
49
+
50
+ .tile.-disabled {
51
+ --tile-background-color: #f5f5f5;
52
+ }
53
+
54
+ .tile.-hidden {
55
+ display: none;
56
+ }
57
+
58
+ .tile__header {
59
+ flex: 0 0 auto;
60
+ position: relative;
61
+ display: flex;
62
+ justify-content: space-between;
63
+ align-items: flex-start;
64
+ padding-bottom: 0.5em;
65
+ margin-bottom: 0.5em;
66
+ border-bottom: 1px solid lightgrey;
67
+ }
68
+
69
+ .tile-heading {
70
+ display: flex;
71
+ flex-direction: column-reverse;
72
+ margin: 0;
73
+ padding: 0;
74
+ }
75
+
76
+ .tile-heading__label {
77
+ font-size: 0.8125em;
78
+ line-height: 1.5385em;
79
+ color: rgba(51, 51, 51, 0.7);
80
+ }
81
+
82
+ .tile-heading__value {
83
+ margin: 0;
84
+ font-size: 1.125em;
85
+ line-height: 1.3333em;
86
+ }
87
+
88
+ .tile__body {
89
+ flex: 1 0 auto;
90
+ padding-bottom: 0.5em;
91
+ }
92
+
93
+ .tile__footer {
94
+ flex: 0 0 auto;
95
+ padding: var(
96
+ --tile-footer-padding-top,
97
+ var(--tile-footer-padding-vertical, var(--tile-footer-padding, 1em))
98
+ )
99
+ var(
100
+ --tile-footer-padding-right,
101
+ var(--tile-footer-padding-horizontal, var(--tile-footer-padding, 0))
102
+ )
103
+ var(
104
+ --tile-footer-padding-bottom,
105
+ var(--tile-footer-padding-vertical, var(--tile-footer-padding, 1em))
106
+ )
107
+ var(
108
+ --tile-footer-padding-left,
109
+ var(--tile-footer-padding-horizontal, var(--tile-footer-padding, 0))
110
+ );
111
+ border-top: 1px solid lightgrey;
112
+ }
113
+
114
+ .tile__footer.-full-bleed {
115
+ margin-left: calc(
116
+ var(
117
+ --tile-padding-left,
118
+ var(--tile-padding-horizontal, var(--tile-padding, 1em))
119
+ ) * -1
120
+ );
121
+ margin-right: calc(
122
+ var(
123
+ --tile-padding-right,
124
+ var(--tile-padding-horizontal, var(--tile-padding, 1em))
125
+ ) * -1
126
+ );
127
+ margin-bottom: calc(
128
+ var(
129
+ --tile-padding-bottom,
130
+ var(--tile-padding-vertical, var(--tile-padding, 0))
131
+ ) * -1
132
+ );
133
+ margin-top: 0;
134
+ }
135
+
136
+ .tile-radio-btn {
137
+ position: relative;
138
+ padding: 0;
139
+ border-top: none;
140
+ }
141
+
142
+ .tile-radio-btn__input {
143
+ position: absolute;
144
+ top: 0;
145
+ left: 0;
146
+ opacity: 0;
147
+ z-index: -1;
148
+ }
149
+
150
+ .tile-radio-btn__input:focus {
151
+ outline: none;
152
+ }
153
+
154
+ .tile-radio-btn__label {
155
+ display: block;
156
+ padding: 1em;
157
+ text-align: center;
158
+ background-color: rgba(214, 238, 247, 1);
159
+ background-color: var(--tile-radio-btn-bg-color, rgba(214, 238, 247, 1));
160
+ color: inherit;
161
+ color: var(--tile-radio-btn-text-color, inherit);
162
+ cursor: pointer;
163
+ }
164
+
165
+ .tile-radio-btn__input:focus ~ .tile-radio-btn__label {
166
+ box-shadow: 0 -4px 0 0 #007399 inset;
167
+ box-shadow: 0 -4px 0 0 var(--tile-radio-btn-focus-accent-color, #007399) inset;
168
+ }
169
+
170
+ @media (hover: hover) {
171
+ .tile-radio-btn__label:hover {
172
+ background-color: #abdcef;
173
+ background-color: var(
174
+ --tile-radio-btn-hover-bg-color,
175
+ var(--tile-radio-btn-bg-color, #abdcef)
176
+ );
177
+ color: inherit;
178
+ color: var(
179
+ --tile-radio-btn-hover-text-color,
180
+ var(--tile-radio-btn-text-color, inherit)
181
+ );
182
+ }
183
+ }
184
+
185
+ .tile-radio-btn__label.-checked {
186
+ background-color: #09c;
187
+ background-color: var(--tile-radio-btn-selected-bg-color, #09c);
188
+ color: #fff;
189
+ color: var(
190
+ --tile-radio-btn-selected-text-color,
191
+ var(--tile-radio-btn-text-color, #fff)
192
+ );
193
+ opacity: 0;
194
+ }
195
+
196
+ .tile-radio-btn__input:checked ~ .tile-radio-btn__label.-checked {
197
+ opacity: 1;
198
+ cursor: default;
199
+ }
200
+
201
+ .tile-radio-btn__label.-disabled {
202
+ background-image: repeating-linear-gradient(
203
+ -30deg,
204
+ transparent 0,
205
+ transparent 3px,
206
+ rgba(0, 0, 0, 0.1) 3px,
207
+ rgba(0, 0, 0, 0.1) 4px
208
+ );
209
+ background-color: lightgrey;
210
+ background-color: var(--tile-radio-btn-disabled-bg-color, lightgrey);
211
+ color: #888;
212
+ color: var(
213
+ --tile-radio-btn-disabled-text-color,
214
+ var(--tile-radio-btn-text-color, #888)
215
+ );
216
+ cursor: not-allowed;
217
+ }
218
+
219
+ .surface {
220
+ position: relative;
221
+ --md-elevation-level: 2;
222
+ }
223
+ `;class n extends i{constructor(){super(...arguments),this.items=[],this.searchFields=[],this.foundItems=[],this.onSelectTile=void 0,this.onResultsFound=void 0,this.disabledText="Disabled",this.selectedText="Selected",this.chooseText="Choose",this.value=""}static get styles(){return[r]}connectedCallback(){super.connectedCallback(),this.foundItems=this.items}filterTiles(e){this.foundItems=this.items.map(t=>{var i;return{...t,hidden:!(null===(i=null==e?void 0:e.detail)||void 0===i?void 0:i.items.includes(t))}}),this.onResultsFound&&this.onResultsFound(this.foundItems)}handleClick(e){const{target:t}=e;this.value=t.value||"",this.onSelectTile&&this.onSelectTile(this.value);const i=this.foundItems.find(e=>e.id===this.value);i&&this.renderRadioButtonLabel(i),this.requestUpdate()}getRadioButtonLabelText(e){return e.disabled?e.disabledButtonText||this.disabledText:e.id===this.value?this.selectedText:this.chooseText}getRadioButtonLabelClass(e){return d({"-disabled":(null==e?void 0:e.disabled)||!1,"-checked":e.id===this.value,"-unselected":e.id!==this.value})}renderRadioButtonLabel(e){return o`<label
224
+ for="tile-${e.id}"
225
+ class="tile-radio-btn__label ${this.getRadioButtonLabelClass(e)}"
226
+ aria-hidden="true"
227
+ >${this.getRadioButtonLabelText(e)}</label
228
+ >`}render(){return o`
229
+ <ix-search-bar
230
+ .items="${this.items}"
231
+ .searchFields="${this.searchFields}"
232
+ @onResultsFound="${this.filterTiles}"
233
+ ></ix-search-bar>
234
+
235
+ <div class="tiles">
236
+ ${this.foundItems.length?this.foundItems.map((e,t)=>o`
237
+ <div
238
+ class="tile surface ${d({"-disabled":(null==e?void 0:e.disabled)||!1,"-hidden":(null==e?void 0:e.hidden)||!1})}"
239
+ >
240
+ <md-elevation></md-elevation>
241
+ <header class="tile__header" aria-hidden="true">
242
+ <dl class="tile-heading" id="tileLabel${t}">
243
+ <dt class="tile-heading__label">
244
+ <slot name="label-${e.id}"></slot>
245
+ </dt>
246
+ <dd class="tile-heading__value">
247
+ <slot name="value-${e.id}"></slot>
248
+ </dd>
249
+ </dl>
250
+ </header>
251
+
252
+ <div
253
+ class="tile__body"
254
+ aria-hidden="true"
255
+ id="tileDescription${t}"
256
+ >
257
+ <slot name="body-${e.id}"></slot>
258
+ </div>
259
+
260
+ <span class="tile__footer -full-bleed tile-radio-btn">
261
+ <input
262
+ id="tile-${e.id}"
263
+ type="radio"
264
+ class="tile-radio-btn__input"
265
+ name="picked-tile"
266
+ aria-labelledby="tileLabel${t}"
267
+ aria-describedby="tileDescription${t}"
268
+ .value="${(null==e?void 0:e.id)||""}"
269
+ @click="${this.handleClick}"
270
+ ?disabled="${e.disabled}"
271
+ />
272
+ ${this.renderRadioButtonLabel(e)}
273
+ </span>
274
+ </div>
275
+ `):l}
276
+ </div>
277
+ `}}e([a({type:Array})],n.prototype,"items",void 0),e([a({type:Array})],n.prototype,"searchFields",void 0),e([a({type:Array})],n.prototype,"foundItems",void 0),e([a({attribute:!1})],n.prototype,"onSelectTile",void 0),e([a({attribute:!1})],n.prototype,"onResultsFound",void 0),e([a()],n.prototype,"disabledText",void 0),e([a()],n.prototype,"selectedText",void 0),e([a()],n.prototype,"chooseText",void 0),window.customElements.define("ix-tile-picker",n);
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Webcomponent ix-tile-picker following open-wc recommendations",
4
4
  "license": "MIT",
5
5
  "author": "Digital Realty",
6
- "version": "2.3.15",
6
+ "version": "2.4.1",
7
7
  "type": "module",
8
8
  "main": "dist/index.js",
9
9
  "module": "dist/index.js",
@@ -21,13 +21,13 @@
21
21
  "start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
22
22
  "build": "tsc && npm run analyze -- --exclude dist && rollup -c",
23
23
  "prepublish": "tsc && npm run analyze -- --exclude dist",
24
- "lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
25
- "format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
24
+ "lint": "eslint --ext .ts,.html . && prettier \"**/*.ts\" --check --ignore-path .gitignore",
25
+ "format": "eslint --ext .ts,.html . --fix && prettier \"**/*.ts\" --write --ignore-path .gitignore",
26
26
  "test": "tsc && wtr --coverage",
27
27
  "test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\""
28
28
  },
29
29
  "dependencies": {
30
- "@digital-realty/ix-search-bar": "^2.3.15",
30
+ "@digital-realty/ix-search-bar": "^2.4.1",
31
31
  "@lit/react": "^1.0.2",
32
32
  "@material/web": "2.4.0",
33
33
  "lit": "^3.2.1",
@@ -35,23 +35,21 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@custom-elements-manifest/analyzer": "^0.4.17",
38
- "@open-wc/eslint-config": "^9.2.1",
39
38
  "@open-wc/testing": "^3.1.6",
39
+ "@rollup/plugin-terser": "^1.0.0",
40
40
  "@types/react": "^18.2.22",
41
- "@typescript-eslint/eslint-plugin": "^5.48.0",
42
- "@typescript-eslint/parser": "^5.48.0",
41
+ "@typescript-eslint/eslint-plugin": "^8.58.2",
42
+ "@typescript-eslint/parser": "^8.58.2",
43
43
  "@web/dev-server": "^0.4.6",
44
44
  "@web/test-runner": "^0.20.2",
45
- "concurrently": "^9.1.0",
46
- "eslint": "^8.31.0",
45
+ "concurrently": "^9.2.1",
46
+ "eslint": "^9.39.4",
47
47
  "eslint-config-prettier": "^8.3.0",
48
48
  "husky": "^4.3.8",
49
49
  "lint-staged": "^10.5.4",
50
50
  "prettier": "^2.4.1",
51
51
  "rollup": "^4.29.1",
52
- "rollup-plugin-minify-html-literals": "^1.2.6",
53
52
  "rollup-plugin-summary": "^2.0.0",
54
- "rollup-plugin-uglify": "^6.0.4",
55
53
  "tslib": "^2.3.1",
56
54
  "typescript": "^4.5.2"
57
55
  },
@@ -59,10 +57,6 @@
59
57
  "eslintConfig": {
60
58
  "parser": "@typescript-eslint/parser",
61
59
  "root": true,
62
- "extends": [
63
- "@open-wc",
64
- "prettier"
65
- ],
66
60
  "plugins": [
67
61
  "@typescript-eslint"
68
62
  ],
@@ -103,5 +97,5 @@
103
97
  "README.md",
104
98
  "LICENSE"
105
99
  ],
106
- "gitHead": "b47ba9e880c386ecf579ab21a118f94221cd1e1c"
100
+ "gitHead": "da06737d6707fd3d4ef898ba0fa632e7b3ed8019"
107
101
  }