@umbraco-ui/uui-card-block-type 1.6.0-rc.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 uui-app
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # uui-card-block-type
2
+
3
+ ![npm](https://img.shields.io/npm/v/@umbraco-ui/uui-card-block-type?logoColor=%231B264F)
4
+
5
+ Umbraco style card-block-type component.
6
+
7
+ ## Installation
8
+
9
+ ### ES imports
10
+
11
+ ```zsh
12
+ npm i @umbraco-ui/uui-card-block-type
13
+ ```
14
+
15
+ Import the registration of `<uui-card-block-type>` via:
16
+
17
+ ```javascript
18
+ import '@umbraco-ui/uui-card-block-type';
19
+ ```
20
+
21
+ When looking to leverage the `UUICardBlockTypeElement` base class as a type and/or for extension purposes, do so via:
22
+
23
+ ```javascript
24
+ import { UUICardBlockTypeElement } from '@umbraco-ui/uui-card-block-type';
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ```html
30
+ <uui-card-block-type></uui-card-block-type>
31
+ ```
@@ -0,0 +1,160 @@
1
+ {
2
+ "version": "experimental",
3
+ "tags": [
4
+ {
5
+ "name": "uui-card-block-type",
6
+ "path": "./lib/uui-card-block-type.element.ts",
7
+ "attributes": [
8
+ {
9
+ "name": "name",
10
+ "description": "Block type name",
11
+ "type": "string",
12
+ "default": "\"''\""
13
+ },
14
+ {
15
+ "name": "description",
16
+ "description": "Block type description",
17
+ "type": "string",
18
+ "default": "\"undefined\""
19
+ },
20
+ {
21
+ "name": "background",
22
+ "type": "string | undefined"
23
+ },
24
+ {
25
+ "name": "disabled",
26
+ "description": "Set to true to prevent opening of this item.\nThis does not prevent selection, selection is controlled by property 'selectable'",
27
+ "type": "boolean",
28
+ "default": "\"false\""
29
+ },
30
+ {
31
+ "name": "error",
32
+ "description": "Set to true to highlight there is an error with this item.",
33
+ "type": "boolean",
34
+ "default": "\"false\""
35
+ },
36
+ {
37
+ "name": "href",
38
+ "description": "Set an href, this will turns the name of the card into an anchor tag.",
39
+ "type": "string",
40
+ "default": "\"undefined\""
41
+ },
42
+ {
43
+ "name": "target",
44
+ "description": "Set an anchor tag target, only used when using href.",
45
+ "type": "string",
46
+ "default": "\"undefined\""
47
+ },
48
+ {
49
+ "name": "select-only",
50
+ "description": "Enforce selection interaction and prevent all other interactions, set this when the UI is turned into Selection-Mode.",
51
+ "type": "boolean"
52
+ },
53
+ {
54
+ "name": "selectable",
55
+ "description": "Enable the ability to select this element.",
56
+ "type": "boolean"
57
+ },
58
+ {
59
+ "name": "selected",
60
+ "description": "Attribute applied when the element is selected.",
61
+ "type": "boolean",
62
+ "default": "false"
63
+ }
64
+ ],
65
+ "properties": [
66
+ {
67
+ "name": "name",
68
+ "attribute": "name",
69
+ "description": "Block type name",
70
+ "type": "string",
71
+ "default": "\"''\""
72
+ },
73
+ {
74
+ "name": "description",
75
+ "attribute": "description",
76
+ "description": "Block type description",
77
+ "type": "string",
78
+ "default": "\"undefined\""
79
+ },
80
+ {
81
+ "name": "background",
82
+ "attribute": "background",
83
+ "type": "string | undefined"
84
+ },
85
+ {
86
+ "name": "disabled",
87
+ "attribute": "disabled",
88
+ "description": "Set to true to prevent opening of this item.\nThis does not prevent selection, selection is controlled by property 'selectable'",
89
+ "type": "boolean",
90
+ "default": "\"false\""
91
+ },
92
+ {
93
+ "name": "error",
94
+ "attribute": "error",
95
+ "description": "Set to true to highlight there is an error with this item.",
96
+ "type": "boolean",
97
+ "default": "\"false\""
98
+ },
99
+ {
100
+ "name": "href",
101
+ "attribute": "href",
102
+ "description": "Set an href, this will turns the name of the card into an anchor tag.",
103
+ "type": "string",
104
+ "default": "\"undefined\""
105
+ },
106
+ {
107
+ "name": "target",
108
+ "attribute": "target",
109
+ "description": "Set an anchor tag target, only used when using href.",
110
+ "type": "string",
111
+ "default": "\"undefined\""
112
+ },
113
+ {
114
+ "name": "styles",
115
+ "type": "CSSResult[]",
116
+ "default": "[null,null]"
117
+ },
118
+ {
119
+ "name": "selectOnly",
120
+ "attribute": "select-only",
121
+ "description": "Enforce selection interaction and prevent all other interactions, set this when the UI is turned into Selection-Mode.",
122
+ "type": "boolean"
123
+ },
124
+ {
125
+ "name": "selectable",
126
+ "attribute": "selectable",
127
+ "description": "Enable the ability to select this element.",
128
+ "type": "boolean"
129
+ },
130
+ {
131
+ "name": "selected",
132
+ "attribute": "selected",
133
+ "description": "Attribute applied when the element is selected.",
134
+ "type": "boolean",
135
+ "default": "false"
136
+ }
137
+ ],
138
+ "events": [
139
+ {
140
+ "name": "open",
141
+ "description": "fires when the card title is clicked."
142
+ },
143
+ {
144
+ "name": "selected",
145
+ "description": "fires when the media card is selected"
146
+ },
147
+ {
148
+ "name": "deselected",
149
+ "description": "fires when the media card is deselected"
150
+ }
151
+ ],
152
+ "slots": [
153
+ {
154
+ "name": "",
155
+ "description": "Default content."
156
+ }
157
+ ]
158
+ }
159
+ ]
160
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './uui-card-block-type.element';
package/lib/index.js ADDED
@@ -0,0 +1,195 @@
1
+ import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
2
+ import { css, html, nothing } from 'lit';
3
+ import { UUICardElement } from '@umbraco-ui/uui-card/lib';
4
+ import { styleMap } from 'lit/directives/style-map.js';
5
+ import { ifDefined } from 'lit/directives/if-defined.js';
6
+ import { property } from 'lit/decorators.js';
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
+ var __decorateClass = (decorators, target, key, kind) => {
11
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
12
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
13
+ if (decorator = decorators[i])
14
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
15
+ if (kind && result)
16
+ __defProp(target, key, result);
17
+ return result;
18
+ };
19
+ var __accessCheck = (obj, member, msg) => {
20
+ if (!member.has(obj))
21
+ throw TypeError("Cannot " + msg);
22
+ };
23
+ var __privateAdd = (obj, member, value) => {
24
+ if (member.has(obj))
25
+ throw TypeError("Cannot add the same private member more than once");
26
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
27
+ };
28
+ var __privateMethod = (obj, member, method) => {
29
+ __accessCheck(obj, member, "access private method");
30
+ return method;
31
+ };
32
+ var _renderButton, renderButton_fn, _renderLink, renderLink_fn;
33
+ let UUICardBlockTypeElement = class extends UUICardElement {
34
+ constructor() {
35
+ super(...arguments);
36
+ __privateAdd(this, _renderButton);
37
+ __privateAdd(this, _renderLink);
38
+ this.name = "";
39
+ }
40
+ render() {
41
+ return html`
42
+ <div
43
+ id="portrait"
44
+ style=${styleMap({ backgroundColor: this.background })}>
45
+ <slot></slot>
46
+ </div>
47
+ ${this.href ? __privateMethod(this, _renderLink, renderLink_fn).call(this) : __privateMethod(this, _renderButton, renderButton_fn).call(this)}
48
+
49
+ <slot name="tag"></slot>
50
+ <slot name="actions"></slot>
51
+ `;
52
+ }
53
+ };
54
+ _renderButton = new WeakSet();
55
+ renderButton_fn = function() {
56
+ return html`
57
+ <button
58
+ id="open-part"
59
+ tabindex=${this.disabled ? nothing : "0"}
60
+ @click=${this.handleOpenClick}
61
+ @keydown=${this.handleOpenKeydown}>
62
+ <strong>${this.name}</strong><small>${this.description}</small>
63
+ </button>
64
+ `;
65
+ };
66
+ _renderLink = new WeakSet();
67
+ renderLink_fn = function() {
68
+ return html`
69
+ <a
70
+ id="open-part"
71
+ tabindex=${this.disabled ? nothing : "0"}
72
+ href=${ifDefined(!this.disabled ? this.href : void 0)}
73
+ target=${ifDefined(this.target || void 0)}
74
+ rel=${ifDefined(
75
+ this.target === "_blank" ? "noopener noreferrer" : void 0
76
+ )}>
77
+ <strong>${this.name}</strong><small>${this.description}</small>
78
+ </a>
79
+ `;
80
+ };
81
+ UUICardBlockTypeElement.styles = [
82
+ ...UUICardElement.styles,
83
+ css`
84
+ :host {
85
+ flex-direction: column;
86
+ justify-content: flex-start;
87
+ }
88
+
89
+ :host(:hover) #info {
90
+ color: var(--uui-color-interactive-emphasis,#3544b1);
91
+ }
92
+
93
+ #portrait {
94
+ background-color: var(--uui-color-surface-alt,#f3f3f5);
95
+ display: flex;
96
+ justify-content: center;
97
+ min-height: 150px;
98
+ max-height: 150px;
99
+ }
100
+
101
+ slot:not([name])::slotted(*) {
102
+ align-self: center;
103
+ font-size: var(--uui-size-8,24px);
104
+ border-radius: var(--uui-border-radius,3px);
105
+ object-fit: cover;
106
+ max-width: 100%;
107
+ max-height: 100%;
108
+ }
109
+
110
+ #open-part {
111
+ text-align: left;
112
+ background-color: var(--uui-color-surface,#fff);
113
+ cursor: pointer;
114
+ color: var(--uui-color-interactive,#1b264f);
115
+ border: none;
116
+ border-top: 1px solid var(--uui-color-divider,#f6f6f7);
117
+ border-radius: 0 0 var(--uui-border-radius,3px) var(--uui-border-radius,3px);
118
+ font-family: inherit;
119
+ font-size: var(--uui-type-small-size,12px);
120
+ box-sizing: border-box;
121
+ padding: var(--uui-size-2,6px) var(--uui-size-4,12px);
122
+ display: flex;
123
+ flex-direction: column;
124
+ line-height: var(--uui-size-6,18px);
125
+ }
126
+
127
+ :host([disabled]) #open-part {
128
+ pointer-events: none;
129
+ background: var(--uui-color-disabled,#f3f3f5);
130
+ color: var(--uui-color-contrast-disabled);
131
+ }
132
+
133
+ #open-part:hover strong {
134
+ text-decoration: underline;
135
+ }
136
+ #open-part:hover {
137
+ color: var(--uui-color-interactive-emphasis,#3544b1);
138
+ }
139
+
140
+ :host([image]:not([image=''])) #open-part {
141
+ transition: opacity 0.5s 0.5s;
142
+ opacity: 0;
143
+ }
144
+ slot[name='tag'] {
145
+ position: absolute;
146
+ top: var(--uui-size-4,12px);
147
+ right: var(--uui-size-4,12px);
148
+ display: flex;
149
+ justify-content: right;
150
+ }
151
+
152
+ slot[name='actions'] {
153
+ position: absolute;
154
+ top: var(--uui-size-4,12px);
155
+ right: var(--uui-size-4,12px);
156
+ display: flex;
157
+ justify-content: right;
158
+
159
+ opacity: 0;
160
+ transition: opacity 120ms;
161
+ }
162
+ :host(:focus) slot[name='actions'],
163
+ :host(:focus-within) slot[name='actions'],
164
+ :host(:hover) slot[name='actions'] {
165
+ opacity: 1;
166
+ }
167
+
168
+ :host(
169
+ [image]:not([image='']):hover,
170
+ [image]:not([image='']):focus,
171
+ [image]:not([image='']):focus-within,
172
+ [selected][image]:not([image='']),
173
+ [error][image]:not([image=''])
174
+ )
175
+ #open-part {
176
+ opacity: 1;
177
+ transition-duration: 120ms;
178
+ transition-delay: 0s;
179
+ }
180
+ `
181
+ ];
182
+ __decorateClass([
183
+ property({ type: String })
184
+ ], UUICardBlockTypeElement.prototype, "name", 2);
185
+ __decorateClass([
186
+ property({ type: String })
187
+ ], UUICardBlockTypeElement.prototype, "description", 2);
188
+ __decorateClass([
189
+ property({ type: String, attribute: "background" })
190
+ ], UUICardBlockTypeElement.prototype, "background", 2);
191
+ UUICardBlockTypeElement = __decorateClass([
192
+ defineElement("uui-card-block-type")
193
+ ], UUICardBlockTypeElement);
194
+
195
+ export { UUICardBlockTypeElement };
@@ -0,0 +1,33 @@
1
+ import { UUICardElement } from '@umbraco-ui/uui-card/lib';
2
+ export type BlockTypeIcon = {
3
+ name?: string;
4
+ color?: string;
5
+ };
6
+ /**
7
+ * @element uui-card-block-type
8
+ */
9
+ export declare class UUICardBlockTypeElement extends UUICardElement {
10
+ #private;
11
+ /**
12
+ * Block type name
13
+ * @type {string}
14
+ * @attr name
15
+ * @default ''
16
+ */
17
+ name: string;
18
+ /**
19
+ * Block type description
20
+ * @type {string}
21
+ * @attr description
22
+ * @default undefined
23
+ */
24
+ description?: string;
25
+ background?: string;
26
+ render(): import("lit-html").TemplateResult<1>;
27
+ static styles: import("lit").CSSResult[];
28
+ }
29
+ declare global {
30
+ interface HTMLElementTagNameMap {
31
+ 'uui-card-block-type': UUICardBlockTypeElement;
32
+ }
33
+ }
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@umbraco-ui/uui-card-block-type",
3
+ "version": "1.6.0-rc.2",
4
+ "license": "MIT",
5
+ "keywords": [
6
+ "Umbraco",
7
+ "Custom elements",
8
+ "Web components",
9
+ "UI",
10
+ "Lit",
11
+ "Card Block Type"
12
+ ],
13
+ "description": "Umbraco UI card-block-type component",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/umbraco/Umbraco.UI.git",
17
+ "directory": "packages/uui-card-block-type"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/umbraco/Umbraco.UI/issues"
21
+ },
22
+ "main": "./lib/index.js",
23
+ "module": "./lib/index.js",
24
+ "types": "./lib/index.d.ts",
25
+ "type": "module",
26
+ "customElements": "custom-elements.json",
27
+ "files": [
28
+ "lib/**/*.d.ts",
29
+ "lib/**/*.js",
30
+ "custom-elements.json"
31
+ ],
32
+ "dependencies": {
33
+ "@umbraco-ui/uui-base": "1.6.0-rc.2",
34
+ "@umbraco-ui/uui-card": "1.6.0-rc.2"
35
+ },
36
+ "scripts": {
37
+ "build": "npm run analyze && tsc --build --force && rollup -c rollup.config.js",
38
+ "clean": "tsc --build --clean && rimraf -g dist lib/*.js lib/**/*.js *.tgz lib/**/*.d.ts custom-elements.json",
39
+ "analyze": "web-component-analyzer **/*.element.ts --outFile custom-elements.json"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "homepage": "https://uui.umbraco.com/?path=/story/uui-card-block-type",
45
+ "gitHead": "5d4eefce4744802ab5bc40055b1a3136f0afc520"
46
+ }