@lark-apaas/client-toolkit-lite 1.1.1-alpha.1 → 1.1.1-alpha.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/dist/index.cjs CHANGED
@@ -34,6 +34,7 @@ __export(index_exports, {
34
34
  ActiveLink: () => ActiveLink,
35
35
  AppContainer: () => AppContainer_default,
36
36
  NavLink: () => NavLink2,
37
+ PagePlaceholder: () => PagePlaceholder_default,
37
38
  QueryProvider: () => QueryProvider_default,
38
39
  TrackKey: () => TrackKey,
39
40
  UniversalLink: () => UniversalLink,
@@ -570,9 +571,52 @@ var messages = {
570
571
  var messages_default = messages;
571
572
 
572
573
  // src/utils/locale.ts
574
+ var STORAGE_KEY = "miaoda:preview-locale";
575
+ function toLocale(value) {
576
+ const lang = value ?? "zh";
577
+ return lang.toLowerCase().startsWith("zh") ? "zh" : "en";
578
+ }
579
+ __name(toLocale, "toLocale");
580
+ function readLocaleFromQuery() {
581
+ if (typeof window === "undefined") return null;
582
+ try {
583
+ const value = new URLSearchParams(window.location.search).get("locale");
584
+ return value && value.length > 0 ? value : null;
585
+ } catch {
586
+ return null;
587
+ }
588
+ }
589
+ __name(readLocaleFromQuery, "readLocaleFromQuery");
590
+ function readLocaleFromStorage() {
591
+ if (typeof window === "undefined") return null;
592
+ try {
593
+ const value = window.localStorage?.getItem(STORAGE_KEY);
594
+ return value && value.length > 0 ? value : null;
595
+ } catch {
596
+ return null;
597
+ }
598
+ }
599
+ __name(readLocaleFromStorage, "readLocaleFromStorage");
600
+ function writeLocaleToStorage(value) {
601
+ if (typeof window === "undefined") return;
602
+ try {
603
+ window.localStorage?.setItem(STORAGE_KEY, value);
604
+ } catch {
605
+ }
606
+ }
607
+ __name(writeLocaleToStorage, "writeLocaleToStorage");
573
608
  function getLocale() {
574
- const lang = navigator.language || "zh";
575
- return lang.startsWith("zh") ? "zh" : "en";
609
+ if (process.env.NODE_ENV === "production") {
610
+ return toLocale(navigator.language);
611
+ }
612
+ const fromQuery = readLocaleFromQuery();
613
+ if (fromQuery) {
614
+ writeLocaleToStorage(fromQuery);
615
+ return toLocale(fromQuery);
616
+ }
617
+ const fromStorage = readLocaleFromStorage();
618
+ if (fromStorage) return toLocale(fromStorage);
619
+ return toLocale(navigator.language);
576
620
  }
577
621
  __name(getLocale, "getLocale");
578
622
 
@@ -1240,28 +1284,96 @@ var AppContainer_default = AppContainer;
1240
1284
  var import_react8 = __toESM(require("react"), 1);
1241
1285
  var Welcome = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1", description = "\u9875\u9762\u6682\u672A\u5F00\u53D1\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85..." }) => {
1242
1286
  return /* @__PURE__ */ import_react8.default.createElement("div", {
1243
- className: "flex flex-col items-center justify-center px-6 w-full h-[calc(100vh-64px)] text-center"
1287
+ style: {
1288
+ display: "flex",
1289
+ flexDirection: "column",
1290
+ alignItems: "center",
1291
+ justifyContent: "center",
1292
+ width: "100%",
1293
+ height: "calc(100vh - 64px)",
1294
+ padding: "0 24px",
1295
+ textAlign: "center"
1296
+ }
1244
1297
  }, /* @__PURE__ */ import_react8.default.createElement("img", {
1245
- className: "rounded-md mb-6",
1298
+ style: {
1299
+ borderRadius: 6,
1300
+ marginBottom: 24
1301
+ },
1246
1302
  width: "320",
1247
1303
  height: "200",
1248
1304
  src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/welcome.svg",
1249
1305
  alt: "Welcome"
1250
1306
  }), /* @__PURE__ */ import_react8.default.createElement("div", {
1251
- className: "text-center text-foreground text-base font-medium mb-1 leading-6"
1307
+ style: {
1308
+ fontSize: 16,
1309
+ fontWeight: 500,
1310
+ lineHeight: "24px",
1311
+ marginBottom: 4,
1312
+ color: "#1f2329"
1313
+ }
1252
1314
  }, title), /* @__PURE__ */ import_react8.default.createElement("div", {
1253
- className: "text-center text-muted-foreground text-base leading-6 line-clamp-2 sm:max-w-[480px]"
1315
+ style: {
1316
+ fontSize: 16,
1317
+ lineHeight: "24px",
1318
+ color: "#8f959e",
1319
+ maxWidth: 480
1320
+ }
1254
1321
  }, description));
1255
1322
  }, "Welcome");
1256
1323
  var Welcome_default = Welcome;
1257
1324
 
1258
- // src/route-components/ActiveLink.tsx
1325
+ // src/components/PagePlaceholder/index.tsx
1259
1326
  var import_react9 = __toESM(require("react"), 1);
1327
+ var PagePlaceholder = /* @__PURE__ */ __name(({ title = "\u9875\u9762\u5F85\u5F00\u53D1", description = "\u9875\u9762\u6682\u672A\u5F00\u53D1\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85..." }) => {
1328
+ return /* @__PURE__ */ import_react9.default.createElement("div", {
1329
+ style: {
1330
+ display: "flex",
1331
+ flexDirection: "column",
1332
+ alignItems: "center",
1333
+ justifyContent: "center",
1334
+ padding: "0 24px",
1335
+ width: "100%",
1336
+ height: "calc(100vh - 64px)",
1337
+ textAlign: "center"
1338
+ }
1339
+ }, /* @__PURE__ */ import_react9.default.createElement("img", {
1340
+ style: {
1341
+ borderRadius: "6px",
1342
+ marginBottom: "24px"
1343
+ },
1344
+ width: "320",
1345
+ height: "200",
1346
+ src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/welcome.svg",
1347
+ alt: "Welcome"
1348
+ }), /* @__PURE__ */ import_react9.default.createElement("div", {
1349
+ style: {
1350
+ fontSize: "16px",
1351
+ fontWeight: 500,
1352
+ marginBottom: "4px",
1353
+ lineHeight: "24px"
1354
+ }
1355
+ }, title), /* @__PURE__ */ import_react9.default.createElement("div", {
1356
+ style: {
1357
+ color: "#6b7280",
1358
+ fontSize: "16px",
1359
+ lineHeight: "24px",
1360
+ maxWidth: "480px",
1361
+ overflow: "hidden",
1362
+ display: "-webkit-box",
1363
+ WebkitLineClamp: 2,
1364
+ WebkitBoxOrient: "vertical"
1365
+ }
1366
+ }, description));
1367
+ }, "PagePlaceholder");
1368
+ var PagePlaceholder_default = PagePlaceholder;
1369
+
1370
+ // src/route-components/ActiveLink.tsx
1371
+ var import_react10 = __toESM(require("react"), 1);
1260
1372
  var import_react_router_dom = require("react-router-dom");
1261
- var ActiveLink = /* @__PURE__ */ (0, import_react9.forwardRef)(({ to, onClick, className, style, children, ...rest }, ref) => {
1262
- const [currentHash, setCurrentHash] = (0, import_react9.useState)(() => typeof window !== "undefined" ? window.location.hash : "");
1373
+ var ActiveLink = /* @__PURE__ */ (0, import_react10.forwardRef)(({ to, onClick, className, style, children, ...rest }, ref) => {
1374
+ const [currentHash, setCurrentHash] = (0, import_react10.useState)(() => typeof window !== "undefined" ? window.location.hash : "");
1263
1375
  const isHashRoute = typeof to === "string" && to.startsWith("#");
1264
- (0, import_react9.useEffect)(() => {
1376
+ (0, import_react10.useEffect)(() => {
1265
1377
  if (!isHashRoute) return;
1266
1378
  const handleHashChange = /* @__PURE__ */ __name(() => {
1267
1379
  setCurrentHash(window.location.hash);
@@ -1273,7 +1385,7 @@ var ActiveLink = /* @__PURE__ */ (0, import_react9.forwardRef)(({ to, onClick, c
1273
1385
  ]);
1274
1386
  const isActive = isHashRoute && currentHash === to;
1275
1387
  if (!isHashRoute) {
1276
- return /* @__PURE__ */ import_react9.default.createElement(import_react_router_dom.NavLink, {
1388
+ return /* @__PURE__ */ import_react10.default.createElement(import_react_router_dom.NavLink, {
1277
1389
  ref,
1278
1390
  to,
1279
1391
  onClick,
@@ -1314,7 +1426,7 @@ var ActiveLink = /* @__PURE__ */ (0, import_react9.forwardRef)(({ to, onClick, c
1314
1426
  isPending: false,
1315
1427
  isTransitioning: false
1316
1428
  }) : children;
1317
- return /* @__PURE__ */ import_react9.default.createElement("a", {
1429
+ return /* @__PURE__ */ import_react10.default.createElement("a", {
1318
1430
  ref,
1319
1431
  href: to,
1320
1432
  onClick: handleHashClick,
@@ -1326,9 +1438,9 @@ var ActiveLink = /* @__PURE__ */ (0, import_react9.forwardRef)(({ to, onClick, c
1326
1438
  ActiveLink.displayName = "ActiveLink";
1327
1439
 
1328
1440
  // src/route-components/NavLink.tsx
1329
- var React7 = __toESM(require("react"), 1);
1441
+ var React8 = __toESM(require("react"), 1);
1330
1442
  var import_react_router_dom2 = require("react-router-dom");
1331
- var NavLink2 = /* @__PURE__ */ React7.forwardRef(({ to, children, className, style, ...props }, ref) => {
1443
+ var NavLink2 = /* @__PURE__ */ React8.forwardRef(({ to, children, className, style, ...props }, ref) => {
1332
1444
  const isHashLink = typeof to === "string" && to.startsWith("#");
1333
1445
  const location = (0, import_react_router_dom2.useLocation)();
1334
1446
  const navigate = (0, import_react_router_dom2.useNavigate)();
@@ -1352,7 +1464,7 @@ var NavLink2 = /* @__PURE__ */ React7.forwardRef(({ to, children, className, sty
1352
1464
  const resolvedClassName = typeof className === "function" ? className(renderProps) : className;
1353
1465
  const resolvedStyle = typeof style === "function" ? style(renderProps) : style;
1354
1466
  const { caseSensitive, end, replace, state, preventScrollReset, relative, viewTransition, ...restProps } = props;
1355
- return /* @__PURE__ */ React7.createElement("a", {
1467
+ return /* @__PURE__ */ React8.createElement("a", {
1356
1468
  href: to,
1357
1469
  onClick: handleClick,
1358
1470
  ref,
@@ -1361,7 +1473,7 @@ var NavLink2 = /* @__PURE__ */ React7.forwardRef(({ to, children, className, sty
1361
1473
  ...restProps
1362
1474
  }, typeof children === "function" ? children(renderProps) : children);
1363
1475
  }
1364
- return /* @__PURE__ */ React7.createElement(import_react_router_dom2.NavLink, {
1476
+ return /* @__PURE__ */ React8.createElement(import_react_router_dom2.NavLink, {
1365
1477
  to,
1366
1478
  ref,
1367
1479
  className,
@@ -1376,7 +1488,7 @@ var NavLink2 = /* @__PURE__ */ React7.forwardRef(({ to, children, className, sty
1376
1488
  NavLink2.displayName = "NavLink";
1377
1489
 
1378
1490
  // src/route-components/UniversalLink.tsx
1379
- var import_react10 = __toESM(require("react"), 1);
1491
+ var import_react11 = __toESM(require("react"), 1);
1380
1492
  var import_react_router_dom3 = require("react-router-dom");
1381
1493
  function isInternalRoute(to) {
1382
1494
  return !to.startsWith("#") && !to.startsWith("http://") && !to.startsWith("https://") && !to.startsWith("//");
@@ -1386,15 +1498,15 @@ function isExternalLink(to) {
1386
1498
  return to.startsWith("http://") || to.startsWith("https://") || to.startsWith("//");
1387
1499
  }
1388
1500
  __name(isExternalLink, "isExternalLink");
1389
- var UniversalLink = /* @__PURE__ */ import_react10.default.forwardRef(/* @__PURE__ */ __name(function UniversalLink2({ to, ...props }, ref) {
1501
+ var UniversalLink = /* @__PURE__ */ import_react11.default.forwardRef(/* @__PURE__ */ __name(function UniversalLink2({ to, ...props }, ref) {
1390
1502
  if (isInternalRoute(to)) {
1391
- return /* @__PURE__ */ import_react10.default.createElement(import_react_router_dom3.Link, {
1503
+ return /* @__PURE__ */ import_react11.default.createElement(import_react_router_dom3.Link, {
1392
1504
  to,
1393
1505
  ref,
1394
1506
  ...props
1395
1507
  });
1396
1508
  }
1397
- return /* @__PURE__ */ import_react10.default.createElement("a", {
1509
+ return /* @__PURE__ */ import_react11.default.createElement("a", {
1398
1510
  href: to,
1399
1511
  ref,
1400
1512
  ...props,
@@ -1819,6 +1931,7 @@ var abstractArt3dRenderingCoverImg6 = "https://lf3-static.bytednsdoc.com/obj/ede
1819
1931
  ActiveLink,
1820
1932
  AppContainer,
1821
1933
  NavLink,
1934
+ PagePlaceholder,
1822
1935
  QueryProvider,
1823
1936
  TrackKey,
1824
1937
  UniversalLink,