@daikin-oss/design-system-web-components 2.0.1-next.1 → 2.1.0-next.3
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 +27 -0
- package/custom-elements.json +570 -383
- package/dist/cjs/base/dds-element.cjs +1 -1
- package/dist/cjs/components/carousel/daikin-carousel.cjs +298 -57
- package/dist/cjs/components/carousel/daikin-carousel.d.cts +50 -7
- package/dist/cjs/components/carousel-item/daikin-carousel-item.cjs +18 -2
- package/dist/cjs/components/carousel-item/daikin-carousel-item.d.cts +1 -5
- package/dist/cjs/components/chip/daikin-chip.cjs +24 -6
- package/dist/cjs/components/chip/daikin-chip.d.cts +2 -0
- package/dist/cjs/components/combobox/daikin-combobox.cjs +14 -4
- package/dist/cjs/components/combobox/daikin-combobox.d.cts +8 -0
- package/dist/cjs/components/icon-button/daikin-icon-button.cjs +42 -7
- package/dist/cjs/components/tag/daikin-tag.cjs +3 -1
- package/dist/cjs/components/text-field/daikin-text-field.cjs +12 -12
- package/dist/cjs/controllers/click-outside.cjs +6 -8
- package/dist/cjs/controllers/click-outside.d.cts +3 -3
- package/dist/cjs/tailwind.css.cjs +1 -1
- package/dist/cjs-dev/base/dds-element.cjs +1 -1
- package/dist/cjs-dev/components/carousel/daikin-carousel.cjs +300 -59
- package/dist/cjs-dev/components/carousel/daikin-carousel.d.cts +50 -7
- package/dist/cjs-dev/components/carousel-item/daikin-carousel-item.cjs +18 -2
- package/dist/cjs-dev/components/carousel-item/daikin-carousel-item.d.cts +1 -5
- package/dist/cjs-dev/components/chip/daikin-chip.cjs +24 -6
- package/dist/cjs-dev/components/chip/daikin-chip.d.cts +2 -0
- package/dist/cjs-dev/components/combobox/daikin-combobox.cjs +14 -4
- package/dist/cjs-dev/components/combobox/daikin-combobox.d.cts +8 -0
- package/dist/cjs-dev/components/icon-button/daikin-icon-button.cjs +42 -7
- package/dist/cjs-dev/components/tag/daikin-tag.cjs +3 -1
- package/dist/cjs-dev/components/text-field/daikin-text-field.cjs +12 -12
- package/dist/cjs-dev/controllers/click-outside.cjs +6 -8
- package/dist/cjs-dev/controllers/click-outside.d.cts +3 -3
- package/dist/cjs-dev/tailwind.css.cjs +1 -1
- package/dist/es/base/dds-element.js +1 -1
- package/dist/es/components/carousel/daikin-carousel.d.ts +50 -7
- package/dist/es/components/carousel/daikin-carousel.js +297 -58
- package/dist/es/components/carousel-item/daikin-carousel-item.d.ts +1 -5
- package/dist/es/components/carousel-item/daikin-carousel-item.js +18 -2
- package/dist/es/components/chip/daikin-chip.d.ts +2 -0
- package/dist/es/components/chip/daikin-chip.js +25 -7
- package/dist/es/components/combobox/daikin-combobox.d.ts +8 -0
- package/dist/es/components/combobox/daikin-combobox.js +14 -4
- package/dist/es/components/icon-button/daikin-icon-button.js +42 -7
- package/dist/es/components/tag/daikin-tag.js +3 -1
- package/dist/es/components/text-field/daikin-text-field.js +12 -12
- package/dist/es/controllers/click-outside.d.ts +3 -3
- package/dist/es/controllers/click-outside.js +6 -8
- package/dist/es/tailwind.css.js +1 -1
- package/dist/es-dev/base/dds-element.js +1 -1
- package/dist/es-dev/components/carousel/daikin-carousel.d.ts +50 -7
- package/dist/es-dev/components/carousel/daikin-carousel.js +299 -60
- package/dist/es-dev/components/carousel-item/daikin-carousel-item.d.ts +1 -5
- package/dist/es-dev/components/carousel-item/daikin-carousel-item.js +18 -2
- package/dist/es-dev/components/chip/daikin-chip.d.ts +2 -0
- package/dist/es-dev/components/chip/daikin-chip.js +25 -7
- package/dist/es-dev/components/combobox/daikin-combobox.d.ts +8 -0
- package/dist/es-dev/components/combobox/daikin-combobox.js +14 -4
- package/dist/es-dev/components/icon-button/daikin-icon-button.js +42 -7
- package/dist/es-dev/components/tag/daikin-tag.js +3 -1
- package/dist/es-dev/components/text-field/daikin-text-field.js +12 -12
- package/dist/es-dev/controllers/click-outside.d.ts +3 -3
- package/dist/es-dev/controllers/click-outside.js +6 -8
- package/dist/es-dev/tailwind.css.js +1 -1
- package/package.json +2 -1
|
@@ -42,7 +42,7 @@ function ensureGlobalKeyIndex(name) {
|
|
|
42
42
|
*/
|
|
43
43
|
var DDSElement = class extends LitElement {
|
|
44
44
|
static {
|
|
45
|
-
this.version = "2.0
|
|
45
|
+
this.version = "2.1.0-next.3";
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* Override of LitElement's getPropertyDescriptor to add support for fallback values
|
|
@@ -3,16 +3,20 @@ import { DDSElement } from "../../base/index.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* A carousel is a component that displays multiple pieces of information by sliding left and right within a fixed height area.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* Powered by embla-carousel for smooth, native-feeling interactions and infinite loops.
|
|
7
7
|
*
|
|
8
8
|
* Hierarchy:
|
|
9
9
|
* - `daikin-carousel` > `daikin-carousel-item`
|
|
10
10
|
*
|
|
11
|
-
* @fires select -
|
|
11
|
+
* @fires select - Fired when the carousel index changes. `event.detail` contains the triggering `operation` (`"prev"`, `"next"`, `"indicator"`, or `"swipe"`) and `beforeCurrentIndex`; read `currentIndex` for the selected index.
|
|
12
12
|
*
|
|
13
13
|
* @slot - A slot for carousel items. Place `daikin-carousel-item` elements here.
|
|
14
14
|
*
|
|
15
|
-
* @cssprop [--ddc-transition-duration=600ms] -
|
|
15
|
+
* @cssprop [--ddc-transition-duration=600ms] - Legacy transition duration in milliseconds. **Warning:** Mapped to Embla's duration option using 600ms = 25. This property may be removed in a future release; gradually migrate to the `duration` property instead.
|
|
16
|
+
* @cssprop [--ddc-item-aspect-ratio=16/9] - The aspect ratio of every carousel item's media container.
|
|
17
|
+
* @cssprop [--ddc-item-object-fit=contain] - How image/video content fits inside every carousel item's media container.
|
|
18
|
+
* @cssprop [--ddc-item-background-color=var(--dds-color-common-surface-secondary)] - The default background color for the carousel items.
|
|
19
|
+
* @cssprop [--ddc-item-gap=var(--dds-space-100)] - The gap between carousel items.
|
|
16
20
|
*
|
|
17
21
|
* @example
|
|
18
22
|
*
|
|
@@ -33,19 +37,58 @@ export declare class DaikinCarousel extends DDSElement {
|
|
|
33
37
|
static readonly styles: import('lit').CSSResult;
|
|
34
38
|
/**
|
|
35
39
|
* The index number of the content currently being displayed.
|
|
36
|
-
* When controlling this property externally, listen to the `select` event and read the updated `currentIndex` from the component to keep your state in sync.
|
|
37
40
|
*/
|
|
38
41
|
currentIndex: number;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the carousel should loop back to the first item when the last item is reached.
|
|
44
|
+
*/
|
|
45
|
+
loop: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* The position of the navigation arrows. Can be either "outside" or "inside".
|
|
48
|
+
* - "outside": Arrows are placed outside the carousel viewport.
|
|
49
|
+
* - "inside": Arrows are placed inside the carousel viewport.
|
|
50
|
+
* The inside option is useful for carousels with a smaller width, where the arrows can be placed over the content without taking up additional space.
|
|
51
|
+
* When the width of viewport is smaller than mobile breakpoint (768px), the arrows will always be placed inside regardless of this property.
|
|
52
|
+
*
|
|
53
|
+
* @default "outside"
|
|
54
|
+
*/
|
|
55
|
+
arrows: "outside" | "inside";
|
|
56
|
+
/**
|
|
57
|
+
* The higher this value, the slower the image scrolling animation. However, this value does not affect the sliding speed when the user is dragging the image, as that depends on the user's dragging speed.
|
|
58
|
+
*
|
|
59
|
+
* @default 25
|
|
60
|
+
*/
|
|
61
|
+
duration: number;
|
|
39
62
|
private readonly _items;
|
|
63
|
+
/**
|
|
64
|
+
* Keeps track of the total number of slotted carousel items.
|
|
65
|
+
*/
|
|
40
66
|
private _itemCount;
|
|
41
|
-
private
|
|
42
|
-
private
|
|
67
|
+
private _emblaApi?;
|
|
68
|
+
private _mediaResizeObserver?;
|
|
43
69
|
private _indicatorButtonsContainer;
|
|
70
|
+
private _viewport;
|
|
71
|
+
private _track;
|
|
72
|
+
private _pendingOperation;
|
|
73
|
+
private _isDragging;
|
|
74
|
+
private _getEmblaDuration;
|
|
75
|
+
connectedCallback(): void;
|
|
76
|
+
disconnectedCallback(): void;
|
|
44
77
|
private _emitSelect;
|
|
78
|
+
/**
|
|
79
|
+
* Initializes or re-initializes the Embla instance when properties or slots change.
|
|
80
|
+
*/
|
|
81
|
+
private _initEmbla;
|
|
82
|
+
private _onEmblaPointerDown;
|
|
83
|
+
private _onEmblaSettle;
|
|
84
|
+
/**
|
|
85
|
+
* Embla event listener that synchronizes internal state when the user swipes or slides.
|
|
86
|
+
*/
|
|
87
|
+
private _onEmblaSelect;
|
|
45
88
|
private _handleClickIndicator;
|
|
46
89
|
private _handleKeydownIndicator;
|
|
47
|
-
private _handleSlotchange;
|
|
48
90
|
private _moveBy;
|
|
91
|
+
private _handleSlotchange;
|
|
49
92
|
private _updateItemActive;
|
|
50
93
|
render(): import('lit-html').TemplateResult<1>;
|
|
51
94
|
protected updated(changedProperties: PropertyValues): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DDSElement } from "../../base/dds-element.js";
|
|
2
|
-
import { property as property$1 } from "../../base/dds-property.js";
|
|
2
|
+
import { oneOf, property as property$1 } from "../../base/dds-property.js";
|
|
3
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/decorate.js";
|
|
4
4
|
import { ddsElement } from "../../base/decorators.js";
|
|
5
5
|
import "../../base/index.js";
|
|
@@ -10,19 +10,56 @@ import { queryAssignedElements, state } from "lit/decorators.js";
|
|
|
10
10
|
import { cva } from "class-variance-authority";
|
|
11
11
|
import { createRef, ref } from "lit/directives/ref.js";
|
|
12
12
|
import { repeat } from "lit/directives/repeat.js";
|
|
13
|
+
import EmblaCarousel from "embla-carousel";
|
|
13
14
|
//#region src/components/carousel/daikin-carousel.ts
|
|
14
|
-
var DEFAULT_TRANSITION_DURATION = "600ms";
|
|
15
15
|
var cvaButton = cva([
|
|
16
16
|
"flex",
|
|
17
17
|
"justify-center",
|
|
18
18
|
"items-center",
|
|
19
19
|
"flex-none",
|
|
20
|
-
"size-6",
|
|
21
20
|
"text-current"
|
|
22
|
-
], { variants: {
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
], { variants: {
|
|
22
|
+
intent: {
|
|
23
|
+
previous: ["icon-[daikin--chevron-left]"],
|
|
24
|
+
next: ["icon-[daikin--chevron-right]"]
|
|
25
|
+
},
|
|
26
|
+
arrows: {
|
|
27
|
+
outside: ["size-6"],
|
|
28
|
+
inside: ["size-8"]
|
|
29
|
+
}
|
|
30
|
+
} });
|
|
31
|
+
var outsideButtonWrapper = cva([
|
|
32
|
+
"hidden",
|
|
33
|
+
"flex-none",
|
|
34
|
+
"relative",
|
|
35
|
+
"w-6"
|
|
36
|
+
], { variants: { arrows: {
|
|
37
|
+
outside: ["md:block"],
|
|
38
|
+
inside: ["md:hidden"]
|
|
25
39
|
} } });
|
|
40
|
+
var insideButtonWrapper = cva([
|
|
41
|
+
"absolute",
|
|
42
|
+
"top-(--ddc-arrow-y,50%)",
|
|
43
|
+
"-translate-y-1/2",
|
|
44
|
+
"z-10",
|
|
45
|
+
"flex"
|
|
46
|
+
], { variants: {
|
|
47
|
+
arrows: {
|
|
48
|
+
outside: ["md:hidden"],
|
|
49
|
+
inside: ["md:flex"]
|
|
50
|
+
},
|
|
51
|
+
intent: {
|
|
52
|
+
previous: ["left-4"],
|
|
53
|
+
next: ["right-4"]
|
|
54
|
+
}
|
|
55
|
+
} });
|
|
56
|
+
var INJECTION_CLASS_INSIDE_BUTTON = cva([
|
|
57
|
+
"[--ddc-color-common-surface-neutral-default:var(--dds-color-common-surface-overlay-default)]",
|
|
58
|
+
"[--ddc-color-common-surface-neutral-hover:var(--dds-color-common-surface-overlay-hover)]",
|
|
59
|
+
"[--ddc-color-common-surface-neutral-press:var(--dds-color-common-surface-overlay-press)]",
|
|
60
|
+
"[--ddc-color-common-disabled:var(--dds-color-common-surface-overlay-disabled)]",
|
|
61
|
+
"[--ddc-color-common-surface-disabled:var(--dds-color-common-surface-disabled-overlay)]"
|
|
62
|
+
])();
|
|
26
63
|
var INDICATOR_CLASS_NAME = cva([
|
|
27
64
|
"flex",
|
|
28
65
|
"justify-center",
|
|
@@ -45,14 +82,41 @@ var INDICATOR_CLASS_NAME = cva([
|
|
|
45
82
|
"aria-selected:focus-visible:after:outline-offset-1",
|
|
46
83
|
"aria-selected:focus-visible:after:outline-ddt-color-common-border-focus"
|
|
47
84
|
])();
|
|
85
|
+
var DEFAULT_EMBLA_DURATION = 25;
|
|
86
|
+
var LEGACY_CSS_DURATION_MS = 600;
|
|
87
|
+
var parseDurationMs = (value) => {
|
|
88
|
+
const matched = value.trim().match(/^(\d+(?:\.\d+)?)(ms|s)$/);
|
|
89
|
+
if (!matched) return void 0;
|
|
90
|
+
const duration = Number(matched[1]);
|
|
91
|
+
return matched[2] === "s" ? duration * 1e3 : duration;
|
|
92
|
+
};
|
|
48
93
|
var DaikinCarousel = class DaikinCarousel extends DDSElement {
|
|
49
94
|
constructor(..._args) {
|
|
50
95
|
super(..._args);
|
|
51
96
|
this.currentIndex = 0;
|
|
97
|
+
this.loop = false;
|
|
52
98
|
this._itemCount = 0;
|
|
53
|
-
this._prevButton = createRef();
|
|
54
|
-
this._nextButton = createRef();
|
|
55
99
|
this._indicatorButtonsContainer = createRef();
|
|
100
|
+
this._viewport = createRef();
|
|
101
|
+
this._track = createRef();
|
|
102
|
+
this._isDragging = false;
|
|
103
|
+
this._onEmblaPointerDown = () => {
|
|
104
|
+
this._isDragging = true;
|
|
105
|
+
};
|
|
106
|
+
this._onEmblaSettle = () => {
|
|
107
|
+
this._isDragging = false;
|
|
108
|
+
};
|
|
109
|
+
this._onEmblaSelect = () => {
|
|
110
|
+
if (!this._emblaApi) return;
|
|
111
|
+
const previousIndex = this.currentIndex;
|
|
112
|
+
const newIndex = this._emblaApi.selectedScrollSnap();
|
|
113
|
+
if (previousIndex !== newIndex) {
|
|
114
|
+
this.currentIndex = newIndex;
|
|
115
|
+
this._emitSelect(this._isDragging ? "swipe" : this._pendingOperation ?? "indicator", previousIndex);
|
|
116
|
+
this._updateItemActive();
|
|
117
|
+
}
|
|
118
|
+
this._pendingOperation = void 0;
|
|
119
|
+
};
|
|
56
120
|
}
|
|
57
121
|
static {
|
|
58
122
|
this.styles = css`
|
|
@@ -62,21 +126,89 @@ var DaikinCarousel = class DaikinCarousel extends DDSElement {
|
|
|
62
126
|
display: block;
|
|
63
127
|
width: 100%;
|
|
64
128
|
position: relative;
|
|
129
|
+
/* Defaults to vertical center and is later overridden by ResizeObserver. */
|
|
130
|
+
--ddc-arrow-y: 50%;
|
|
131
|
+
/* Defaults aspect ratio for carousel items */
|
|
132
|
+
--ddc-item-aspect-ratio: 16 / 9;
|
|
133
|
+
--ddc-item-object-fit: contain;
|
|
134
|
+
/* Defaults background color for the carousel */
|
|
135
|
+
--ddc-item-background-color: var(--dds-color-common-surface-secondary);
|
|
136
|
+
/* Defaults gap between carousel items */
|
|
137
|
+
--ddc-item-gap: var(--dds-space-100);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
slot {
|
|
141
|
+
display: contents;
|
|
142
|
+
}
|
|
65
143
|
|
|
66
|
-
|
|
144
|
+
/* Ensure slides take up exactly 100% of the viewport container without subpixel overflow */
|
|
145
|
+
::slotted(daikin-carousel-item) {
|
|
146
|
+
flex: 0 0 100% !important;
|
|
147
|
+
min-width: 0 !important;
|
|
148
|
+
max-width: 100% !important;
|
|
149
|
+
margin: 0 !important;
|
|
150
|
+
padding: 0 !important;
|
|
151
|
+
box-sizing: border-box !important;
|
|
67
152
|
}
|
|
68
153
|
`;
|
|
69
154
|
}
|
|
155
|
+
_getEmblaDuration() {
|
|
156
|
+
const cssDurationMs = parseDurationMs(getComputedStyle(this).getPropertyValue("--ddc-transition-duration"));
|
|
157
|
+
if (cssDurationMs == null) return this.duration;
|
|
158
|
+
return cssDurationMs / LEGACY_CSS_DURATION_MS * DEFAULT_EMBLA_DURATION;
|
|
159
|
+
}
|
|
160
|
+
connectedCallback() {
|
|
161
|
+
super.connectedCallback();
|
|
162
|
+
this._mediaResizeObserver = new ResizeObserver((entries) => {
|
|
163
|
+
if (entries.length > 0) {
|
|
164
|
+
const height = entries[0].contentRect.height;
|
|
165
|
+
if (height > 0) this.style.setProperty("--ddc-arrow-y", `${height / 2}px`);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
this.updateComplete.then(() => {
|
|
169
|
+
if (this.isConnected) this._handleSlotchange();
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
disconnectedCallback() {
|
|
173
|
+
super.disconnectedCallback();
|
|
174
|
+
this._mediaResizeObserver?.disconnect();
|
|
175
|
+
if (this._emblaApi) {
|
|
176
|
+
this._emblaApi.destroy();
|
|
177
|
+
this._emblaApi = void 0;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
70
180
|
_emitSelect(operation, beforeCurrentIndex) {
|
|
71
181
|
this.dispatchEvent(new CustomEvent("select", { detail: {
|
|
72
182
|
operation,
|
|
73
183
|
beforeCurrentIndex
|
|
74
184
|
} }));
|
|
75
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* Initializes or re-initializes the Embla instance when properties or slots change.
|
|
188
|
+
*/
|
|
189
|
+
_initEmbla() {
|
|
190
|
+
if (!this._viewport.value || !this._track.value) return;
|
|
191
|
+
const options = {
|
|
192
|
+
loop: this.loop,
|
|
193
|
+
align: "start",
|
|
194
|
+
containScroll: "trimSnaps",
|
|
195
|
+
slides: this._items,
|
|
196
|
+
container: this._track.value,
|
|
197
|
+
duration: this._getEmblaDuration(),
|
|
198
|
+
startIndex: this.currentIndex
|
|
199
|
+
};
|
|
200
|
+
if (this._emblaApi) this._emblaApi.reInit(options);
|
|
201
|
+
else {
|
|
202
|
+
this._emblaApi = EmblaCarousel(this._viewport.value, options);
|
|
203
|
+
this._emblaApi.on("select", this._onEmblaSelect);
|
|
204
|
+
this._emblaApi.on("pointerDown", this._onEmblaPointerDown);
|
|
205
|
+
this._emblaApi.on("settle", this._onEmblaSettle);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
76
208
|
_handleClickIndicator(index) {
|
|
77
|
-
|
|
78
|
-
this.
|
|
79
|
-
this.
|
|
209
|
+
if (!this._emblaApi) return;
|
|
210
|
+
this._pendingOperation = "indicator";
|
|
211
|
+
this._emblaApi.scrollTo(index);
|
|
80
212
|
}
|
|
81
213
|
_handleKeydownIndicator(event) {
|
|
82
214
|
const moveOffset = {
|
|
@@ -84,74 +216,160 @@ var DaikinCarousel = class DaikinCarousel extends DDSElement {
|
|
|
84
216
|
ArrowLeft: -1
|
|
85
217
|
}[event.key];
|
|
86
218
|
if (!moveOffset) return;
|
|
219
|
+
event.preventDefault();
|
|
87
220
|
const buttons = [...this._indicatorButtonsContainer.value?.querySelectorAll("button") ?? []];
|
|
221
|
+
const focusedIndex = buttons.indexOf(event.target);
|
|
222
|
+
if (focusedIndex < 0) return;
|
|
88
223
|
this._moveBy(moveOffset);
|
|
89
|
-
|
|
224
|
+
let targetIndex = focusedIndex + moveOffset;
|
|
225
|
+
if (this.loop) targetIndex = (targetIndex + this._itemCount) % this._itemCount;
|
|
226
|
+
else targetIndex = Math.max(0, Math.min(targetIndex, this._itemCount - 1));
|
|
227
|
+
buttons[targetIndex]?.focus();
|
|
90
228
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
this.
|
|
94
|
-
|
|
95
|
-
this.
|
|
229
|
+
_moveBy(offset) {
|
|
230
|
+
if (!this._emblaApi) return;
|
|
231
|
+
this._pendingOperation = offset === 1 ? "next" : "prev";
|
|
232
|
+
if (offset === 1) this._emblaApi.scrollNext();
|
|
233
|
+
else this._emblaApi.scrollPrev();
|
|
96
234
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
this.
|
|
102
|
-
this.
|
|
235
|
+
async _handleSlotchange() {
|
|
236
|
+
await this.updateComplete;
|
|
237
|
+
this._itemCount = this._items.length;
|
|
238
|
+
for (const [index, item] of this._items.entries()) item.label = `${index + 1} of ${this._itemCount}`;
|
|
239
|
+
this._updateItemActive();
|
|
240
|
+
if (this._items.length > 0 && this._mediaResizeObserver) {
|
|
241
|
+
this._mediaResizeObserver.disconnect();
|
|
242
|
+
const mediaContainer = this._items[this.currentIndex].shadowRoot?.querySelector(".media-container");
|
|
243
|
+
if (mediaContainer) this._mediaResizeObserver.observe(mediaContainer);
|
|
244
|
+
}
|
|
245
|
+
requestAnimationFrame(() => {
|
|
246
|
+
if (this.isConnected) this._initEmbla();
|
|
247
|
+
});
|
|
103
248
|
}
|
|
104
249
|
_updateItemActive() {
|
|
105
250
|
if (this._items.length - 1 < this.currentIndex) {
|
|
106
|
-
console.warn(`Invalid 'current-index' property: ${this.currentIndex}.
|
|
107
|
-
|
|
251
|
+
console.warn(`Invalid 'current-index' property: ${this.currentIndex}. It exceeds the maximum item index. Correcting to ${Math.max(0, this._itemCount - 1)}.`);
|
|
252
|
+
this.currentIndex = Math.max(0, this._itemCount - 1);
|
|
108
253
|
}
|
|
109
254
|
if (this.currentIndex < 0) {
|
|
110
|
-
console.warn(`Invalid 'current-
|
|
111
|
-
|
|
255
|
+
console.warn(`Invalid 'current-index' property: ${this.currentIndex}. Negative values cannot be set. Correcting to 0.`);
|
|
256
|
+
this.currentIndex = 0;
|
|
112
257
|
}
|
|
113
258
|
for (const [index, item] of this._items.entries()) item.active = index === this.currentIndex;
|
|
114
259
|
}
|
|
115
260
|
render() {
|
|
116
|
-
return html`<div
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
261
|
+
return html`<div class="flex justify-center items-center flex-col gap-8">
|
|
262
|
+
<!-- items-center is intentionally removed so the outside arrow wrappers can stretch to the full height. -->
|
|
263
|
+
<div class="flex w-full gap-4 relative">
|
|
264
|
+
<!-- Outside Prev Arrow -->
|
|
265
|
+
<div class=${outsideButtonWrapper({ arrows: this.arrows })}>
|
|
266
|
+
<!-- Absolutely center the arrow based on the computed media height. -->
|
|
267
|
+
<div
|
|
268
|
+
class="absolute w-full top-(--ddc-arrow-y,50%) -translate-y-1/2 flex justify-center"
|
|
269
|
+
>
|
|
270
|
+
<daikin-icon-button
|
|
271
|
+
variant="ghost"
|
|
272
|
+
color="neutral"
|
|
273
|
+
button-aria-label="Previous"
|
|
274
|
+
?disabled=${this._itemCount <= 1 || !this.loop && this.currentIndex <= 0}
|
|
275
|
+
@click=${() => this._moveBy(-1)}
|
|
276
|
+
>
|
|
277
|
+
<span
|
|
278
|
+
class=${cvaButton({
|
|
279
|
+
intent: "previous",
|
|
280
|
+
arrows: "outside"
|
|
281
|
+
})}
|
|
282
|
+
></span>
|
|
283
|
+
</daikin-icon-button>
|
|
284
|
+
</div>
|
|
285
|
+
</div>
|
|
286
|
+
|
|
287
|
+
<!-- Inside Prev Arrow -->
|
|
288
|
+
<div
|
|
289
|
+
class=${insideButtonWrapper({
|
|
290
|
+
arrows: this.arrows,
|
|
291
|
+
intent: "previous"
|
|
292
|
+
})}
|
|
128
293
|
>
|
|
129
|
-
<
|
|
130
|
-
|
|
294
|
+
<daikin-icon-button
|
|
295
|
+
class=${INJECTION_CLASS_INSIDE_BUTTON}
|
|
296
|
+
variant="ghost"
|
|
297
|
+
color="neutral"
|
|
298
|
+
size="m"
|
|
299
|
+
button-aria-label="Previous"
|
|
300
|
+
?disabled=${this._itemCount <= 1 || !this.loop && this.currentIndex <= 0}
|
|
301
|
+
@click=${() => this._moveBy(-1)}
|
|
302
|
+
>
|
|
303
|
+
<span
|
|
304
|
+
class=${cvaButton({
|
|
305
|
+
intent: "previous",
|
|
306
|
+
arrows: "inside"
|
|
307
|
+
})}
|
|
308
|
+
></span>
|
|
309
|
+
</daikin-icon-button>
|
|
310
|
+
</div>
|
|
311
|
+
|
|
312
|
+
<!-- Viewport -->
|
|
131
313
|
<div
|
|
132
|
-
|
|
314
|
+
${ref(this._viewport)}
|
|
315
|
+
data-carousel-viewport
|
|
316
|
+
class="flex-1 min-w-0 overflow-hidden focus-within:outline-solid focus-within:outline-2 focus-within:outline-offset-2 focus-within:outline-ddt-color-common-border-focus"
|
|
133
317
|
aria-live="polite"
|
|
134
318
|
>
|
|
319
|
+
<div ${ref(this._track)} class="flex touch-pan-y">
|
|
320
|
+
<slot @slotchange=${this._handleSlotchange}></slot>
|
|
321
|
+
</div>
|
|
322
|
+
</div>
|
|
323
|
+
|
|
324
|
+
<!-- Inside Next Arrow -->
|
|
325
|
+
<div
|
|
326
|
+
class=${insideButtonWrapper({
|
|
327
|
+
arrows: this.arrows,
|
|
328
|
+
intent: "next"
|
|
329
|
+
})}
|
|
330
|
+
>
|
|
331
|
+
<daikin-icon-button
|
|
332
|
+
class=${INJECTION_CLASS_INSIDE_BUTTON}
|
|
333
|
+
variant="ghost"
|
|
334
|
+
color="neutral"
|
|
335
|
+
size="m"
|
|
336
|
+
button-aria-label="Next"
|
|
337
|
+
?disabled=${this._itemCount <= 1 || !this.loop && this.currentIndex >= this._itemCount - 1}
|
|
338
|
+
@click=${() => this._moveBy(1)}
|
|
339
|
+
>
|
|
340
|
+
<span
|
|
341
|
+
class=${cvaButton({
|
|
342
|
+
intent: "next",
|
|
343
|
+
arrows: "inside"
|
|
344
|
+
})}
|
|
345
|
+
></span>
|
|
346
|
+
</daikin-icon-button>
|
|
347
|
+
</div>
|
|
348
|
+
|
|
349
|
+
<!-- Outside Next Arrow -->
|
|
350
|
+
<div class=${outsideButtonWrapper({ arrows: this.arrows })}>
|
|
135
351
|
<div
|
|
136
|
-
class="
|
|
352
|
+
class="absolute w-full top-(--ddc-arrow-y,50%) -translate-y-1/2 flex justify-center"
|
|
137
353
|
>
|
|
138
|
-
<
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
354
|
+
<daikin-icon-button
|
|
355
|
+
variant="ghost"
|
|
356
|
+
color="neutral"
|
|
357
|
+
button-aria-label="Next"
|
|
358
|
+
?disabled=${this._itemCount <= 1 || !this.loop && this.currentIndex >= this._itemCount - 1}
|
|
359
|
+
@click=${() => this._moveBy(1)}
|
|
360
|
+
>
|
|
361
|
+
<span
|
|
362
|
+
class=${cvaButton({
|
|
363
|
+
intent: "next",
|
|
364
|
+
arrows: "outside"
|
|
365
|
+
})}
|
|
366
|
+
></span>
|
|
367
|
+
</daikin-icon-button>
|
|
142
368
|
</div>
|
|
143
369
|
</div>
|
|
144
|
-
<daikin-icon-button
|
|
145
|
-
${ref(this._nextButton)}
|
|
146
|
-
variant="ghost"
|
|
147
|
-
color="neutral"
|
|
148
|
-
button-aria-label="Next"
|
|
149
|
-
?disabled=${this.currentIndex >= this._itemCount - 1}
|
|
150
|
-
@click=${() => this._moveBy(1)}
|
|
151
|
-
>
|
|
152
|
-
<span class=${cvaButton({ intent: "next" })}></span>
|
|
153
|
-
</daikin-icon-button>
|
|
154
370
|
</div>
|
|
371
|
+
|
|
372
|
+
<!-- Indicators remain unchanged. -->
|
|
155
373
|
<div class="flex gap-3">
|
|
156
374
|
<div
|
|
157
375
|
${ref(this._indicatorButtonsContainer)}
|
|
@@ -159,7 +377,7 @@ var DaikinCarousel = class DaikinCarousel extends DDSElement {
|
|
|
159
377
|
role="tablist"
|
|
160
378
|
@keydown=${this._handleKeydownIndicator}
|
|
161
379
|
>
|
|
162
|
-
${repeat(this.
|
|
380
|
+
${repeat([...Array(this._itemCount).keys()], (index) => index, (index) => html`<button
|
|
163
381
|
type="button"
|
|
164
382
|
class=${INDICATOR_CLASS_NAME}
|
|
165
383
|
aria-label="Slide ${index + 1}"
|
|
@@ -173,7 +391,11 @@ var DaikinCarousel = class DaikinCarousel extends DDSElement {
|
|
|
173
391
|
</div>`;
|
|
174
392
|
}
|
|
175
393
|
updated(changedProperties) {
|
|
176
|
-
if (changedProperties.has("currentIndex"))
|
|
394
|
+
if (changedProperties.has("currentIndex")) {
|
|
395
|
+
if (this._emblaApi && this._emblaApi.selectedScrollSnap() !== this.currentIndex) this._emblaApi.scrollTo(this.currentIndex);
|
|
396
|
+
this._updateItemActive();
|
|
397
|
+
}
|
|
398
|
+
if (changedProperties.has("loop") || changedProperties.has("duration")) this._initEmbla();
|
|
177
399
|
}
|
|
178
400
|
};
|
|
179
401
|
__decorate([property$1({
|
|
@@ -181,6 +403,23 @@ __decorate([property$1({
|
|
|
181
403
|
reflect: true,
|
|
182
404
|
attribute: "current-index"
|
|
183
405
|
})], DaikinCarousel.prototype, "currentIndex", void 0);
|
|
406
|
+
__decorate([property$1({
|
|
407
|
+
type: Boolean,
|
|
408
|
+
attribute: "loop"
|
|
409
|
+
})], DaikinCarousel.prototype, "loop", void 0);
|
|
410
|
+
__decorate([property$1({
|
|
411
|
+
type: String,
|
|
412
|
+
reflect: true,
|
|
413
|
+
fallbackValue: "outside",
|
|
414
|
+
isAllowedValue: oneOf(["outside", "inside"])
|
|
415
|
+
})], DaikinCarousel.prototype, "arrows", void 0);
|
|
416
|
+
__decorate([property$1({
|
|
417
|
+
type: Number,
|
|
418
|
+
reflect: true,
|
|
419
|
+
attribute: "duration",
|
|
420
|
+
fallbackValue: DEFAULT_EMBLA_DURATION,
|
|
421
|
+
isAllowedValue: (value) => typeof value === "number" && Number.isFinite(value) && value >= 0
|
|
422
|
+
})], DaikinCarousel.prototype, "duration", void 0);
|
|
184
423
|
__decorate([queryAssignedElements({ selector: "daikin-carousel-item" })], DaikinCarousel.prototype, "_items", void 0);
|
|
185
424
|
__decorate([state()], DaikinCarousel.prototype, "_itemCount", void 0);
|
|
186
425
|
DaikinCarousel = __decorate([ddsElement("daikin-carousel")], DaikinCarousel);
|
|
@@ -22,11 +22,7 @@ import { DDSElement } from "../../base/index.js";
|
|
|
22
22
|
export declare class DaikinCarouselItem extends DDSElement {
|
|
23
23
|
static readonly styles: import('lit').CSSResult;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
* Item's aria label.
|
|
27
|
-
* Controlled by `daikin-carousel`.
|
|
28
|
-
*
|
|
29
|
-
* @private
|
|
25
|
+
* The Aria label for the carousel item.
|
|
30
26
|
*/
|
|
31
27
|
label: string;
|
|
32
28
|
/**
|
|
@@ -22,6 +22,17 @@ var DaikinCarouselItem = class DaikinCarouselItem extends DDSElement {
|
|
|
22
22
|
display: block;
|
|
23
23
|
width: 100%;
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
.media-container {
|
|
27
|
+
aspect-ratio: var(--ddc-item-aspect-ratio);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
::slotted(img),
|
|
31
|
+
::slotted(video) {
|
|
32
|
+
width: 100% !important;
|
|
33
|
+
height: 100% !important;
|
|
34
|
+
object-fit: var(--ddc-item-object-fit);
|
|
35
|
+
}
|
|
25
36
|
`;
|
|
26
37
|
}
|
|
27
38
|
_handleFooterSlotChange() {
|
|
@@ -29,12 +40,17 @@ var DaikinCarouselItem = class DaikinCarouselItem extends DDSElement {
|
|
|
29
40
|
}
|
|
30
41
|
render() {
|
|
31
42
|
return html`<div
|
|
32
|
-
class="flex flex-col flex-none gap-3 text-ddt-color-common-text-primary overflow-hidden"
|
|
43
|
+
class="flex flex-col flex-none gap-3 text-ddt-color-common-text-primary overflow-hidden px-[calc(var(--ddc-item-gap)/2)]"
|
|
33
44
|
role="tabpanel"
|
|
34
45
|
aria-label=${this.label}
|
|
35
46
|
aria-hidden=${!this.active}
|
|
36
47
|
>
|
|
37
|
-
<
|
|
48
|
+
<div
|
|
49
|
+
class="media-container flex w-full flex-none items-center justify-center overflow-hidden bg-(--ddc-item-background-color)"
|
|
50
|
+
>
|
|
51
|
+
<slot></slot>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
38
54
|
<div
|
|
39
55
|
class="visible:flex flex-col gap-2"
|
|
40
56
|
?hidden=${!this._hasTextContents}
|
|
@@ -71,6 +71,8 @@ export declare class DaikinChip extends DDSElement {
|
|
|
71
71
|
*/
|
|
72
72
|
chipAriaLabel: string | null;
|
|
73
73
|
private _focusableElement;
|
|
74
|
+
private _hasLeftIcon;
|
|
75
|
+
private _handleLeftIconSlotChange;
|
|
74
76
|
private _handleRemoveClick;
|
|
75
77
|
/**
|
|
76
78
|
* Emits `before-select` event if necessary and returns whether we should proceed.
|