@daikin-oss/design-system-web-components 1.0.0 → 1.1.0
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/CHANGELOG.md +18 -0
- package/dist/cjs/base/dds-element.cjs +1 -1
- package/dist/cjs/components/avatar/daikin-avatar.cjs +160 -0
- package/dist/cjs/components/avatar/daikin-avatar.d.cts +64 -0
- package/dist/cjs/components/avatar/index.cjs +7 -0
- package/dist/cjs/components/avatar/index.d.cts +1 -0
- package/dist/cjs/components/checkbox/daikin-checkbox.cjs +1 -0
- package/dist/cjs/components/checkbox/daikin-checkbox.d.cts +4 -0
- package/dist/cjs/components/dropdown/daikin-dropdown.cjs +145 -69
- package/dist/cjs/components/dropdown/daikin-dropdown.d.cts +48 -9
- package/dist/cjs/components/dropdown-item/daikin-dropdown-item.cjs +97 -36
- package/dist/cjs/components/dropdown-item/daikin-dropdown-item.d.cts +6 -1
- package/dist/cjs/components/icon/icons.json.cjs +1 -1
- package/dist/cjs/components/icon/icons.json.d.cts +4 -0
- package/dist/cjs/components/index.cjs +10 -0
- package/dist/cjs/components/index.d.cts +2 -0
- package/dist/cjs/components/loading/daikin-loading.cjs +91 -0
- package/dist/cjs/components/loading/daikin-loading.d.cts +32 -0
- package/dist/cjs/components/loading/index.cjs +7 -0
- package/dist/cjs/components/loading/index.d.cts +1 -0
- package/dist/cjs/index.cjs +10 -0
- package/dist/cjs/tailwind.css.cjs +1 -1
- package/dist/cjs/utils/is-similar-to-click.cjs +4 -0
- package/dist/cjs/utils/is-similar-to-click.d.cts +1 -0
- package/dist/cjs-dev/base/dds-element.cjs +1 -1
- package/dist/cjs-dev/components/avatar/daikin-avatar.cjs +160 -0
- package/dist/cjs-dev/components/avatar/daikin-avatar.d.cts +64 -0
- package/dist/cjs-dev/components/avatar/index.cjs +7 -0
- package/dist/cjs-dev/components/avatar/index.d.cts +1 -0
- package/dist/cjs-dev/components/checkbox/daikin-checkbox.cjs +1 -0
- package/dist/cjs-dev/components/checkbox/daikin-checkbox.d.cts +4 -0
- package/dist/cjs-dev/components/dropdown/daikin-dropdown.cjs +145 -69
- package/dist/cjs-dev/components/dropdown/daikin-dropdown.d.cts +48 -9
- package/dist/cjs-dev/components/dropdown-item/daikin-dropdown-item.cjs +97 -36
- package/dist/cjs-dev/components/dropdown-item/daikin-dropdown-item.d.cts +6 -1
- package/dist/cjs-dev/components/icon/icons.json.cjs +1 -1
- package/dist/cjs-dev/components/icon/icons.json.d.cts +4 -0
- package/dist/cjs-dev/components/index.cjs +10 -0
- package/dist/cjs-dev/components/index.d.cts +2 -0
- package/dist/cjs-dev/components/loading/daikin-loading.cjs +91 -0
- package/dist/cjs-dev/components/loading/daikin-loading.d.cts +32 -0
- package/dist/cjs-dev/components/loading/index.cjs +7 -0
- package/dist/cjs-dev/components/loading/index.d.cts +1 -0
- package/dist/cjs-dev/index.cjs +10 -0
- package/dist/cjs-dev/tailwind.css.cjs +1 -1
- package/dist/cjs-dev/utils/is-similar-to-click.cjs +4 -0
- package/dist/cjs-dev/utils/is-similar-to-click.d.cts +1 -0
- package/dist/es/base/dds-element.js +1 -1
- package/dist/es/components/avatar/daikin-avatar.d.ts +64 -0
- package/dist/es/components/avatar/daikin-avatar.js +161 -0
- package/dist/es/components/avatar/index.d.ts +1 -0
- package/dist/es/components/avatar/index.js +4 -0
- package/dist/es/components/checkbox/daikin-checkbox.d.ts +4 -0
- package/dist/es/components/checkbox/daikin-checkbox.js +1 -0
- package/dist/es/components/dropdown/daikin-dropdown.d.ts +48 -9
- package/dist/es/components/dropdown/daikin-dropdown.js +145 -69
- package/dist/es/components/dropdown-item/daikin-dropdown-item.d.ts +6 -1
- package/dist/es/components/dropdown-item/daikin-dropdown-item.js +97 -36
- package/dist/es/components/icon/icons.json.d.ts +4 -0
- package/dist/es/components/icon/icons.json.js +1 -1
- package/dist/es/components/index.d.ts +2 -0
- package/dist/es/components/index.js +4 -0
- package/dist/es/components/loading/daikin-loading.d.ts +32 -0
- package/dist/es/components/loading/daikin-loading.js +92 -0
- package/dist/es/components/loading/index.d.ts +1 -0
- package/dist/es/components/loading/index.js +4 -0
- package/dist/es/index.js +4 -0
- package/dist/es/tailwind.css.js +1 -1
- package/dist/es/utils/is-similar-to-click.d.ts +1 -0
- package/dist/es/utils/is-similar-to-click.js +4 -0
- package/dist/es-dev/base/dds-element.js +1 -1
- package/dist/es-dev/components/avatar/daikin-avatar.d.ts +64 -0
- package/dist/es-dev/components/avatar/daikin-avatar.js +161 -0
- package/dist/es-dev/components/avatar/index.d.ts +1 -0
- package/dist/es-dev/components/avatar/index.js +4 -0
- package/dist/es-dev/components/checkbox/daikin-checkbox.d.ts +4 -0
- package/dist/es-dev/components/checkbox/daikin-checkbox.js +1 -0
- package/dist/es-dev/components/dropdown/daikin-dropdown.d.ts +48 -9
- package/dist/es-dev/components/dropdown/daikin-dropdown.js +145 -69
- package/dist/es-dev/components/dropdown-item/daikin-dropdown-item.d.ts +6 -1
- package/dist/es-dev/components/dropdown-item/daikin-dropdown-item.js +97 -36
- package/dist/es-dev/components/icon/icons.json.d.ts +4 -0
- package/dist/es-dev/components/icon/icons.json.js +1 -1
- package/dist/es-dev/components/index.d.ts +2 -0
- package/dist/es-dev/components/index.js +4 -0
- package/dist/es-dev/components/loading/daikin-loading.d.ts +32 -0
- package/dist/es-dev/components/loading/daikin-loading.js +92 -0
- package/dist/es-dev/components/loading/index.d.ts +1 -0
- package/dist/es-dev/components/loading/index.js +4 -0
- package/dist/es-dev/index.js +4 -0
- package/dist/es-dev/tailwind.css.js +1 -1
- package/dist/es-dev/utils/is-similar-to-click.d.ts +1 -0
- package/dist/es-dev/utils/is-similar-to-click.js +4 -0
- package/icons/profile.svg +4 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @daikin-oss/design-system-web-components
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#153](https://github.com/dsv-rp/DDS/pull/153) [`8fe1ed0`](https://github.com/dsv-rp/DDS/commit/8fe1ed0d692f9f85a2c173adeb2111b7715f9f61) Thanks [@poetrainy](https://github.com/poetrainy)! - Loading: Initial Implementation. (DDS-1716)
|
|
8
|
+
|
|
9
|
+
- [#154](https://github.com/dsv-rp/DDS/pull/154) [`2ad908a`](https://github.com/dsv-rp/DDS/commit/2ad908a4bec6c42414c7427f9262b506aa153c0b) Thanks [@rinjInTokyo](https://github.com/rinjInTokyo)! - Avatar: Initial Implementation. (DDS-1880)
|
|
10
|
+
|
|
11
|
+
- [#121](https://github.com/dsv-rp/DDS/pull/121) [`72c8153`](https://github.com/dsv-rp/DDS/commit/72c81538970bbd341e5ff6bd25b886cc5056ba42) Thanks [@poetrainy](https://github.com/poetrainy)! - Dropdown: The `multiple`, `selectedOptions` and `maxLabels` properties have been added. (DDS-1695)
|
|
12
|
+
Dropdown Item: The `selectable` property has been added. (DDS-1695)
|
|
13
|
+
Checkbox: The `label` CSS part has been added. (DDS-1695)
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#165](https://github.com/dsv-rp/DDS/pull/165) [`d4895ec`](https://github.com/dsv-rp/DDS/commit/d4895eccd896abd6e2ff16b18f61e7acd9d5026f) Thanks [@yodas7](https://github.com/yodas7)! - Removed Provenance.
|
|
18
|
+
|
|
19
|
+
- [#121](https://github.com/dsv-rp/DDS/pull/121) [`72c8153`](https://github.com/dsv-rp/DDS/commit/72c81538970bbd341e5ff6bd25b886cc5056ba42) Thanks [@poetrainy](https://github.com/poetrainy)! - Dropdown: Updated appearance. (DDS-1870)
|
|
20
|
+
|
|
3
21
|
## 1.0.0
|
|
4
22
|
|
|
5
23
|
### Major Changes
|
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const lit = require("lit");
|
|
4
4
|
const _DDSElement = class _DDSElement extends lit.LitElement {
|
|
5
5
|
};
|
|
6
|
-
_DDSElement.version = "1.
|
|
6
|
+
_DDSElement.version = "1.1.0";
|
|
7
7
|
let DDSElement = _DDSElement;
|
|
8
8
|
exports.DDSElement = DDSElement;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const classVarianceAuthority = require("class-variance-authority");
|
|
4
|
+
const lit = require("lit");
|
|
5
|
+
const decorators_js = require("lit/decorators.js");
|
|
6
|
+
const ifDefined_js = require("lit/directives/if-defined.js");
|
|
7
|
+
const tailwind = require("../../tailwind.css.cjs");
|
|
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) __defProp(target, key, result);
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
const cvaWrapper = classVarianceAuthority.cva(
|
|
19
|
+
[
|
|
20
|
+
"inline-block",
|
|
21
|
+
"rounded-full",
|
|
22
|
+
"relative",
|
|
23
|
+
"overflow-hidden",
|
|
24
|
+
"box-border",
|
|
25
|
+
"size-full",
|
|
26
|
+
"focus-visible:outline",
|
|
27
|
+
"focus-visible:outline-2",
|
|
28
|
+
"focus-visible:outline-offset-2",
|
|
29
|
+
"focus-visible:outline-ddt-color-common-border-focus"
|
|
30
|
+
],
|
|
31
|
+
{
|
|
32
|
+
variants: {
|
|
33
|
+
type: {
|
|
34
|
+
button: [
|
|
35
|
+
"enabled:bg-ddt-color-common-neutral-default",
|
|
36
|
+
"enabled:text-ddt-color-common-surface-default",
|
|
37
|
+
"enabled:hover:bg-ddt-color-common-neutral-hover",
|
|
38
|
+
"enabled:hover:text-ddt-color-common-surface-hover",
|
|
39
|
+
"enabled:active:bg-ddt-color-common-neutral-press",
|
|
40
|
+
"enabled:active:text-ddt-color-common-surface-press",
|
|
41
|
+
"disabled:bg-ddt-color-common-disabled",
|
|
42
|
+
"disabled:text-ddt-color-common-surface-default"
|
|
43
|
+
],
|
|
44
|
+
icon: [
|
|
45
|
+
"bg-ddt-color-common-neutral-default",
|
|
46
|
+
"text-ddt-color-common-surface-default"
|
|
47
|
+
],
|
|
48
|
+
link: [
|
|
49
|
+
"link-enabled:bg-ddt-color-common-neutral-default",
|
|
50
|
+
"link-enabled:text-ddt-color-common-surface-default",
|
|
51
|
+
"link-enabled:hover:bg-ddt-color-common-neutral-hover",
|
|
52
|
+
"link-enabled:hover:text-ddt-color-common-surface-hover",
|
|
53
|
+
"link-enabled:active:bg-ddt-color-common-neutral-press",
|
|
54
|
+
"link-enabled:active:text-ddt-color-common-surface-press",
|
|
55
|
+
"link-disabled:bg-ddt-color-common-disabled",
|
|
56
|
+
"link-disabled:text-ddt-color-common-surface-default"
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
exports.DaikinAvatar = class DaikinAvatar extends lit.LitElement {
|
|
63
|
+
constructor() {
|
|
64
|
+
super();
|
|
65
|
+
this.type = "icon";
|
|
66
|
+
this.href = null;
|
|
67
|
+
this.alt = null;
|
|
68
|
+
this.disabled = false;
|
|
69
|
+
this.avatarAriaHaspopup = null;
|
|
70
|
+
this.avatarAriaExpanded = null;
|
|
71
|
+
this.addEventListener("click", (event) => {
|
|
72
|
+
if (this.disabled || this.type === "link" && this.href == null) {
|
|
73
|
+
event.stopImmediatePropagation();
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
render() {
|
|
78
|
+
const icon = lit.html`
|
|
79
|
+
<span
|
|
80
|
+
class="i-daikin-profile"
|
|
81
|
+
>
|
|
82
|
+
</span>
|
|
83
|
+
</daikin-icon>`;
|
|
84
|
+
if (this.type === "icon") {
|
|
85
|
+
return lit.html`<span
|
|
86
|
+
class=${cvaWrapper({ type: "icon" })}
|
|
87
|
+
role="figure"
|
|
88
|
+
aria-label=${ifDefined_js.ifDefined(this.alt ?? void 0)}
|
|
89
|
+
>
|
|
90
|
+
${icon}
|
|
91
|
+
</span>`;
|
|
92
|
+
} else if (this.type === "button") {
|
|
93
|
+
return lit.html`<button
|
|
94
|
+
class=${cvaWrapper({ type: "button" })}
|
|
95
|
+
aria-label=${ifDefined_js.ifDefined(this.alt ?? void 0)}
|
|
96
|
+
aria-haspopup=${ifDefined_js.ifDefined(this.avatarAriaHaspopup ?? void 0)}
|
|
97
|
+
aria-expanded=${ifDefined_js.ifDefined(this.avatarAriaExpanded ?? void 0)}
|
|
98
|
+
?disabled=${this.disabled}
|
|
99
|
+
>
|
|
100
|
+
${icon}
|
|
101
|
+
</button>`;
|
|
102
|
+
} else {
|
|
103
|
+
const linkDisabled = this.disabled || this.href == null;
|
|
104
|
+
return lit.html`<a
|
|
105
|
+
class=${cvaWrapper({ type: "link" })}
|
|
106
|
+
role=${ifDefined_js.ifDefined(linkDisabled ? "link" : void 0)}
|
|
107
|
+
aria-label=${ifDefined_js.ifDefined(this.alt ?? void 0)}
|
|
108
|
+
href=${ifDefined_js.ifDefined(!linkDisabled ? this.href ?? void 0 : void 0)}
|
|
109
|
+
aria-disabled=${ifDefined_js.ifDefined(linkDisabled ? "true" : void 0)}
|
|
110
|
+
>
|
|
111
|
+
${icon}
|
|
112
|
+
</a>`;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Focuses on the inner button or link.
|
|
117
|
+
* @param options focus options
|
|
118
|
+
*/
|
|
119
|
+
focus(options) {
|
|
120
|
+
var _a;
|
|
121
|
+
(_a = this._focusableElement) == null ? void 0 : _a.focus(options);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
exports.DaikinAvatar.styles = lit.css`
|
|
125
|
+
${lit.unsafeCSS(tailwind.default)}
|
|
126
|
+
|
|
127
|
+
:host {
|
|
128
|
+
display: inline-flex;
|
|
129
|
+
position: relative;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
:host {
|
|
133
|
+
width: 2.5rem;
|
|
134
|
+
height: 2.5rem;
|
|
135
|
+
}
|
|
136
|
+
`;
|
|
137
|
+
__decorateClass([
|
|
138
|
+
decorators_js.property({ type: String, reflect: true })
|
|
139
|
+
], exports.DaikinAvatar.prototype, "type", 2);
|
|
140
|
+
__decorateClass([
|
|
141
|
+
decorators_js.property({ type: String, reflect: true })
|
|
142
|
+
], exports.DaikinAvatar.prototype, "href", 2);
|
|
143
|
+
__decorateClass([
|
|
144
|
+
decorators_js.property({ type: String, reflect: true })
|
|
145
|
+
], exports.DaikinAvatar.prototype, "alt", 2);
|
|
146
|
+
__decorateClass([
|
|
147
|
+
decorators_js.property({ type: Boolean, reflect: true })
|
|
148
|
+
], exports.DaikinAvatar.prototype, "disabled", 2);
|
|
149
|
+
__decorateClass([
|
|
150
|
+
decorators_js.property({ type: String, reflect: true, attribute: "avatar-aria-haspopup" })
|
|
151
|
+
], exports.DaikinAvatar.prototype, "avatarAriaHaspopup", 2);
|
|
152
|
+
__decorateClass([
|
|
153
|
+
decorators_js.property({ type: Boolean, reflect: true, attribute: "avatar-aria-expanded" })
|
|
154
|
+
], exports.DaikinAvatar.prototype, "avatarAriaExpanded", 2);
|
|
155
|
+
__decorateClass([
|
|
156
|
+
decorators_js.query("a,button")
|
|
157
|
+
], exports.DaikinAvatar.prototype, "_focusableElement", 2);
|
|
158
|
+
exports.DaikinAvatar = __decorateClass([
|
|
159
|
+
decorators_js.customElement("daikin-avatar")
|
|
160
|
+
], exports.DaikinAvatar);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { MergeVariantProps } from "../../type-utils.cjs";
|
|
3
|
+
declare const cvaWrapper: (props?: ({
|
|
4
|
+
type?: "button" | "icon" | "link" | null | undefined;
|
|
5
|
+
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
6
|
+
type AvatarVariantProps = MergeVariantProps<typeof cvaWrapper>;
|
|
7
|
+
/**
|
|
8
|
+
* The avatar is a UI element that represent a user
|
|
9
|
+
*
|
|
10
|
+
* @fires click - A retargeted event of a [click event](https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event) emitted from the inner `<button>` element. Suppressed if `disabled` is true,
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
*
|
|
14
|
+
* ```js
|
|
15
|
+
* import "@daikin-oss/design-system-web-components/components/avatar/index.js";
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* ```html
|
|
19
|
+
* <daikin-avatar></daikin-avatar>
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class DaikinAvatar extends LitElement {
|
|
23
|
+
static readonly styles: import('lit').CSSResult;
|
|
24
|
+
/**
|
|
25
|
+
* Replace the wrapping element.
|
|
26
|
+
*/
|
|
27
|
+
type: AvatarVariantProps["type"];
|
|
28
|
+
/**
|
|
29
|
+
* Link `href`.
|
|
30
|
+
* Only used if the `type` is `"link"`.
|
|
31
|
+
* If omitted with `type="link"`, the link will be treated type [a placeholder link](https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-a-element:~:text=If%20the%20a%20element%20has%20no%20href%20attribute) and rendered type disabled state.
|
|
32
|
+
*/
|
|
33
|
+
href: string | null;
|
|
34
|
+
/**
|
|
35
|
+
* Provides an accessible name of the avatar.
|
|
36
|
+
*/
|
|
37
|
+
alt: string | null;
|
|
38
|
+
/**
|
|
39
|
+
* Specify the avatar disabled state.
|
|
40
|
+
*/
|
|
41
|
+
disabled: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The aria-haspopup of the avatar when `type="button"`.
|
|
44
|
+
*/
|
|
45
|
+
avatarAriaHaspopup: "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | null;
|
|
46
|
+
/**
|
|
47
|
+
* The aria-expanded of avatar when `type="button"`.
|
|
48
|
+
*/
|
|
49
|
+
avatarAriaExpanded: boolean | null;
|
|
50
|
+
private _focusableElement;
|
|
51
|
+
constructor();
|
|
52
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
53
|
+
/**
|
|
54
|
+
* Focuses on the inner button or link.
|
|
55
|
+
* @param options focus options
|
|
56
|
+
*/
|
|
57
|
+
focus(options?: FocusOptions): void;
|
|
58
|
+
}
|
|
59
|
+
declare global {
|
|
60
|
+
interface HTMLElementTagNameMap {
|
|
61
|
+
"daikin-avatar": DaikinAvatar;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./daikin-avatar.cjs";
|
|
@@ -119,6 +119,7 @@ exports.DaikinCheckbox = class DaikinCheckbox extends ddsElement.DDSElement {
|
|
|
119
119
|
render() {
|
|
120
120
|
return lit.html`<label
|
|
121
121
|
class="group flex gap-2 items-center size-full font-daikinSerif"
|
|
122
|
+
part="label"
|
|
122
123
|
@click=${this._handleClick}
|
|
123
124
|
>
|
|
124
125
|
<span class="p-2">
|
|
@@ -7,6 +7,10 @@ import { DDSElement } from "../../base/index.cjs";
|
|
|
7
7
|
*
|
|
8
8
|
* @fires change - A cloned event of a [change event](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event) emitted from the inner `<input type="checkbox">` element.
|
|
9
9
|
*
|
|
10
|
+
* @slot - A slot for the checkbox label content.
|
|
11
|
+
*
|
|
12
|
+
* @csspart label - Change the style of checkbox label.
|
|
13
|
+
*
|
|
10
14
|
* @example
|
|
11
15
|
*
|
|
12
16
|
* ```js
|
|
@@ -5,12 +5,14 @@ const classVarianceAuthority = require("class-variance-authority");
|
|
|
5
5
|
const lit = require("lit");
|
|
6
6
|
const decorators_js = require("lit/decorators.js");
|
|
7
7
|
const ifDefined_js = require("lit/directives/if-defined.js");
|
|
8
|
+
const ref_js = require("lit/directives/ref.js");
|
|
8
9
|
const ddsElement = require("../../base/dds-element.cjs");
|
|
9
10
|
const decorators = require("../../base/decorators.cjs");
|
|
10
11
|
require("../../base/define.cjs");
|
|
11
12
|
const clickOutside = require("../../controllers/click-outside.cjs");
|
|
12
13
|
const floatingUiAutoUpdate = require("../../controllers/floating-ui-auto-update.cjs");
|
|
13
14
|
const tailwind = require("../../tailwind.css.cjs");
|
|
15
|
+
const isSimpleKey = require("../../utils/is-simple-key.cjs");
|
|
14
16
|
var __defProp = Object.defineProperty;
|
|
15
17
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
16
18
|
var __decorateClass = (decorators2, target, key, kind) => {
|
|
@@ -24,36 +26,34 @@ var __decorateClass = (decorators2, target, key, kind) => {
|
|
|
24
26
|
const cvaButton = classVarianceAuthority.cva(
|
|
25
27
|
[
|
|
26
28
|
"flex",
|
|
29
|
+
"justify-between",
|
|
27
30
|
"items-center",
|
|
28
31
|
"gap-2",
|
|
29
32
|
"w-full",
|
|
30
33
|
"h-full",
|
|
31
34
|
"min-h-12",
|
|
32
35
|
"bg-ddt-color-common-background-default",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
+
"py-3",
|
|
37
|
+
"pl-4",
|
|
38
|
+
"pr-3",
|
|
36
39
|
"rounded",
|
|
37
40
|
"overflow-hidden",
|
|
38
41
|
"font-daikinSerif",
|
|
39
42
|
"text-left",
|
|
40
|
-
"leading-
|
|
43
|
+
"leading-[130%]",
|
|
41
44
|
"relative",
|
|
42
45
|
"outline",
|
|
43
|
-
"outline-
|
|
44
|
-
"-outline-offset-
|
|
46
|
+
"outline-1",
|
|
47
|
+
"-outline-offset-1",
|
|
45
48
|
"focus-visible:outline-2",
|
|
46
|
-
"focus-visible
|
|
49
|
+
"focus-visible:-outline-offset-2",
|
|
50
|
+
"enabled:outline-[--color-base]",
|
|
47
51
|
"disabled:text-ddt-color-common-disabled",
|
|
48
|
-
"disabled:
|
|
52
|
+
"disabled:outline-ddt-color-common-disabled",
|
|
49
53
|
"after:i-daikin-dropdown-chevron-down",
|
|
50
|
-
"after:
|
|
51
|
-
"after:
|
|
52
|
-
"after:
|
|
53
|
-
"after:m-auto",
|
|
54
|
-
"after:top-0",
|
|
55
|
-
"after:bottom-0",
|
|
56
|
-
"after:right-3",
|
|
54
|
+
"after:size-6",
|
|
55
|
+
"after:flex-none",
|
|
56
|
+
"after:ml-auto",
|
|
57
57
|
"enabled:after:text-ddt-color-common-text-primary",
|
|
58
58
|
"disabled:after:text-ddt-color-common-disabled"
|
|
59
59
|
],
|
|
@@ -64,17 +64,19 @@ const cvaButton = classVarianceAuthority.cva(
|
|
|
64
64
|
"enabled:hover:bg-ddt-color-common-surface-hover",
|
|
65
65
|
"enabled:active:bg-ddt-color-common-surface-press"
|
|
66
66
|
],
|
|
67
|
-
true: [
|
|
67
|
+
true: [
|
|
68
|
+
"enabled:bg-ddt-color-common-surface-press",
|
|
69
|
+
"after:scale-y-[-1]"
|
|
70
|
+
]
|
|
68
71
|
},
|
|
69
72
|
error: {
|
|
70
73
|
false: [
|
|
71
74
|
"var-color-ddt-color-common-neutral-default/color-base",
|
|
72
|
-
"var-color-ddt-color-common-
|
|
75
|
+
"hover:var-color-ddt-color-common-neutral-hover/color-base",
|
|
76
|
+
"active:var-color-ddt-color-common-neutral-press/color-base",
|
|
77
|
+
"focus-visible:var-color-ddt-color-common-border-focus/color-base"
|
|
73
78
|
],
|
|
74
|
-
true: [
|
|
75
|
-
"var-color-ddt-color-common-danger-default/color-base",
|
|
76
|
-
"var-color-ddt-color-common-danger-default/color-focus"
|
|
77
|
-
]
|
|
79
|
+
true: ["var-color-ddt-color-common-danger-default/color-base"]
|
|
78
80
|
},
|
|
79
81
|
placeholder: {
|
|
80
82
|
false: ["text-ddt-color-common-text-primary"],
|
|
@@ -108,37 +110,31 @@ exports.DaikinDropdown = class DaikinDropdown extends ddsElement.DDSElement {
|
|
|
108
110
|
this.required = false;
|
|
109
111
|
this.error = false;
|
|
110
112
|
this.open = false;
|
|
113
|
+
this.multiple = false;
|
|
114
|
+
this.selectedOptions = [];
|
|
115
|
+
this.maxLabels = null;
|
|
111
116
|
this._label = null;
|
|
112
|
-
this.
|
|
113
|
-
this._selectedItemLabel = "";
|
|
117
|
+
this._initialUpdateCompleted = false;
|
|
114
118
|
this._autoUpdateController = new floatingUiAutoUpdate.FloatingUIAutoUpdateController(this);
|
|
115
119
|
this._clickOutsideController = new clickOutside.ClickOutsideController(
|
|
116
120
|
this,
|
|
117
121
|
this._onClickOutside
|
|
118
122
|
);
|
|
119
123
|
this._lastFocusedItem = null;
|
|
124
|
+
this._dropdownRef = ref_js.createRef();
|
|
120
125
|
}
|
|
121
|
-
|
|
122
|
-
this.
|
|
126
|
+
get _selectionLabels() {
|
|
127
|
+
const items = this._items;
|
|
128
|
+
return this.selectedOptions.map(
|
|
129
|
+
(value) => {
|
|
130
|
+
var _a;
|
|
131
|
+
return ((_a = items.find((item) => item.value === value)) == null ? void 0 : _a.textContent) ?? "";
|
|
132
|
+
}
|
|
133
|
+
);
|
|
123
134
|
}
|
|
124
135
|
_onClickOutside() {
|
|
125
136
|
this.open = false;
|
|
126
137
|
}
|
|
127
|
-
_reflectItemsAndLabel() {
|
|
128
|
-
const items = this._items;
|
|
129
|
-
const selectedItem = items.find((item) => item.value === this.value);
|
|
130
|
-
for (const item of items) {
|
|
131
|
-
item.selected = item === selectedItem;
|
|
132
|
-
}
|
|
133
|
-
this._hasSelectedItem = !!selectedItem;
|
|
134
|
-
this._selectedItemLabel = (selectedItem == null ? void 0 : selectedItem.textContent) ?? "";
|
|
135
|
-
}
|
|
136
|
-
_handleClick() {
|
|
137
|
-
if (this.disabled) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
this.open = !this.open;
|
|
141
|
-
}
|
|
142
138
|
_searchItem(prefix) {
|
|
143
139
|
const items = this._items.filter(
|
|
144
140
|
(item) => {
|
|
@@ -160,13 +156,6 @@ exports.DaikinDropdown = class DaikinDropdown extends ddsElement.DDSElement {
|
|
|
160
156
|
this.open = true;
|
|
161
157
|
}
|
|
162
158
|
}
|
|
163
|
-
_handleKeyDownEscape() {
|
|
164
|
-
if (this.open) {
|
|
165
|
-
this.open = false;
|
|
166
|
-
} else {
|
|
167
|
-
this.value = null;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
159
|
_moveFocus(moveOffset) {
|
|
171
160
|
if (!this.open) {
|
|
172
161
|
this.open = true;
|
|
@@ -188,7 +177,56 @@ exports.DaikinDropdown = class DaikinDropdown extends ddsElement.DDSElement {
|
|
|
188
177
|
break;
|
|
189
178
|
}
|
|
190
179
|
}
|
|
180
|
+
_updateFormValue() {
|
|
181
|
+
this._internals.setFormValue(JSON.stringify(this.value));
|
|
182
|
+
}
|
|
183
|
+
_updateItemsSelectable() {
|
|
184
|
+
for (const item of this._items) {
|
|
185
|
+
item.selectable = this.multiple;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
_updateValueBySelectedOptions() {
|
|
189
|
+
this.value = this.selectedOptions.at(-1) ?? null;
|
|
190
|
+
}
|
|
191
|
+
_updateSelectedOptionsByValue() {
|
|
192
|
+
this.selectedOptions = this.value ? [this.value] : [];
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Handling for when an option is selected.
|
|
196
|
+
* If multiple selection is enabled, the specified option is added to or removed from the array of selected options.
|
|
197
|
+
* If multiple selection is disabled, the current value is set to the specified option. The selection is not cleared.
|
|
198
|
+
*
|
|
199
|
+
* @param value The value of selected option.
|
|
200
|
+
*/
|
|
201
|
+
_handleSelectOption(value) {
|
|
202
|
+
this.value = value;
|
|
203
|
+
this.selectedOptions = this.multiple ? this.selectedOptions.includes(value) ? this.selectedOptions.filter((option) => option != value) : [...this.selectedOptions, value] : [value];
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Removes the last selected option.
|
|
207
|
+
*
|
|
208
|
+
* If multiple selection is enabled, remove the last selected option and the array will eventually become empty.
|
|
209
|
+
* If multiple selection is disabled, directly empty the selected options.
|
|
210
|
+
*/
|
|
211
|
+
_removeLastSelection() {
|
|
212
|
+
if (this.multiple) {
|
|
213
|
+
this.selectedOptions = this.selectedOptions.slice(0, -1);
|
|
214
|
+
this.value = this.selectedOptions.at(-1) ?? null;
|
|
215
|
+
} else {
|
|
216
|
+
this.selectedOptions = [];
|
|
217
|
+
this.value = null;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
_handleClick() {
|
|
221
|
+
if (this.disabled) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
this.open = !this.open;
|
|
225
|
+
}
|
|
191
226
|
_handleKeyDown(event) {
|
|
227
|
+
if (!isSimpleKey.isSimpleKeyEvent(event)) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
192
230
|
const printableCharacter = event.key.trim().length === 1 ? event.key : null;
|
|
193
231
|
if (printableCharacter) {
|
|
194
232
|
event.preventDefault();
|
|
@@ -212,19 +250,12 @@ exports.DaikinDropdown = class DaikinDropdown extends ddsElement.DDSElement {
|
|
|
212
250
|
break;
|
|
213
251
|
}
|
|
214
252
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
if (!target || !this._items.includes(target)) {
|
|
221
|
-
return;
|
|
253
|
+
_handleKeyDownEscape() {
|
|
254
|
+
if (this.open) {
|
|
255
|
+
this.open = false;
|
|
256
|
+
} else {
|
|
257
|
+
this._removeLastSelection();
|
|
222
258
|
}
|
|
223
|
-
this._hasSelectedItem = true;
|
|
224
|
-
this._selectedItemLabel = target.textContent ?? "";
|
|
225
|
-
this.value = target.value;
|
|
226
|
-
this.open = false;
|
|
227
|
-
this.dispatchEvent(new Event("change"));
|
|
228
259
|
}
|
|
229
260
|
/**
|
|
230
261
|
* Handle `focusin` event to remember last focused item.
|
|
@@ -246,14 +277,28 @@ exports.DaikinDropdown = class DaikinDropdown extends ddsElement.DDSElement {
|
|
|
246
277
|
const item = items.find((item2) => item2 === this._lastFocusedItem) ?? items.find((item2) => item2.value === this.value) ?? items.at(0);
|
|
247
278
|
item == null ? void 0 : item.focus();
|
|
248
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* Handle `select` event from `daikin-dropdown-item`.
|
|
282
|
+
*/
|
|
283
|
+
_handleSelect(event) {
|
|
284
|
+
this._handleSelectOption(event.target.value);
|
|
285
|
+
if (!this.multiple) {
|
|
286
|
+
this.open = false;
|
|
287
|
+
}
|
|
288
|
+
this.dispatchEvent(new Event("change"));
|
|
289
|
+
}
|
|
290
|
+
_handleSlotChange() {
|
|
291
|
+
this._updateItemsSelectable();
|
|
292
|
+
}
|
|
249
293
|
render() {
|
|
250
294
|
return lit.html`<div class="w-full relative" @keydown=${this._handleKeyDown}>
|
|
251
295
|
<button
|
|
296
|
+
${ref_js.ref(this._dropdownRef)}
|
|
252
297
|
type="button"
|
|
253
298
|
class=${cvaButton({
|
|
254
299
|
open: this.open,
|
|
255
300
|
error: this.error,
|
|
256
|
-
placeholder: !this.
|
|
301
|
+
placeholder: !this.selectedOptions.length
|
|
257
302
|
})}
|
|
258
303
|
?disabled=${this.disabled}
|
|
259
304
|
role="combobox"
|
|
@@ -266,18 +311,19 @@ exports.DaikinDropdown = class DaikinDropdown extends ddsElement.DDSElement {
|
|
|
266
311
|
@click=${this._handleClick}
|
|
267
312
|
${this._autoUpdateController.refReference()}
|
|
268
313
|
>
|
|
269
|
-
${this.
|
|
314
|
+
${this.selectedOptions.length ? this.multiple && this.selectedOptions.length > (this.maxLabels ?? 0) ? `${this.selectedOptions.length} items selected` : this._selectionLabels.join(", ") : this.placeholder}
|
|
270
315
|
</button>
|
|
271
316
|
<div
|
|
272
317
|
id="dropdown-items"
|
|
273
318
|
popover
|
|
274
|
-
class="floating-unready:hidden absolute left-[--floating-x,0] top-[--floating-y,0] min-w-[--floating-width] max-h-[12.5rem] overflow-y-auto opacity-1 transition-[opacity] rounded
|
|
319
|
+
class="floating-unready:hidden absolute left-[--floating-x,0] top-[--floating-y,0] min-w-[--floating-width] max-h-[12.5rem] border border-ddt-color-divider overflow-y-auto opacity-1 transition-[opacity] rounded"
|
|
275
320
|
aria-label=${ifDefined_js.ifDefined(this._label ?? void 0)}
|
|
276
321
|
role="listbox"
|
|
277
322
|
@floating-ready=${this._handleFloatingReady}
|
|
278
323
|
${this._autoUpdateController.refFloating()}
|
|
279
324
|
>
|
|
280
325
|
<slot
|
|
326
|
+
@slotchange=${this._handleSlotChange}
|
|
281
327
|
@select=${this._handleSelect}
|
|
282
328
|
@focusin=${this._handleFocusIn}
|
|
283
329
|
></slot>
|
|
@@ -300,11 +346,29 @@ exports.DaikinDropdown = class DaikinDropdown extends ddsElement.DDSElement {
|
|
|
300
346
|
var _a;
|
|
301
347
|
(_a = this._button) == null ? void 0 : _a.focus(options);
|
|
302
348
|
}
|
|
349
|
+
willUpdate(changedProperties) {
|
|
350
|
+
if (!this._initialUpdateCompleted) {
|
|
351
|
+
if (!!this.selectedOptions.length && (!this.value || !this.selectedOptions.includes(this.value))) {
|
|
352
|
+
this._updateValueBySelectedOptions();
|
|
353
|
+
} else if (!!this.value && !this.selectedOptions.length) {
|
|
354
|
+
this.selectedOptions = [this.value];
|
|
355
|
+
}
|
|
356
|
+
this._initialUpdateCompleted = true;
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
const hasChangedValue = changedProperties.has("value");
|
|
360
|
+
const hasChangedSelectedOptions = changedProperties.has("selectedOptions");
|
|
361
|
+
if (hasChangedValue && !hasChangedSelectedOptions) {
|
|
362
|
+
this._updateSelectedOptionsByValue();
|
|
363
|
+
}
|
|
364
|
+
if (!hasChangedValue && hasChangedSelectedOptions) {
|
|
365
|
+
this._updateValueBySelectedOptions();
|
|
366
|
+
}
|
|
367
|
+
}
|
|
303
368
|
updated(changedProperties) {
|
|
304
369
|
var _a;
|
|
305
370
|
if (changedProperties.has("value")) {
|
|
306
371
|
this._updateFormValue();
|
|
307
|
-
this._reflectItemsAndLabel();
|
|
308
372
|
}
|
|
309
373
|
if (changedProperties.has("open") || changedProperties.has("disabled")) {
|
|
310
374
|
(_a = this._autoUpdateController.floatingElement) == null ? void 0 : _a.togglePopover(
|
|
@@ -314,6 +378,15 @@ exports.DaikinDropdown = class DaikinDropdown extends ddsElement.DDSElement {
|
|
|
314
378
|
this.focus();
|
|
315
379
|
}
|
|
316
380
|
}
|
|
381
|
+
if (changedProperties.has("selectedOptions")) {
|
|
382
|
+
const items = this._items;
|
|
383
|
+
for (const item of items) {
|
|
384
|
+
item.selected = this.selectedOptions.includes(item.value);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
if (changedProperties.has("multiple")) {
|
|
388
|
+
this._updateItemsSelectable();
|
|
389
|
+
}
|
|
317
390
|
}
|
|
318
391
|
/**
|
|
319
392
|
* This method is used by `daikin-input-group` to reflect it's attributes to this component.
|
|
@@ -358,6 +431,15 @@ __decorateClass([
|
|
|
358
431
|
__decorateClass([
|
|
359
432
|
decorators_js.property({ type: Boolean, reflect: true })
|
|
360
433
|
], exports.DaikinDropdown.prototype, "open", 2);
|
|
434
|
+
__decorateClass([
|
|
435
|
+
decorators_js.property({ type: Boolean, reflect: true })
|
|
436
|
+
], exports.DaikinDropdown.prototype, "multiple", 2);
|
|
437
|
+
__decorateClass([
|
|
438
|
+
decorators_js.property({ type: Array, attribute: false })
|
|
439
|
+
], exports.DaikinDropdown.prototype, "selectedOptions", 2);
|
|
440
|
+
__decorateClass([
|
|
441
|
+
decorators_js.property({ type: Number, reflect: true, attribute: "max-labels" })
|
|
442
|
+
], exports.DaikinDropdown.prototype, "maxLabels", 2);
|
|
361
443
|
__decorateClass([
|
|
362
444
|
decorators_js.queryAssignedElements({ selector: "daikin-dropdown-item" })
|
|
363
445
|
], exports.DaikinDropdown.prototype, "_items", 2);
|
|
@@ -367,12 +449,6 @@ __decorateClass([
|
|
|
367
449
|
__decorateClass([
|
|
368
450
|
decorators_js.state()
|
|
369
451
|
], exports.DaikinDropdown.prototype, "_label", 2);
|
|
370
|
-
__decorateClass([
|
|
371
|
-
decorators_js.state()
|
|
372
|
-
], exports.DaikinDropdown.prototype, "_hasSelectedItem", 2);
|
|
373
|
-
__decorateClass([
|
|
374
|
-
decorators_js.state()
|
|
375
|
-
], exports.DaikinDropdown.prototype, "_selectedItemLabel", 2);
|
|
376
452
|
exports.DaikinDropdown = __decorateClass([
|
|
377
453
|
decorators.ddsElement("daikin-dropdown")
|
|
378
454
|
], exports.DaikinDropdown);
|