@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
|
+
}
|
|
65
139
|
|
|
66
|
-
|
|
140
|
+
slot {
|
|
141
|
+
display: contents;
|
|
142
|
+
}
|
|
143
|
+
|
|
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,68 +216,154 @@ 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
|
-
if (this._items.length - 1 < this.currentIndex)
|
|
106
|
-
if (this.currentIndex < 0)
|
|
250
|
+
if (this._items.length - 1 < this.currentIndex) this.currentIndex = Math.max(0, this._itemCount - 1);
|
|
251
|
+
if (this.currentIndex < 0) this.currentIndex = 0;
|
|
107
252
|
for (const [index, item] of this._items.entries()) item.active = index === this.currentIndex;
|
|
108
253
|
}
|
|
109
254
|
render() {
|
|
110
|
-
return html`<div
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
255
|
+
return html`<div class="flex justify-center items-center flex-col gap-8">
|
|
256
|
+
<!-- items-center is intentionally removed so the outside arrow wrappers can stretch to the full height. -->
|
|
257
|
+
<div class="flex w-full gap-4 relative">
|
|
258
|
+
<!-- Outside Prev Arrow -->
|
|
259
|
+
<div class=${outsideButtonWrapper({ arrows: this.arrows })}>
|
|
260
|
+
<!-- Absolutely center the arrow based on the computed media height. -->
|
|
261
|
+
<div
|
|
262
|
+
class="absolute w-full top-(--ddc-arrow-y,50%) -translate-y-1/2 flex justify-center"
|
|
263
|
+
>
|
|
264
|
+
<daikin-icon-button
|
|
265
|
+
variant="ghost"
|
|
266
|
+
color="neutral"
|
|
267
|
+
button-aria-label="Previous"
|
|
268
|
+
?disabled=${this._itemCount <= 1 || !this.loop && this.currentIndex <= 0}
|
|
269
|
+
@click=${() => this._moveBy(-1)}
|
|
270
|
+
>
|
|
271
|
+
<span
|
|
272
|
+
class=${cvaButton({
|
|
273
|
+
intent: "previous",
|
|
274
|
+
arrows: "outside"
|
|
275
|
+
})}
|
|
276
|
+
></span>
|
|
277
|
+
</daikin-icon-button>
|
|
278
|
+
</div>
|
|
279
|
+
</div>
|
|
280
|
+
|
|
281
|
+
<!-- Inside Prev Arrow -->
|
|
282
|
+
<div
|
|
283
|
+
class=${insideButtonWrapper({
|
|
284
|
+
arrows: this.arrows,
|
|
285
|
+
intent: "previous"
|
|
286
|
+
})}
|
|
122
287
|
>
|
|
123
|
-
<
|
|
124
|
-
|
|
288
|
+
<daikin-icon-button
|
|
289
|
+
class=${INJECTION_CLASS_INSIDE_BUTTON}
|
|
290
|
+
variant="ghost"
|
|
291
|
+
color="neutral"
|
|
292
|
+
size="m"
|
|
293
|
+
button-aria-label="Previous"
|
|
294
|
+
?disabled=${this._itemCount <= 1 || !this.loop && this.currentIndex <= 0}
|
|
295
|
+
@click=${() => this._moveBy(-1)}
|
|
296
|
+
>
|
|
297
|
+
<span
|
|
298
|
+
class=${cvaButton({
|
|
299
|
+
intent: "previous",
|
|
300
|
+
arrows: "inside"
|
|
301
|
+
})}
|
|
302
|
+
></span>
|
|
303
|
+
</daikin-icon-button>
|
|
304
|
+
</div>
|
|
305
|
+
|
|
306
|
+
<!-- Viewport -->
|
|
125
307
|
<div
|
|
126
|
-
|
|
308
|
+
${ref(this._viewport)}
|
|
309
|
+
data-carousel-viewport
|
|
310
|
+
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"
|
|
127
311
|
aria-live="polite"
|
|
128
312
|
>
|
|
313
|
+
<div ${ref(this._track)} class="flex touch-pan-y">
|
|
314
|
+
<slot @slotchange=${this._handleSlotchange}></slot>
|
|
315
|
+
</div>
|
|
316
|
+
</div>
|
|
317
|
+
|
|
318
|
+
<!-- Inside Next Arrow -->
|
|
319
|
+
<div
|
|
320
|
+
class=${insideButtonWrapper({
|
|
321
|
+
arrows: this.arrows,
|
|
322
|
+
intent: "next"
|
|
323
|
+
})}
|
|
324
|
+
>
|
|
325
|
+
<daikin-icon-button
|
|
326
|
+
class=${INJECTION_CLASS_INSIDE_BUTTON}
|
|
327
|
+
variant="ghost"
|
|
328
|
+
color="neutral"
|
|
329
|
+
size="m"
|
|
330
|
+
button-aria-label="Next"
|
|
331
|
+
?disabled=${this._itemCount <= 1 || !this.loop && this.currentIndex >= this._itemCount - 1}
|
|
332
|
+
@click=${() => this._moveBy(1)}
|
|
333
|
+
>
|
|
334
|
+
<span
|
|
335
|
+
class=${cvaButton({
|
|
336
|
+
intent: "next",
|
|
337
|
+
arrows: "inside"
|
|
338
|
+
})}
|
|
339
|
+
></span>
|
|
340
|
+
</daikin-icon-button>
|
|
341
|
+
</div>
|
|
342
|
+
|
|
343
|
+
<!-- Outside Next Arrow -->
|
|
344
|
+
<div class=${outsideButtonWrapper({ arrows: this.arrows })}>
|
|
129
345
|
<div
|
|
130
|
-
class="
|
|
346
|
+
class="absolute w-full top-(--ddc-arrow-y,50%) -translate-y-1/2 flex justify-center"
|
|
131
347
|
>
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
348
|
+
<daikin-icon-button
|
|
349
|
+
variant="ghost"
|
|
350
|
+
color="neutral"
|
|
351
|
+
button-aria-label="Next"
|
|
352
|
+
?disabled=${this._itemCount <= 1 || !this.loop && this.currentIndex >= this._itemCount - 1}
|
|
353
|
+
@click=${() => this._moveBy(1)}
|
|
354
|
+
>
|
|
355
|
+
<span
|
|
356
|
+
class=${cvaButton({
|
|
357
|
+
intent: "next",
|
|
358
|
+
arrows: "outside"
|
|
359
|
+
})}
|
|
360
|
+
></span>
|
|
361
|
+
</daikin-icon-button>
|
|
136
362
|
</div>
|
|
137
363
|
</div>
|
|
138
|
-
<daikin-icon-button
|
|
139
|
-
${ref(this._nextButton)}
|
|
140
|
-
variant="ghost"
|
|
141
|
-
color="neutral"
|
|
142
|
-
button-aria-label="Next"
|
|
143
|
-
?disabled=${this.currentIndex >= this._itemCount - 1}
|
|
144
|
-
@click=${() => this._moveBy(1)}
|
|
145
|
-
>
|
|
146
|
-
<span class=${cvaButton({ intent: "next" })}></span>
|
|
147
|
-
</daikin-icon-button>
|
|
148
364
|
</div>
|
|
365
|
+
|
|
366
|
+
<!-- Indicators remain unchanged. -->
|
|
149
367
|
<div class="flex gap-3">
|
|
150
368
|
<div
|
|
151
369
|
${ref(this._indicatorButtonsContainer)}
|
|
@@ -153,7 +371,7 @@ var DaikinCarousel = class DaikinCarousel extends DDSElement {
|
|
|
153
371
|
role="tablist"
|
|
154
372
|
@keydown=${this._handleKeydownIndicator}
|
|
155
373
|
>
|
|
156
|
-
${repeat(this.
|
|
374
|
+
${repeat([...Array(this._itemCount).keys()], (index) => index, (index) => html`<button
|
|
157
375
|
type="button"
|
|
158
376
|
class=${INDICATOR_CLASS_NAME}
|
|
159
377
|
aria-label="Slide ${index + 1}"
|
|
@@ -167,7 +385,11 @@ var DaikinCarousel = class DaikinCarousel extends DDSElement {
|
|
|
167
385
|
</div>`;
|
|
168
386
|
}
|
|
169
387
|
updated(changedProperties) {
|
|
170
|
-
if (changedProperties.has("currentIndex"))
|
|
388
|
+
if (changedProperties.has("currentIndex")) {
|
|
389
|
+
if (this._emblaApi && this._emblaApi.selectedScrollSnap() !== this.currentIndex) this._emblaApi.scrollTo(this.currentIndex);
|
|
390
|
+
this._updateItemActive();
|
|
391
|
+
}
|
|
392
|
+
if (changedProperties.has("loop") || changedProperties.has("duration")) this._initEmbla();
|
|
171
393
|
}
|
|
172
394
|
};
|
|
173
395
|
__decorate([property$1({
|
|
@@ -175,6 +397,23 @@ __decorate([property$1({
|
|
|
175
397
|
reflect: true,
|
|
176
398
|
attribute: "current-index"
|
|
177
399
|
})], DaikinCarousel.prototype, "currentIndex", void 0);
|
|
400
|
+
__decorate([property$1({
|
|
401
|
+
type: Boolean,
|
|
402
|
+
attribute: "loop"
|
|
403
|
+
})], DaikinCarousel.prototype, "loop", void 0);
|
|
404
|
+
__decorate([property$1({
|
|
405
|
+
type: String,
|
|
406
|
+
reflect: true,
|
|
407
|
+
fallbackValue: "outside",
|
|
408
|
+
isAllowedValue: oneOf(["outside", "inside"])
|
|
409
|
+
})], DaikinCarousel.prototype, "arrows", void 0);
|
|
410
|
+
__decorate([property$1({
|
|
411
|
+
type: Number,
|
|
412
|
+
reflect: true,
|
|
413
|
+
attribute: "duration",
|
|
414
|
+
fallbackValue: DEFAULT_EMBLA_DURATION,
|
|
415
|
+
isAllowedValue: (value) => typeof value === "number" && Number.isFinite(value) && value >= 0
|
|
416
|
+
})], DaikinCarousel.prototype, "duration", void 0);
|
|
178
417
|
__decorate([queryAssignedElements({ selector: "daikin-carousel-item" })], DaikinCarousel.prototype, "_items", void 0);
|
|
179
418
|
__decorate([state()], DaikinCarousel.prototype, "_itemCount", void 0);
|
|
180
419
|
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.
|