@umbraco-ui/uui-card 0.0.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.
- package/LICENSE +21 -0
- package/README.md +19 -0
- package/custom-elements.json +82 -0
- package/lib/UUICardEvent.d.ts +7 -0
- package/lib/uui-card.element.d.ts +36 -0
- package/lib/uui-card.element.js +149 -0
- package/package.json +44 -0
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,19 @@
|
|
|
1
|
+
# uui-card
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### ES imports
|
|
8
|
+
|
|
9
|
+
```zsh
|
|
10
|
+
npm i @umbraco-ui/uui-card
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
import { UUICardElement } from '@umbraco-ui/uui-card/lib/uui-card.element';
|
|
17
|
+
|
|
18
|
+
class MyCardElement extends UUICardElement {}
|
|
19
|
+
```
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "experimental",
|
|
3
|
+
"tags": [
|
|
4
|
+
{
|
|
5
|
+
"name": "uui-card",
|
|
6
|
+
"path": "./lib/uui-card.element.ts",
|
|
7
|
+
"attributes": [
|
|
8
|
+
{
|
|
9
|
+
"name": "disabled",
|
|
10
|
+
"description": "Set to true to prevent opening of this item.\nThis does not prevent selection, selection is controlled by property 'selectable'",
|
|
11
|
+
"type": "boolean",
|
|
12
|
+
"default": "\"false\""
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "error",
|
|
16
|
+
"description": "Set to true to highlight there is an error with this item.",
|
|
17
|
+
"type": "boolean",
|
|
18
|
+
"default": "\"false\""
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "selectable",
|
|
22
|
+
"description": "Set to true if you want to be able to select this particular element on.",
|
|
23
|
+
"type": "boolean"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "selected",
|
|
27
|
+
"description": "Attribute applied when the element is selected.",
|
|
28
|
+
"type": "boolean",
|
|
29
|
+
"default": "false"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"properties": [
|
|
33
|
+
{
|
|
34
|
+
"name": "styles",
|
|
35
|
+
"type": "CSSResult[]",
|
|
36
|
+
"default": "[null]"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "disabled",
|
|
40
|
+
"attribute": "disabled",
|
|
41
|
+
"description": "Set to true to prevent opening of this item.\nThis does not prevent selection, selection is controlled by property 'selectable'",
|
|
42
|
+
"type": "boolean",
|
|
43
|
+
"default": "\"false\""
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"name": "error",
|
|
47
|
+
"attribute": "error",
|
|
48
|
+
"description": "Set to true to highlight there is an error with this item.",
|
|
49
|
+
"type": "boolean",
|
|
50
|
+
"default": "\"false\""
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"name": "selectable",
|
|
54
|
+
"attribute": "selectable",
|
|
55
|
+
"description": "Set to true if you want to be able to select this particular element on.",
|
|
56
|
+
"type": "boolean"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"name": "selected",
|
|
60
|
+
"attribute": "selected",
|
|
61
|
+
"description": "Attribute applied when the element is selected.",
|
|
62
|
+
"type": "boolean",
|
|
63
|
+
"default": "false"
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"events": [
|
|
67
|
+
{
|
|
68
|
+
"name": "open",
|
|
69
|
+
"description": "fires when the media card title is clicked"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"name": "select",
|
|
73
|
+
"description": "fires when the media card is selected"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"name": "unselect",
|
|
77
|
+
"description": "fires when the media card is unselected"
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UUIEvent } from '@umbraco-ui/uui-base/lib/events';
|
|
2
|
+
import { UUICardElement } from './uui-card.element';
|
|
3
|
+
export declare class UUICardEvent extends UUIEvent<{}, UUICardElement> {
|
|
4
|
+
static readonly OPEN = "open";
|
|
5
|
+
static readonly SELECTED = "selected";
|
|
6
|
+
static readonly UNSELECTED = "unselected";
|
|
7
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
declare const UUICardElement_base: (new (...args: any[]) => import("@umbraco-ui/uui-base/lib/mixins").SelectableMixinInterface) & typeof LitElement;
|
|
3
|
+
/**
|
|
4
|
+
* @element uui-card
|
|
5
|
+
* @fires {UUICardEvent} open - fires when the media card title is clicked
|
|
6
|
+
* @fires {UUICardEvent} select - fires when the media card is selected
|
|
7
|
+
* @fires {UUICardEvent} unselect - fires when the media card is unselected
|
|
8
|
+
* @description - Base card component to be extended by specific cards.
|
|
9
|
+
*/
|
|
10
|
+
export declare class UUICardElement extends UUICardElement_base {
|
|
11
|
+
static styles: import("lit").CSSResult[];
|
|
12
|
+
/**
|
|
13
|
+
* Set to true to prevent opening of this item.
|
|
14
|
+
* This does not prevent selection, selection is controlled by property 'selectable'
|
|
15
|
+
* @type {boolean}
|
|
16
|
+
* @attr disabled
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Set to true to highlight there is an error with this item.
|
|
22
|
+
* @type {boolean}
|
|
23
|
+
* @attr error
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
error: boolean;
|
|
27
|
+
constructor();
|
|
28
|
+
private toggleSelect;
|
|
29
|
+
/** TODO: Move these methods to SelectMixin? */
|
|
30
|
+
select(): void;
|
|
31
|
+
deselect(): void;
|
|
32
|
+
private handleSelectKeydown;
|
|
33
|
+
protected handleOpenClick(e: Event): void;
|
|
34
|
+
protected handleOpenKeydown(e: KeyboardEvent): void;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { LitElement, css } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { SelectableMixin } from '@umbraco-ui/uui-base/lib/mixins';
|
|
4
|
+
import { UUIEvent } from '@umbraco-ui/uui-base/lib/events';
|
|
5
|
+
|
|
6
|
+
class UUICardEvent extends UUIEvent {
|
|
7
|
+
}
|
|
8
|
+
UUICardEvent.OPEN = "open";
|
|
9
|
+
UUICardEvent.SELECTED = "selected";
|
|
10
|
+
UUICardEvent.UNSELECTED = "unselected";
|
|
11
|
+
|
|
12
|
+
var __defProp = Object.defineProperty;
|
|
13
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
14
|
+
typeof require !== "undefined" ? require : (x) => {
|
|
15
|
+
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
16
|
+
};
|
|
17
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
18
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
19
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
20
|
+
if (decorator = decorators[i])
|
|
21
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
22
|
+
if (kind && result)
|
|
23
|
+
__defProp(target, key, result);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
class UUICardElement extends SelectableMixin(LitElement) {
|
|
27
|
+
constructor() {
|
|
28
|
+
super();
|
|
29
|
+
this.disabled = false;
|
|
30
|
+
this.error = false;
|
|
31
|
+
this.addEventListener("click", this.toggleSelect);
|
|
32
|
+
this.addEventListener("keydown", this.handleSelectKeydown);
|
|
33
|
+
}
|
|
34
|
+
toggleSelect() {
|
|
35
|
+
if (this.selectable === false)
|
|
36
|
+
return;
|
|
37
|
+
this.selected = !this.selected;
|
|
38
|
+
this.dispatchEvent(new UUICardEvent(this.selected ? UUICardEvent.SELECTED : UUICardEvent.UNSELECTED));
|
|
39
|
+
}
|
|
40
|
+
select() {
|
|
41
|
+
this.selected = true;
|
|
42
|
+
}
|
|
43
|
+
deselect() {
|
|
44
|
+
this.selected = false;
|
|
45
|
+
}
|
|
46
|
+
handleSelectKeydown(e) {
|
|
47
|
+
if (e.key !== " " && e.key !== "Enter")
|
|
48
|
+
return;
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
this.toggleSelect();
|
|
51
|
+
}
|
|
52
|
+
handleOpenClick(e) {
|
|
53
|
+
if (this.disabled)
|
|
54
|
+
return;
|
|
55
|
+
e.stopPropagation();
|
|
56
|
+
this.dispatchEvent(new UUICardEvent(UUICardEvent.OPEN));
|
|
57
|
+
}
|
|
58
|
+
handleOpenKeydown(e) {
|
|
59
|
+
if (this.disabled)
|
|
60
|
+
return;
|
|
61
|
+
if (e.key !== "Enter")
|
|
62
|
+
return;
|
|
63
|
+
e.preventDefault();
|
|
64
|
+
e.stopPropagation();
|
|
65
|
+
this.dispatchEvent(new UUICardEvent(UUICardEvent.OPEN));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
UUICardElement.styles = [
|
|
69
|
+
css`
|
|
70
|
+
:host {
|
|
71
|
+
position: relative;
|
|
72
|
+
display: flex;
|
|
73
|
+
width: 100%;
|
|
74
|
+
justify-content: center;
|
|
75
|
+
box-sizing: border-box;
|
|
76
|
+
/* TODO: fix automatic fallback values for shadows before we use them: var(--uui-shadow-depth-1)*/
|
|
77
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
|
|
78
|
+
border-radius: var(--uui-border-radius,3px);
|
|
79
|
+
min-height: var(--uui-layout-medium);
|
|
80
|
+
background-color: var(--uui-interface-surface,#fefefe);
|
|
81
|
+
--uui-card-border-width: 3px;
|
|
82
|
+
transition: box-shadow 100ms ease-out;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
:host(*) * {
|
|
86
|
+
/* TODO: implement globally shared outline style */
|
|
87
|
+
outline-color: var(--uui-interface-outline,#3879ff);
|
|
88
|
+
outline-offset: 4px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
:host(:focus) {
|
|
92
|
+
outline-color: var(--uui-interface-outline,#3879ff);
|
|
93
|
+
outline-width: var(--uui-card-border-width);
|
|
94
|
+
outline-style: solid;
|
|
95
|
+
outline-offset: var(--uui-card-border-width);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
:host([error]) {
|
|
99
|
+
border: var(--uui-card-border-width) solid var(--uui-look-danger-border,#d42054);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
:host([selectable]) {
|
|
103
|
+
cursor: pointer;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
:host([disabled]) {
|
|
107
|
+
background: var(--uui-interface-surface-disabled,rgb(228, 228, 228));
|
|
108
|
+
color: var(--uui-interface-contrast-disabled,rgb(115, 113, 110));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
:host([selectable])::after {
|
|
112
|
+
content: '';
|
|
113
|
+
position: absolute;
|
|
114
|
+
pointer-events: none;
|
|
115
|
+
inset: calc(var(--uui-card-border-width) * -1);
|
|
116
|
+
width: calc(100% + var(--uui-card-border-width) * 2);
|
|
117
|
+
height: calc(100% + var(--uui-card-border-width) * 2);
|
|
118
|
+
box-sizing: border-box;
|
|
119
|
+
border: var(--uui-card-border-width) solid var(--uui-interface-select,#3544b1);
|
|
120
|
+
border-radius: calc(
|
|
121
|
+
var(--uui-border-radius,3px) + var(--uui-card-border-width)
|
|
122
|
+
);
|
|
123
|
+
transition: opacity 100ms ease-out;
|
|
124
|
+
opacity: 0;
|
|
125
|
+
}
|
|
126
|
+
:host([selectable]:hover)::after {
|
|
127
|
+
opacity: 0.33;
|
|
128
|
+
}
|
|
129
|
+
:host([selectable][selected]:hover)::after {
|
|
130
|
+
opacity: 0.66;
|
|
131
|
+
}
|
|
132
|
+
:host([selectable][selected])::after {
|
|
133
|
+
opacity: 1;
|
|
134
|
+
}
|
|
135
|
+
:host([error])::after {
|
|
136
|
+
inset: calc(var(--uui-card-border-width) * -2);
|
|
137
|
+
width: calc(100% + calc(var(--uui-card-border-width) * 4));
|
|
138
|
+
height: calc(100% + calc(var(--uui-card-border-width) * 4));
|
|
139
|
+
}
|
|
140
|
+
`
|
|
141
|
+
];
|
|
142
|
+
__decorateClass([
|
|
143
|
+
property({ type: Boolean, reflect: true, attribute: "disabled" })
|
|
144
|
+
], UUICardElement.prototype, "disabled", 2);
|
|
145
|
+
__decorateClass([
|
|
146
|
+
property({ type: Boolean, reflect: true })
|
|
147
|
+
], UUICardElement.prototype, "error", 2);
|
|
148
|
+
|
|
149
|
+
export { UUICardElement };
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@umbraco-ui/uui-card",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Umbraco",
|
|
7
|
+
"Custom elements",
|
|
8
|
+
"Web components",
|
|
9
|
+
"UI",
|
|
10
|
+
"Lit",
|
|
11
|
+
"card"
|
|
12
|
+
],
|
|
13
|
+
"description": "",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/umbraco/Umbraco.UI.git",
|
|
17
|
+
"directory": "packages/uui-card"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/umbraco/Umbraco.UI/issues"
|
|
21
|
+
},
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"module": "./lib/index.js",
|
|
24
|
+
"customElements": "custom-elements.json",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"lib/**/*.d.ts",
|
|
28
|
+
"lib/**/*.js",
|
|
29
|
+
"custom-elements.json"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@umbraco-ui/uui-base": "0.0.14"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "npm run analyze && tsc --build --force && rollup -c rollup.config.js",
|
|
36
|
+
"clean": "tsc --build --clean && rimraf dist lib/*.js lib/**/*.js custom-elements.json",
|
|
37
|
+
"analyze": "web-component-analyzer **/*.element.ts --outFile custom-elements.json"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://uui.umbraco.com/?path=/story/uui-card",
|
|
43
|
+
"gitHead": "27d48bb352dcac2b08d55958ecba92b28c11d957"
|
|
44
|
+
}
|