@charlesgomes/leafcode-shared-lib-react 1.0.96 → 1.0.97
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/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +12 -4
- package/dist/index.mjs +12 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -145,6 +145,9 @@ var defaultTheme = {
|
|
|
145
145
|
height: "2.5rem",
|
|
146
146
|
minWidth: "8rem",
|
|
147
147
|
radius: "6px"
|
|
148
|
+
},
|
|
149
|
+
lottie: {
|
|
150
|
+
basePath: "/lotties"
|
|
148
151
|
}
|
|
149
152
|
},
|
|
150
153
|
table: {
|
|
@@ -224,19 +227,24 @@ function Button({
|
|
|
224
227
|
...rest
|
|
225
228
|
}) {
|
|
226
229
|
const theme = useLeafcodeTheme();
|
|
230
|
+
const themeButtonLottie = theme.components.button.lottie;
|
|
227
231
|
const [resolvedLottieData, setResolvedLottieData] = (0, import_react2.useState)(loadingLottieData ?? null);
|
|
232
|
+
const resolvedLottieFileName = loadingLottieFileName ?? themeButtonLottie?.fileName;
|
|
233
|
+
const resolvedLottieBasePath = loadingLottieBasePath ?? themeButtonLottie?.basePath ?? DEFAULT_LOTTIE_BASE_PATH;
|
|
228
234
|
(0, import_react2.useEffect)(() => {
|
|
229
235
|
if (loadingLottieData) {
|
|
230
236
|
setResolvedLottieData(loadingLottieData);
|
|
231
237
|
return;
|
|
232
238
|
}
|
|
233
|
-
if (!
|
|
239
|
+
if (!resolvedLottieFileName) {
|
|
234
240
|
setResolvedLottieData(null);
|
|
235
241
|
return;
|
|
236
242
|
}
|
|
237
243
|
const controller = new AbortController();
|
|
238
|
-
const
|
|
239
|
-
|
|
244
|
+
const lottieUrl = resolveLottieFileUrl(
|
|
245
|
+
resolvedLottieBasePath,
|
|
246
|
+
resolvedLottieFileName
|
|
247
|
+
);
|
|
240
248
|
fetch(lottieUrl, { signal: controller.signal }).then((response) => {
|
|
241
249
|
if (!response.ok) {
|
|
242
250
|
throw new Error(`Failed to load lottie file: ${lottieUrl}`);
|
|
@@ -251,7 +259,7 @@ function Button({
|
|
|
251
259
|
setResolvedLottieData(null);
|
|
252
260
|
});
|
|
253
261
|
return () => controller.abort();
|
|
254
|
-
}, [loadingLottieData,
|
|
262
|
+
}, [loadingLottieData, resolvedLottieFileName, resolvedLottieBasePath]);
|
|
255
263
|
const styleVars = {
|
|
256
264
|
"--button-font-family": theme.components.button.fonts.family,
|
|
257
265
|
"--button-font-weight": theme.components.button.fonts.weight,
|
package/dist/index.mjs
CHANGED
|
@@ -80,6 +80,9 @@ var defaultTheme = {
|
|
|
80
80
|
height: "2.5rem",
|
|
81
81
|
minWidth: "8rem",
|
|
82
82
|
radius: "6px"
|
|
83
|
+
},
|
|
84
|
+
lottie: {
|
|
85
|
+
basePath: "/lotties"
|
|
83
86
|
}
|
|
84
87
|
},
|
|
85
88
|
table: {
|
|
@@ -158,19 +161,24 @@ function Button({
|
|
|
158
161
|
...rest
|
|
159
162
|
}) {
|
|
160
163
|
const theme = useLeafcodeTheme();
|
|
164
|
+
const themeButtonLottie = theme.components.button.lottie;
|
|
161
165
|
const [resolvedLottieData, setResolvedLottieData] = useState(loadingLottieData ?? null);
|
|
166
|
+
const resolvedLottieFileName = loadingLottieFileName ?? themeButtonLottie?.fileName;
|
|
167
|
+
const resolvedLottieBasePath = loadingLottieBasePath ?? themeButtonLottie?.basePath ?? DEFAULT_LOTTIE_BASE_PATH;
|
|
162
168
|
useEffect(() => {
|
|
163
169
|
if (loadingLottieData) {
|
|
164
170
|
setResolvedLottieData(loadingLottieData);
|
|
165
171
|
return;
|
|
166
172
|
}
|
|
167
|
-
if (!
|
|
173
|
+
if (!resolvedLottieFileName) {
|
|
168
174
|
setResolvedLottieData(null);
|
|
169
175
|
return;
|
|
170
176
|
}
|
|
171
177
|
const controller = new AbortController();
|
|
172
|
-
const
|
|
173
|
-
|
|
178
|
+
const lottieUrl = resolveLottieFileUrl(
|
|
179
|
+
resolvedLottieBasePath,
|
|
180
|
+
resolvedLottieFileName
|
|
181
|
+
);
|
|
174
182
|
fetch(lottieUrl, { signal: controller.signal }).then((response) => {
|
|
175
183
|
if (!response.ok) {
|
|
176
184
|
throw new Error(`Failed to load lottie file: ${lottieUrl}`);
|
|
@@ -185,7 +193,7 @@ function Button({
|
|
|
185
193
|
setResolvedLottieData(null);
|
|
186
194
|
});
|
|
187
195
|
return () => controller.abort();
|
|
188
|
-
}, [loadingLottieData,
|
|
196
|
+
}, [loadingLottieData, resolvedLottieFileName, resolvedLottieBasePath]);
|
|
189
197
|
const styleVars = {
|
|
190
198
|
"--button-font-family": theme.components.button.fonts.family,
|
|
191
199
|
"--button-font-weight": theme.components.button.fonts.weight,
|