@x-plat/design-system 0.3.6 → 0.3.8
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/dist/components/Calendar/index.cjs +1216 -0
- package/dist/components/Calendar/index.css +161 -0
- package/dist/components/Calendar/index.d.cts +63 -0
- package/dist/components/Calendar/index.d.ts +63 -0
- package/dist/components/Calendar/index.js +1176 -0
- package/dist/components/DatePicker/index.cjs +439 -10905
- package/dist/components/DatePicker/index.css +109 -790
- package/dist/components/DatePicker/index.d.cts +4 -0
- package/dist/components/DatePicker/index.d.ts +4 -0
- package/dist/components/DatePicker/index.js +445 -10919
- package/dist/components/HtmlTypeWriter/index.cjs +3 -2
- package/dist/components/HtmlTypeWriter/index.js +3 -2
- package/dist/components/Swiper/index.cjs +23 -15
- package/dist/components/Swiper/index.js +23 -15
- package/dist/components/index.cjs +1601 -11948
- package/dist/components/index.css +270 -787
- package/dist/components/index.d.cts +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1630 -11987
- package/dist/index.cjs +1606 -11953
- package/dist/index.css +270 -787
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1641 -11998
- package/package.json +1 -2
|
@@ -130,6 +130,7 @@ var HtmlTypeWriter = ({
|
|
|
130
130
|
const [typedLen, setTypedLen] = import_react2.default.useState(0);
|
|
131
131
|
const doneCalledRef = import_react2.default.useRef(false);
|
|
132
132
|
const { doc, rangeMap, totalLength } = import_react2.default.useMemo(() => {
|
|
133
|
+
if (typeof window === "undefined") return { doc: null, rangeMap: /* @__PURE__ */ new Map(), totalLength: 0 };
|
|
133
134
|
const decoded = decodeHtmlEntities(html);
|
|
134
135
|
const doc2 = new DOMParser().parseFromString(decoded, "text/html");
|
|
135
136
|
const { rangeMap: rangeMap2, totalLength: totalLength2 } = buildRangeMap(doc2.body);
|
|
@@ -159,8 +160,8 @@ var HtmlTypeWriter = ({
|
|
|
159
160
|
}
|
|
160
161
|
}, [typedLen, totalLength, onDone]);
|
|
161
162
|
const parsed = import_react2.default.useMemo(
|
|
162
|
-
() => htmlToReactProgressive(doc.body, typedLen, rangeMap),
|
|
163
|
-
[doc
|
|
163
|
+
() => doc ? htmlToReactProgressive(doc.body, typedLen, rangeMap) : null,
|
|
164
|
+
[doc, typedLen, rangeMap]
|
|
164
165
|
);
|
|
165
166
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "lib-xplat-htmlTypewriter", children: parsed });
|
|
166
167
|
};
|
|
@@ -94,6 +94,7 @@ var HtmlTypeWriter = ({
|
|
|
94
94
|
const [typedLen, setTypedLen] = React2.useState(0);
|
|
95
95
|
const doneCalledRef = React2.useRef(false);
|
|
96
96
|
const { doc, rangeMap, totalLength } = React2.useMemo(() => {
|
|
97
|
+
if (typeof window === "undefined") return { doc: null, rangeMap: /* @__PURE__ */ new Map(), totalLength: 0 };
|
|
97
98
|
const decoded = decodeHtmlEntities(html);
|
|
98
99
|
const doc2 = new DOMParser().parseFromString(decoded, "text/html");
|
|
99
100
|
const { rangeMap: rangeMap2, totalLength: totalLength2 } = buildRangeMap(doc2.body);
|
|
@@ -123,8 +124,8 @@ var HtmlTypeWriter = ({
|
|
|
123
124
|
}
|
|
124
125
|
}, [typedLen, totalLength, onDone]);
|
|
125
126
|
const parsed = React2.useMemo(
|
|
126
|
-
() => htmlToReactProgressive(doc.body, typedLen, rangeMap),
|
|
127
|
-
[doc
|
|
127
|
+
() => doc ? htmlToReactProgressive(doc.body, typedLen, rangeMap) : null,
|
|
128
|
+
[doc, typedLen, rangeMap]
|
|
128
129
|
);
|
|
129
130
|
return /* @__PURE__ */ jsx("div", { className: "lib-xplat-htmlTypewriter", children: parsed });
|
|
130
131
|
};
|
|
@@ -115,22 +115,29 @@ var Swiper = (props) => {
|
|
|
115
115
|
const realIndex = getRealIndex(innerIndex);
|
|
116
116
|
const moveToInner = import_react.default.useCallback(
|
|
117
117
|
(idx, withAnim = true) => {
|
|
118
|
-
if (useLoop) {
|
|
119
|
-
setInnerIndex((prev) => {
|
|
120
|
-
const real = ((prev - cloneCount) % totalSlides + totalSlides) % totalSlides;
|
|
121
|
-
const canonical = cloneCount + real;
|
|
122
|
-
if (prev !== canonical) {
|
|
123
|
-
const delta = idx - prev;
|
|
124
|
-
setAnimated(withAnim);
|
|
125
|
-
return canonical + delta;
|
|
126
|
-
}
|
|
127
|
-
setAnimated(withAnim);
|
|
128
|
-
return idx;
|
|
129
|
-
});
|
|
130
|
-
} else {
|
|
118
|
+
if (!useLoop) {
|
|
131
119
|
setAnimated(withAnim);
|
|
132
120
|
setInnerIndex(idx);
|
|
121
|
+
return;
|
|
133
122
|
}
|
|
123
|
+
setInnerIndex((prev) => {
|
|
124
|
+
const real = ((prev - cloneCount) % totalSlides + totalSlides) % totalSlides;
|
|
125
|
+
const canonical = cloneCount + real;
|
|
126
|
+
const delta = idx - prev;
|
|
127
|
+
const target = canonical + delta;
|
|
128
|
+
if (prev !== canonical) {
|
|
129
|
+
setAnimated(false);
|
|
130
|
+
requestAnimationFrame(() => {
|
|
131
|
+
requestAnimationFrame(() => {
|
|
132
|
+
setAnimated(withAnim);
|
|
133
|
+
setInnerIndex(target);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
return canonical;
|
|
137
|
+
}
|
|
138
|
+
setAnimated(withAnim);
|
|
139
|
+
return target;
|
|
140
|
+
});
|
|
134
141
|
},
|
|
135
142
|
[useLoop, cloneCount, totalSlides]
|
|
136
143
|
);
|
|
@@ -139,10 +146,11 @@ var Swiper = (props) => {
|
|
|
139
146
|
const real = getRealIndex(innerIndex);
|
|
140
147
|
const canonical = cloneCount + real;
|
|
141
148
|
if (innerIndex !== canonical) {
|
|
142
|
-
|
|
149
|
+
setAnimated(false);
|
|
150
|
+
setInnerIndex(canonical);
|
|
143
151
|
}
|
|
144
152
|
onChange?.(Math.min(real, maxIndex));
|
|
145
|
-
}, [useLoop, innerIndex, cloneCount, totalSlides, maxIndex, onChange
|
|
153
|
+
}, [useLoop, innerIndex, cloneCount, totalSlides, maxIndex, onChange]);
|
|
146
154
|
const slideTo = import_react.default.useCallback(
|
|
147
155
|
(logicalIndex) => {
|
|
148
156
|
if (!canSlide) return;
|
|
@@ -79,22 +79,29 @@ var Swiper = (props) => {
|
|
|
79
79
|
const realIndex = getRealIndex(innerIndex);
|
|
80
80
|
const moveToInner = React.useCallback(
|
|
81
81
|
(idx, withAnim = true) => {
|
|
82
|
-
if (useLoop) {
|
|
83
|
-
setInnerIndex((prev) => {
|
|
84
|
-
const real = ((prev - cloneCount) % totalSlides + totalSlides) % totalSlides;
|
|
85
|
-
const canonical = cloneCount + real;
|
|
86
|
-
if (prev !== canonical) {
|
|
87
|
-
const delta = idx - prev;
|
|
88
|
-
setAnimated(withAnim);
|
|
89
|
-
return canonical + delta;
|
|
90
|
-
}
|
|
91
|
-
setAnimated(withAnim);
|
|
92
|
-
return idx;
|
|
93
|
-
});
|
|
94
|
-
} else {
|
|
82
|
+
if (!useLoop) {
|
|
95
83
|
setAnimated(withAnim);
|
|
96
84
|
setInnerIndex(idx);
|
|
85
|
+
return;
|
|
97
86
|
}
|
|
87
|
+
setInnerIndex((prev) => {
|
|
88
|
+
const real = ((prev - cloneCount) % totalSlides + totalSlides) % totalSlides;
|
|
89
|
+
const canonical = cloneCount + real;
|
|
90
|
+
const delta = idx - prev;
|
|
91
|
+
const target = canonical + delta;
|
|
92
|
+
if (prev !== canonical) {
|
|
93
|
+
setAnimated(false);
|
|
94
|
+
requestAnimationFrame(() => {
|
|
95
|
+
requestAnimationFrame(() => {
|
|
96
|
+
setAnimated(withAnim);
|
|
97
|
+
setInnerIndex(target);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
return canonical;
|
|
101
|
+
}
|
|
102
|
+
setAnimated(withAnim);
|
|
103
|
+
return target;
|
|
104
|
+
});
|
|
98
105
|
},
|
|
99
106
|
[useLoop, cloneCount, totalSlides]
|
|
100
107
|
);
|
|
@@ -103,10 +110,11 @@ var Swiper = (props) => {
|
|
|
103
110
|
const real = getRealIndex(innerIndex);
|
|
104
111
|
const canonical = cloneCount + real;
|
|
105
112
|
if (innerIndex !== canonical) {
|
|
106
|
-
|
|
113
|
+
setAnimated(false);
|
|
114
|
+
setInnerIndex(canonical);
|
|
107
115
|
}
|
|
108
116
|
onChange?.(Math.min(real, maxIndex));
|
|
109
|
-
}, [useLoop, innerIndex, cloneCount, totalSlides, maxIndex, onChange
|
|
117
|
+
}, [useLoop, innerIndex, cloneCount, totalSlides, maxIndex, onChange]);
|
|
110
118
|
const slideTo = React.useCallback(
|
|
111
119
|
(logicalIndex) => {
|
|
112
120
|
if (!canSlide) return;
|