@umbraco-ui/uui-card 0.0.1 → 0.0.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.
@@ -17,9 +17,14 @@
17
17
  "type": "boolean",
18
18
  "default": "\"false\""
19
19
  },
20
+ {
21
+ "name": "select-only",
22
+ "description": "Enforce selection interaction and prevent all other interactions, set this when the UI is turned into Selection-Mode.",
23
+ "type": "boolean"
24
+ },
20
25
  {
21
26
  "name": "selectable",
22
- "description": "Set to true if you want to be able to select this particular element on.",
27
+ "description": "Enable the ability to select this element.",
23
28
  "type": "boolean"
24
29
  },
25
30
  {
@@ -49,10 +54,16 @@
49
54
  "type": "boolean",
50
55
  "default": "\"false\""
51
56
  },
57
+ {
58
+ "name": "selectOnly",
59
+ "attribute": "select-only",
60
+ "description": "Enforce selection interaction and prevent all other interactions, set this when the UI is turned into Selection-Mode.",
61
+ "type": "boolean"
62
+ },
52
63
  {
53
64
  "name": "selectable",
54
65
  "attribute": "selectable",
55
- "description": "Set to true if you want to be able to select this particular element on.",
66
+ "description": "Enable the ability to select this element.",
56
67
  "type": "boolean"
57
68
  },
58
69
  {
@@ -2,6 +2,4 @@ import { UUIEvent } from '@umbraco-ui/uui-base/lib/events';
2
2
  import { UUICardElement } from './uui-card.element';
3
3
  export declare class UUICardEvent extends UUIEvent<{}, UUICardElement> {
4
4
  static readonly OPEN = "open";
5
- static readonly SELECTED = "selected";
6
- static readonly UNSELECTED = "unselected";
7
5
  }
@@ -1,10 +1,10 @@
1
1
  import { LitElement } from 'lit';
2
- declare const UUICardElement_base: (new (...args: any[]) => import("@umbraco-ui/uui-base/lib/mixins").SelectableMixinInterface) & typeof LitElement;
2
+ declare const UUICardElement_base: (new (...args: any[]) => import("@umbraco-ui/uui-base/lib/mixins").SelectOnlyMixinInterface) & (new (...args: any[]) => import("@umbraco-ui/uui-base/lib/mixins").SelectableMixinInterface) & typeof LitElement;
3
3
  /**
4
4
  * @element uui-card
5
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
6
+ * @fires {UUISelectableEvent} select - fires when the media card is selected
7
+ * @fires {UUISelectableEvent} unselect - fires when the media card is unselected
8
8
  * @description - Base card component to be extended by specific cards.
9
9
  */
10
10
  export declare class UUICardElement extends UUICardElement_base {
@@ -24,12 +24,6 @@ export declare class UUICardElement extends UUICardElement_base {
24
24
  * @default false
25
25
  */
26
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
27
  protected handleOpenClick(e: Event): void;
34
28
  protected handleOpenKeydown(e: KeyboardEvent): void;
35
29
  }
@@ -1,19 +1,14 @@
1
1
  import { LitElement, css } from 'lit';
2
2
  import { property } from 'lit/decorators.js';
3
- import { SelectableMixin } from '@umbraco-ui/uui-base/lib/mixins';
3
+ import { SelectOnlyMixin, SelectableMixin } from '@umbraco-ui/uui-base/lib/mixins';
4
4
  import { UUIEvent } from '@umbraco-ui/uui-base/lib/events';
5
5
 
6
6
  class UUICardEvent extends UUIEvent {
7
7
  }
8
8
  UUICardEvent.OPEN = "open";
9
- UUICardEvent.SELECTED = "selected";
10
- UUICardEvent.UNSELECTED = "unselected";
11
9
 
12
10
  var __defProp = Object.defineProperty;
13
11
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
14
- typeof require !== "undefined" ? require : (x) => {
15
- throw new Error('Dynamic require of "' + x + '" is not supported');
16
- };
17
12
  var __decorateClass = (decorators, target, key, kind) => {
18
13
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
19
14
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
@@ -23,31 +18,11 @@ var __decorateClass = (decorators, target, key, kind) => {
23
18
  __defProp(target, key, result);
24
19
  return result;
25
20
  };
26
- class UUICardElement extends SelectableMixin(LitElement) {
21
+ class UUICardElement extends SelectOnlyMixin(SelectableMixin(LitElement)) {
27
22
  constructor() {
28
- super();
23
+ super(...arguments);
29
24
  this.disabled = false;
30
25
  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
26
  }
52
27
  handleOpenClick(e) {
53
28
  if (this.disabled)
@@ -132,11 +107,66 @@ UUICardElement.styles = [
132
107
  :host([selectable][selected])::after {
133
108
  opacity: 1;
134
109
  }
110
+
111
+ :host([selectable]:not([selected]):hover) #select-border::after {
112
+ -webkit-animation: not-selected--hover 1.2s infinite;
113
+ animation: not-selected--hover 1.2s infinite;
114
+ }
115
+ @-webkit-keyframes not-selected--hover {
116
+ 0%,
117
+ 100% {
118
+ opacity: 0.66;
119
+ }
120
+ 50% {
121
+ opacity: 1;
122
+ }
123
+ }
124
+ @keyframes not-selected--hover {
125
+ 0%,
126
+ 100% {
127
+ opacity: 0.66;
128
+ }
129
+ 50% {
130
+ opacity: 1;
131
+ }
132
+ }
133
+
134
+ :host([selectable][selected]:hover) #select-border::after {
135
+ -webkit-animation: selected--hover 1.4s infinite;
136
+ animation: selected--hover 1.4s infinite;
137
+ }
138
+ @-webkit-keyframes selected--hover {
139
+ 0%,
140
+ 100% {
141
+ opacity: 1;
142
+ }
143
+ 50% {
144
+ opacity: 0.66;
145
+ }
146
+ }
147
+ @keyframes selected--hover {
148
+ 0%,
149
+ 100% {
150
+ opacity: 1;
151
+ }
152
+ 50% {
153
+ opacity: 0.66;
154
+ }
155
+ }
156
+ :host([selectable]) #open-part:hover + #select-border::after {
157
+ -webkit-animation: none;
158
+ animation: none;
159
+ }
135
160
  :host([error])::after {
136
161
  inset: calc(var(--uui-card-border-width) * -2);
137
162
  width: calc(100% + calc(var(--uui-card-border-width) * 4));
138
163
  height: calc(100% + calc(var(--uui-card-border-width) * 4));
139
164
  }
165
+
166
+ :host([select-only]) *,
167
+ :host([select-only]) ::slotted(*) {
168
+ pointer-events: none;
169
+ }
140
170
  `
141
171
  ];
142
172
  __decorateClass([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umbraco-ui/uui-card",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "Umbraco",
@@ -29,7 +29,7 @@
29
29
  "custom-elements.json"
30
30
  ],
31
31
  "dependencies": {
32
- "@umbraco-ui/uui-base": "0.0.14"
32
+ "@umbraco-ui/uui-base": "0.0.15"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "npm run analyze && tsc --build --force && rollup -c rollup.config.js",
@@ -40,5 +40,5 @@
40
40
  "access": "public"
41
41
  },
42
42
  "homepage": "https://uui.umbraco.com/?path=/story/uui-card",
43
- "gitHead": "27d48bb352dcac2b08d55958ecba92b28c11d957"
43
+ "gitHead": "2a640ce4460de94e9c92a97310e27b84bbd6edda"
44
44
  }