lingee-ui 0.0.16 → 0.0.17
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/button/index.css +1 -1
- package/dist/button/index.d.mts +1 -1
- package/dist/button/index.d.ts +1 -1
- package/dist/button/index.js +1 -1
- package/dist/button/index.mjs +1 -1
- package/dist/{chunk-7I26V66U.js → chunk-3IO42CRF.js} +1 -1
- package/dist/chunk-3RAHZU2C.js +1 -0
- package/dist/{chunk-LAIK6VBD.mjs → chunk-4OLAOR2B.mjs} +1 -1
- package/dist/{chunk-22TFFOQL.js → chunk-CW6SU5IY.js} +1 -1
- package/dist/{chunk-HOX3ZANF.mjs → chunk-H44VO62M.mjs} +1 -1
- package/dist/chunk-KSRZSPQR.js +1 -0
- package/dist/{chunk-ZX6JEZS3.mjs → chunk-L6IXM6OV.mjs} +1 -1
- package/dist/{chunk-T4CPHENK.js → chunk-O6LSVS7F.js} +1 -1
- package/dist/{chunk-Q5MDN5PA.js → chunk-QRQE2XPJ.js} +1 -1
- package/dist/{chunk-YPES54ON.mjs → chunk-TL3WZ5RY.mjs} +1 -1
- package/dist/chunk-X2JJ6KOR.mjs +1 -0
- package/dist/chunk-XQRQYJIE.mjs +1 -0
- package/dist/{index-7pb5YOcq.d.mts → index-BVXwKHfX.d.mts} +1 -1
- package/dist/{index-7pb5YOcq.d.ts → index-BVXwKHfX.d.ts} +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.mts +75 -3
- package/dist/index.d.ts +75 -3
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/input/index.css +1 -1
- package/dist/input/index.d.mts +6 -0
- package/dist/input/index.d.ts +6 -0
- package/dist/input/index.js +1 -1
- package/dist/input/index.mjs +1 -1
- package/dist/popover/index.css +1 -1
- package/dist/switch/index.css +1 -1
- package/dist/switch/index.js +1 -1
- package/dist/switch/index.mjs +1 -1
- package/dist/tabs/index.css +1 -1
- package/dist/tabs/index.d.mts +1 -1
- package/dist/tabs/index.d.ts +1 -1
- package/dist/tabs/index.js +1 -1
- package/dist/tabs/index.mjs +1 -1
- package/dist/toast/index.js +1 -1
- package/dist/toast/index.mjs +1 -1
- package/dist/tree/index.js +1 -1
- package/dist/tree/index.mjs +1 -1
- package/package.json +1 -1
- package/skill/AGENTS-SNIPPET.md +3 -2
- package/skill/SKILL.md +6 -5
- package/skill/VERSION.json +5 -5
- package/skill/references/components/infinite-scroll.md +74 -0
- package/skill/references/components/input.md +1 -0
- package/skill/references/components/tooltip.md +0 -1
- package/skill/references/icons.md +5 -2
- package/skill/references/setup.md +1 -1
- package/skill/references/tokens.md +1 -1
- package/dist/chunk-CB2FRG23.js +0 -1
- package/dist/chunk-CGHN44HV.mjs +0 -1
- package/dist/chunk-ITHSP4P3.js +0 -1
- package/dist/chunk-YNDT7LQA.mjs +0 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# InfiniteScroll 无限滚动
|
|
2
|
+
|
|
3
|
+
列表滚动到底部自动加载下一页,内置并发去重、首屏续拉与失败熔断
|
|
4
|
+
|
|
5
|
+
- 导入:`import { InfiniteScroll } from "lingee-ui";`
|
|
6
|
+
- 可用类型:`InfiniteScrollProps`, `InfiniteScrollTarget`
|
|
7
|
+
|
|
8
|
+
## 最小示例
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
import { useState } from "react";
|
|
12
|
+
import { InfiniteScroll, ScrollArea } from "lingee-ui";
|
|
13
|
+
|
|
14
|
+
/** 模拟分页请求 */
|
|
15
|
+
function fetchPage(page: number): Promise<string[]> {
|
|
16
|
+
return new Promise((resolve) => {
|
|
17
|
+
setTimeout(() => {
|
|
18
|
+
resolve(Array.from({ length: 10 }, (_, i) => `Item ${page * 10 + i + 1}`));
|
|
19
|
+
}, 600);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const TOTAL_PAGES = 3;
|
|
24
|
+
|
|
25
|
+
export default function Basic() {
|
|
26
|
+
const [items, setItems] = useState<string[]>([]);
|
|
27
|
+
const [page, setPage] = useState(0);
|
|
28
|
+
|
|
29
|
+
const hasMore = page < TOTAL_PAGES;
|
|
30
|
+
|
|
31
|
+
const loadMore = async () => {
|
|
32
|
+
const next = await fetchPage(page);
|
|
33
|
+
setItems((prev) => [...prev, ...next]);
|
|
34
|
+
setPage((prev) => prev + 1);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<ScrollArea fill style={{ height: 240 }}>
|
|
39
|
+
<div style={{ display: "flex", flexDirection: "column", gap: 8, padding: 12 }}>
|
|
40
|
+
{items.map((item) => (
|
|
41
|
+
<div
|
|
42
|
+
key={item}
|
|
43
|
+
style={{
|
|
44
|
+
padding: "8px 12px",
|
|
45
|
+
borderRadius: 8,
|
|
46
|
+
background: "var(--lg-g-bg-color-black-faint)",
|
|
47
|
+
color: "var(--lg-g-fg-color-black-strong)",
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
{item}
|
|
51
|
+
</div>
|
|
52
|
+
))}
|
|
53
|
+
<InfiniteScroll loadMore={loadMore} hasMore={hasMore} />
|
|
54
|
+
</div>
|
|
55
|
+
</ScrollArea>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## API
|
|
61
|
+
|
|
62
|
+
继承 `HTMLAttributes<HTMLDivElement>`(不含 `children`)。
|
|
63
|
+
|
|
64
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
65
|
+
|------|------|------|--------|
|
|
66
|
+
| loadMore | 加载下一页,必须返回 Promise。`isRetry` 为 true 表示由用户点击重试触发 | `(isRetry: boolean) => Promise<void>` | — |
|
|
67
|
+
| hasMore | 是否还有更多数据,为 false 时停止观测并渲染「没有更多」态 | `boolean` | — |
|
|
68
|
+
| threshold | 距容器底部多少像素时触发 | `number` | `80` |
|
|
69
|
+
| scrollTarget | 显式指定滚动容器,缺省自动查找最近可滚动祖先 | `HTMLElement \| Window \| null \| (() => HTMLElement \| Window \| null)` | — |
|
|
70
|
+
| loading | 加载中的自定义内容,传 `null` 则不渲染 | `ReactNode` | `Empty.Card` inline 加载态 |
|
|
71
|
+
| noMore | 无更多数据时的自定义内容,传 `null` 则不渲染 | `ReactNode` | `Empty.Card` inline 空态 |
|
|
72
|
+
| error | 加载失败时的自定义内容,函数形态可拿到重试句柄 | `ReactNode \| ((retry: () => void) => ReactNode)` | `Empty.Card` inline 错误态 + 重试 |
|
|
73
|
+
| className | 自定义类名 | `string` | — |
|
|
74
|
+
| style | 自定义行内样式 | `CSSProperties` | — |
|
|
@@ -27,6 +27,7 @@ export default function BasicDemo() {
|
|
|
27
27
|
| `error` | 错误状态 | `boolean` | `false` |
|
|
28
28
|
| `disabled` | 禁用状态 | `boolean` | `false` |
|
|
29
29
|
| `collapsed` | 折叠为正方形,仅展示单个插槽;受控,展开时机由 `onClick` 自行处理 | `boolean` | `false` |
|
|
30
|
+
| `autoFocusOnExpand` | 折叠切换为展开时是否自动聚焦;布局驱动展开的场景传 `false` 自行控制聚焦时机 | `boolean` | `true` |
|
|
30
31
|
| `onPressEnter` | 按下 Enter 键回调 | `(e: KeyboardEvent) => void` | - |
|
|
31
32
|
| `placeholder` | 占位提示文字 | `string` | - |
|
|
32
33
|
| `value` | 输入值(受控) | `string` | - |
|
|
@@ -36,7 +36,6 @@ export default function BasicDemo() {
|
|
|
36
36
|
| `defaultOpen` | 非受控默认打开状态 | `boolean` | `false` |
|
|
37
37
|
| `onOpenChange` | 开关变化回调 | `(open: boolean) => void` | - |
|
|
38
38
|
| `container` | 挂载容器;传 `null` 则不使用 Portal(就地渲染) | `HTMLElement \| null` | `document.body` |
|
|
39
|
-
|
|
40
39
|
| `children` | 触发元素 | `ReactNode` | - |
|
|
41
40
|
|
|
42
41
|
:::tip
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 图标索引
|
|
2
2
|
|
|
3
|
-
图标库 `1.0.
|
|
3
|
+
图标库 `1.0.21`,共 990 个图标、27 个分类。图标名为 PascalCase,直接作为 React 组件名从 `lingee-icon` 导入。
|
|
4
4
|
|
|
5
5
|
```tsx
|
|
6
6
|
import { Search } from "lingee-icon";
|
|
@@ -263,7 +263,7 @@ import { Search } from "lingee-icon";
|
|
|
263
263
|
| ZoomInBold | 放大(粗体) |
|
|
264
264
|
| ZoomOutBold | 缩小(粗体) |
|
|
265
265
|
|
|
266
|
-
## 数据类(
|
|
266
|
+
## 数据类(37)
|
|
267
267
|
|
|
268
268
|
| 图标名 | 语义/用途 |
|
|
269
269
|
|--------|----------|
|
|
@@ -283,6 +283,7 @@ import { Search } from "lingee-icon";
|
|
|
283
283
|
| DataMonitoring | 数据监控 |
|
|
284
284
|
| DataOrigin | 数据源/原始数据表 |
|
|
285
285
|
| DataRow | 数据行/按行拆分 |
|
|
286
|
+
| DateCount | 日期汇总/日期统计(日历∑) |
|
|
286
287
|
| Dynamics | 动态 |
|
|
287
288
|
| Fall | 下跌 |
|
|
288
289
|
| GraphDown | 趋势下降 |
|
|
@@ -299,8 +300,10 @@ import { Search } from "lingee-icon";
|
|
|
299
300
|
| RadarChart | 雷达图 |
|
|
300
301
|
| Rise | 上涨 |
|
|
301
302
|
| Sigma | 求和/合计/汇总(∑) |
|
|
303
|
+
| TextCount | 文本汇总/文本统计(T∑) |
|
|
302
304
|
| Thought | 思维 |
|
|
303
305
|
| UnionAll | 全量合并/并集(Union All) |
|
|
306
|
+
| ValueCount | 数值汇总/数值统计(#∑) |
|
|
304
307
|
|
|
305
308
|
## AI类(76)
|
|
306
309
|
|
package/dist/chunk-CB2FRG23.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkP427AFIE_js=require('./chunk-P427AFIE.js'),chunkDCDWEVW4_js=require('./chunk-DCDWEVW4.js'),ze=require('react'),sonner=require('sonner'),lingeeIcon=require('lingee-icon'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ze__default=/*#__PURE__*/_interopDefault(ze);var ce={locale:"zh-CN",Button:{},Breadcrumb:{more:"\u66F4\u591A",back:"\u8FD4\u56DE"},Select:{loading:"\u52A0\u8F7D\u4E2D",loadError:"\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",loadFailed:"\u52A0\u8F7D\u5931\u8D25",notFound:"\u641C\u7D22\u65E0\u7ED3\u679C",clear:"\u6E05\u7A7A"},Dropdown:{clear:"\u6E05\u9664",loading:"\u52A0\u8F7D\u4E2D",loadError:"\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",empty:"\u6682\u65E0\u6570\u636E"},Tabs:{scrollLeft:"\u5411\u5DE6\u6EDA\u52A8",scrollRight:"\u5411\u53F3\u6EDA\u52A8"},Carousel:{carousel:"\u8F6E\u64AD",prev:"\u4E0A\u4E00\u5F20",next:"\u4E0B\u4E00\u5F20",goToPage:"\u8DF3\u8F6C\u5230\u7B2C {page} \u5F20"},Form:{required:"{label}\u4E0D\u80FD\u4E3A\u7A7A",requiredNoLabel:"\u6B64\u9879\u4E0D\u80FD\u4E3A\u7A7A"},Tag:{close:"\u5173\u95ED"},Upload:{retry:"\u91CD\u65B0\u4E0A\u4F20",remove:"\u79FB\u9664\u6587\u4EF6",removeShort:"\u79FB\u9664",dragText:"\u62D6\u62FD\u6587\u4EF6\u5230\u6B64\u5904\uFF0C\u6216",clickUpload:"\u70B9\u51FB\u4E0A\u4F20"},ColorPicker:{placeholder:"\u8BF7\u9009\u62E9\u989C\u8272"},DatePicker:{placeholder:"\u5E74/\u6708/\u65E5",today:"\u4ECA\u5929",prevYear:"\u4E0A\u4E00\u5E74",nextYear:"\u4E0B\u4E00\u5E74",prevMonth:"\u4E0A\u4E00\u6708",nextMonth:"\u4E0B\u4E00\u6708",prevDecade:"\u4E0A\u4E00\u7EC4\u5E74\u4EFD",nextDecade:"\u4E0B\u4E00\u7EC4\u5E74\u4EFD",months:["1\u6708","2\u6708","3\u6708","4\u6708","5\u6708","6\u6708","7\u6708","8\u6708","9\u6708","10\u6708","11\u6708","12\u6708"],yearFormat:"{year}\u5E74",monthFormat:"{month}\u6708"},RangePicker:{startPlaceholder:"\u5E74/\u6708/\u65E5",endPlaceholder:"\u5E74/\u6708/\u65E5"},TimePicker:{now:"\u73B0\u5728",confirm:"\u786E\u5B9A",placeholder:"\u65F6:\u5206",placeholderFull:"\u65F6:\u5206:\u79D2"},Table:{loading:"\u52A0\u8F7D\u4E2D",empty:"\u6682\u65E0\u6570\u636E",loadError:"\u52A0\u8F7D\u5931\u8D25"},Tree:{empty:"\u6682\u65E0\u6570\u636E"},Pagination:{total:"\u5171 {total} \u6761",prevPage:"\u4E0A\u4E00\u9875",nextPage:"\u4E0B\u4E00\u9875",itemsPerPage:"{size}\u6761/\u9875",jumpTo:"\u8DF3\u81F3",page:"\u9875"},Dialog:{close:"\u5173\u95ED"},Drawer:{close:"\u5173\u95ED"},Input:{clear:"\u6E05\u7A7A",expand:"\u5C55\u5F00\u8F93\u5165\u6846"},Alert:{close:"\u5173\u95ED"},Toast:{close:"\u5173\u95ED\u6D88\u606F"},Spin:{loading:"\u52A0\u8F7D\u4E2D"},Empty:{retry:"\u91CD\u8BD5"},Sidebar:{expand:"\u5C55\u5F00",collapse:"\u6536\u8D77",loading:"\u52A0\u8F7D\u4E2D",empty:"\u6682\u65E0\u6570\u636E",loadError:"\u52A0\u8F7D\u5931\u8D25"}},v=ce;var _=new Map,F=0;function A(){return F+=1,{id:F}}function z(e,o,t){_.set(e.id,{site:o,depth:t});}function Y(e){_.delete(e.id);}function pe(){let e;for(let o of _.values())(!e||o.depth>=e.depth)&&(e=o);return e?.site}function E(){return pe()==="lingee"}var U={dialog:{}},h=ze.createContext(U),D=new Map,B=0;function G(){return B+=1,{id:B}}function q(e,o,t){D.set(e.id,{config:o,depth:t});}function j(e){D.delete(e.id);}function ge(){let e;for(let o of D.values())(!e||o.depth>=e.depth)&&(e=o);return e?.config??U}function me(){return ze.useContext(h)}var Te={locale:"en-US",Button:{},Breadcrumb:{more:"More",back:"Back"},Select:{loading:"Loading",loadError:"Failed to load, please retry",loadFailed:"Failed to load",notFound:"No results found",clear:"Clear"},Dropdown:{clear:"Clear",loading:"Loading",loadError:"Failed to load, please retry",empty:"No data"},Tabs:{scrollLeft:"Scroll left",scrollRight:"Scroll right"},Carousel:{carousel:"Carousel",prev:"Previous slide",next:"Next slide",goToPage:"Go to slide {page}"},Form:{required:"{label} is required",requiredNoLabel:"This field is required"},Tag:{close:"Close"},Upload:{retry:"Retry upload",remove:"Remove file",removeShort:"Remove",dragText:"Drag files here, or ",clickUpload:"click to upload"},ColorPicker:{placeholder:"Select a color"},DatePicker:{placeholder:"YYYY/MM/DD",today:"Today",prevYear:"Previous year",nextYear:"Next year",prevMonth:"Previous month",nextMonth:"Next month",prevDecade:"Previous decade",nextDecade:"Next decade",months:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],yearFormat:"{year}",monthFormat:"{month}"},RangePicker:{startPlaceholder:"Start date",endPlaceholder:"End date"},TimePicker:{now:"Now",confirm:"OK",placeholder:"HH:mm",placeholderFull:"HH:mm:ss"},Table:{loading:"Loading",empty:"No data",loadError:"Failed to load"},Tree:{empty:"No data"},Pagination:{total:"{total} items",prevPage:"Previous page",nextPage:"Next page",itemsPerPage:"{size} / page",jumpTo:"Go to",page:""},Dialog:{close:"Close"},Drawer:{close:"Close"},Input:{clear:"Clear",expand:"Expand input"},Alert:{close:"Close"},Toast:{close:"Close message"},Spin:{loading:"Loading"},Empty:{retry:"Retry"},Sidebar:{expand:"Expand",collapse:"Collapse",loading:"Loading",empty:"No data",loadError:"Failed to load"}},xe=Te;var V=ze.createContext(v),Z=ze.createContext(void 0),X=ze.createContext(-1);function ve({locale:e=v,site:o,dialog:t,children:n}){let r=ze.useContext(X)+1,a=ze.useContext(h),i=t?.zIndex,s=a.dialog.zIndex,l=ze.useMemo(()=>({dialog:{zIndex:i??s}}),[i,s]),c=ze.useRef();c.current||(c.current=A());let p=c.current,g=ze.useRef();g.current||(g.current=G());let m=g.current;z(p,o,r),q(m,l,r),ze.useEffect(()=>()=>{Y(p),j(m);},[m,p]);let d=jsxRuntime.jsx(X.Provider,{value:r,children:jsxRuntime.jsx(h.Provider,{value:l,children:jsxRuntime.jsx(Z.Provider,{value:o,children:jsxRuntime.jsxs(V.Provider,{value:e,children:[n,r===0&&jsxRuntime.jsx(J,{})]})})})});return r===0?jsxRuntime.jsx(chunkP427AFIE_js.c,{children:d}):d}ve.displayName="LingeeProvider";function he(){return ze.useContext(V)}function W(e){return he()[e]}function oo(){return ze.useContext(Z)}var _e={info:jsxRuntime.jsx(lingeeIcon.ExclamationCircleFill,{size:20}),success:jsxRuntime.jsx(lingeeIcon.CheckCircleFill,{size:20}),warning:jsxRuntime.jsx(lingeeIcon.ExclamationCircleFill1,{size:20}),error:jsxRuntime.jsx(lingeeIcon.XCircleFill,{size:20})};function $({type:e,content:o,icon:t,closable:n,className:r,onClose:a}){let i=W("Toast"),s=()=>{if(t===null)return null;let l=t!==void 0?t:_e[e];return jsxRuntime.jsx("span",{className:"lg-toast__icon",children:l})};return jsxRuntime.jsxs("div",{className:chunkDCDWEVW4_js.a("lg-toast",`lg-toast--${e}`,r),children:[s(),jsxRuntime.jsx("span",{className:"lg-toast__content",children:o}),n&&jsxRuntime.jsx("button",{className:"lg-toast__close",onClick:a,"aria-label":i.close,type:"button",children:jsxRuntime.jsx(lingeeIcon.XLg,{size:16})})]})}var ee="lingee-web-bridge",oe="1.0.0",De="host",Ne="iframe",Re="lingee-web-bridge:host-toast-show",He="lingee-web-bridge:host-toast-dismiss",Ie="lingee-web-bridge:host-toast-probe",Me="lingee-web-bridge:host-toast-ready";function te(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();let e=Date.now();return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,o=>{let t=(e+Math.random()*16)%16|0;return e=Math.floor(e/16),(o==="x"?t:t&3|8).toString(16)})}function Oe(e,o){return {_protocol:ee,_version:oe,_source:e,_nonce:te(),_traceId:"",payload:o}}function Fe(e,o){if(typeof e!="object"||e===null)return false;let t=e;return t._protocol===ee&&t._version===oe&&t._source===o&&typeof t._nonce=="string"&&"payload"in t}function y(){return typeof window<"u"&&window.parent!==window}var C=false,f=new Map,Q=false;function Ae(e){if(!Fe(e,De))return false;let o=e.payload;return !!o&&typeof o=="object"&&o.type===Me}function R(e){window.parent.postMessage(Oe(Ne,e),"*");}function w(){Q||!y()||(Q=true,window.addEventListener("message",e=>{e.source===window.parent&&Ae(e.data)&&(C=true);}),window.addEventListener("pagehide",()=>{!C||f.size===0||k();}),R({type:Ie}));}function H(){return w(),C}function ne(e){if(w(),!C||!e.content)return null;let o=te();R({type:Re,toastId:o,content:e.content.slice(0,500),level:e.level,duration:e.duration,key:e.key});let t=e.duration??3e3,n=t>0?window.setTimeout(()=>f.delete(o),t+500):void 0;return f.set(o,n),o}function k(e){if(w(),!!C){if(e){let o=f.get(e);o!==void 0&&window.clearTimeout(o),f.delete(e);}else f.forEach(o=>{o!==void 0&&window.clearTimeout(o);}),f.clear();R({type:He,toastId:e});}}w();function I(){if(!(typeof window>"u"))return window.lingeeBridge}function re(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e)}function ie(e,o={}){return !(!(y()?H():E()&&typeof I()?.showToast=="function")||re(e.content)===void 0||e.icon!==void 0||e.className!==void 0||e.closable||o.getContainer!==void 0||o.top!==void 0||o.maxCount!==void 0)}function ae(e,o,t,n={}){let r=re(o.content);if(r===void 0)return null;let a={level:e,content:r,duration:t,key:o.key};if(y()){let d=ne(a);return d?(n.onAccepted?.(),{dismiss:()=>k(d)}):null}let i=I(),s=i?.showToast;if(!s)return null;let l=null,c=null,p=false,g=false,m=()=>{p||g||c||(c=n.onFallback?.()??null);};return Promise.resolve().then(()=>s(a)).then(d=>{if(!d?.ok||!d.toastId){m();return}if(g=true,l=d.toastId,p){i?.dismissToast?.(l);return}n.onAccepted?.();}).catch(d=>{console.error("[lingee-ui] showToast failed:",d),m();}),{dismiss:()=>{if(!p){if(p=true,c){c(),c=null;return}l&&i?.dismissToast?.(l);}}}}function se(){if(y())return H()?(k(),true):false;let e=I();return !E()||typeof e?.dismissToast!="function"?false:(e.dismissToast().catch(o=>{console.error("[lingee-ui] dismissToast failed:",o);}),true)}var T={};function J(){let e=T.top??16;return jsxRuntime.jsx(sonner.Toaster,{position:"top-center",offset:e,gap:8,closeButton:false,toastOptions:{unstyled:true,className:"lg-toast-wrapper"},style:{"--width":"560px"}})}function Be(e){let o=e[0];return typeof o=="object"&&o!==null&&!ze__default.default.isValidElement(o)?o:{content:o,duration:e[1],onClose:e[2]}}function le(e,o,t,n=()=>o.onClose?.()){let r=t===0?1/0:t,a=false,i=()=>{a||(a=true,n());},s=sonner.toast.custom(l=>jsxRuntime.jsx($,{type:e,content:o.content,icon:o.icon,closable:o.closable,className:o.className,onClose:()=>sonner.toast.dismiss(l)}),{...o.key!==void 0&&{id:o.key},duration:r,onAutoClose:i,onDismiss:i});return ()=>{sonner.toast.dismiss(s),i();}}var L=new Set;function Ue(e,o){let t=o.duration!==void 0?o.duration<0?T.duration??3e3:o.duration:T.duration??3e3;if(ie(o,T)){let n=false,r,a=()=>{},i=()=>{n||(n=true,r!==void 0&&clearTimeout(r),L.delete(a),o.onClose?.());},s=ae(e,o,t,{onAccepted:()=>{t>0&&!n&&(r=setTimeout(i,t));},onFallback:()=>le(e,{...o,onClose:void 0},t,i)});if(s)return a=()=>{n||(s.dismiss(),i());},L.add(a),a}return le(e,o,t)}function S(e){return (...o)=>{let t=Be(o);return Ue(e,t)}}var ko={info:S("info"),success:S("success"),warning:S("warning"),error:S("error"),destroy:()=>{Array.from(L).forEach(e=>e()),L.clear(),se(),sonner.toast.dismiss();},config:e=>{T={...T,...e};}};exports.a=E;exports.b=J;exports.c=ko;exports.d=v;exports.e=ge;exports.f=me;exports.g=xe;exports.h=ve;exports.i=he;exports.j=W;exports.k=oo;
|
package/dist/chunk-CGHN44HV.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {j}from'./chunk-YNDT7LQA.mjs';import {a}from'./chunk-DN2VKVCV.mjs';import G,{useState,useRef,useCallback,useEffect}from'react';import {XCircleFill}from'lingee-icon';import {jsxs,jsx}from'react/jsx-runtime';var U=G.forwardRef(({className:l,style:o,size:a$1="md",shape:M="default",prefix:d,suffix:s,allowClear:T=false,error:C=false,disabled:r=false,collapsed:t=false,value:g,defaultValue:L,onChange:c,onFocus:_,onBlur:f,onPressEnter:v,onKeyDown:h,onClick:b,...H},S)=>{let m=j("Input"),[N,x]=useState(false),[D,y]=useState(L?.toString()??""),e=useRef(null),F=Y(S,e),u=g!==void 0,w=u?g?.toString()??"":D,O=useCallback(n=>{u||y(n.target.value),c?.(n);},[u,c]),P=useCallback(()=>{if(r)return;u||y("");let n=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value")?.set;if(e.current&&n){n.call(e.current,"");let A=new Event("input",{bubbles:true});e.current.dispatchEvent(A);}e.current?.focus();},[r,u]),V=useCallback(n=>{x(true),_?.(n);},[_]),j$1=useCallback(n=>{x(false),f?.(n);},[f]),B=useCallback(n=>{n.key==="Enter"&&v?.(n),h?.(n);},[v,h]),K=T&&w.length>0&&!r&&!t,W=!!s&&!(t&&d),k=useRef(t);useEffect(()=>{let n=k.current;k.current=t,n!==t&&(t?e.current===document.activeElement&&e.current?.blur():r||e.current?.focus());},[t,r]);let X=useCallback(n=>{t||e.current?.focus(),b?.(n);},[t,b]),$=a("lg-input",`lg-input--${a$1}`,M==="round"&&"lg-input--round",N&&!t&&"lg-input--focused",C&&"lg-input--error",r&&"lg-input--disabled",t&&"lg-input--collapsed",l),q=t?{...o,width:void 0,minWidth:void 0,maxWidth:void 0}:o;return jsxs("div",{className:$,style:q,onClick:X,role:t?"button":void 0,tabIndex:t&&!r?0:void 0,"aria-expanded":t?false:void 0,"aria-label":t?m.expand:void 0,children:[d&&jsx("span",{className:"lg-input__prefix",children:d}),jsx("input",{ref:F,className:"lg-input__inner",disabled:r,value:w,onChange:O,onFocus:V,onBlur:j$1,onKeyDown:B,tabIndex:t?-1:void 0,"aria-hidden":t||void 0,...H}),K&&jsx("span",{className:"lg-input__clear",onMouseDown:n=>n.preventDefault(),onClick:P,role:"button","aria-label":m.clear,children:jsx(XCircleFill,{})}),W&&jsx("span",{className:"lg-input__suffix",children:s})]})});U.displayName="Input";function Y(...l){return useCallback(o=>{l.forEach(a=>{a&&(typeof a=="function"?a(o):a.current=o);});},l)}export{U as a};
|
package/dist/chunk-ITHSP4P3.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkCB2FRG23_js=require('./chunk-CB2FRG23.js'),chunkDCDWEVW4_js=require('./chunk-DCDWEVW4.js'),G=require('react'),lingeeIcon=require('lingee-icon'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var G__default=/*#__PURE__*/_interopDefault(G);var U=G__default.default.forwardRef(({className:l,style:o,size:a="md",shape:M="default",prefix:d,suffix:s,allowClear:T=false,error:C=false,disabled:r=false,collapsed:t=false,value:g,defaultValue:L,onChange:c,onFocus:_,onBlur:f,onPressEnter:v,onKeyDown:h,onClick:b,...H},S)=>{let m=chunkCB2FRG23_js.j("Input"),[N,x]=G.useState(false),[D,y]=G.useState(L?.toString()??""),e=G.useRef(null),F=Y(S,e),u=g!==void 0,w=u?g?.toString()??"":D,O=G.useCallback(n=>{u||y(n.target.value),c?.(n);},[u,c]),P=G.useCallback(()=>{if(r)return;u||y("");let n=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value")?.set;if(e.current&&n){n.call(e.current,"");let A=new Event("input",{bubbles:true});e.current.dispatchEvent(A);}e.current?.focus();},[r,u]),V=G.useCallback(n=>{x(true),_?.(n);},[_]),j=G.useCallback(n=>{x(false),f?.(n);},[f]),B=G.useCallback(n=>{n.key==="Enter"&&v?.(n),h?.(n);},[v,h]),K=T&&w.length>0&&!r&&!t,W=!!s&&!(t&&d),k=G.useRef(t);G.useEffect(()=>{let n=k.current;k.current=t,n!==t&&(t?e.current===document.activeElement&&e.current?.blur():r||e.current?.focus());},[t,r]);let X=G.useCallback(n=>{t||e.current?.focus(),b?.(n);},[t,b]),$=chunkDCDWEVW4_js.a("lg-input",`lg-input--${a}`,M==="round"&&"lg-input--round",N&&!t&&"lg-input--focused",C&&"lg-input--error",r&&"lg-input--disabled",t&&"lg-input--collapsed",l),q=t?{...o,width:void 0,minWidth:void 0,maxWidth:void 0}:o;return jsxRuntime.jsxs("div",{className:$,style:q,onClick:X,role:t?"button":void 0,tabIndex:t&&!r?0:void 0,"aria-expanded":t?false:void 0,"aria-label":t?m.expand:void 0,children:[d&&jsxRuntime.jsx("span",{className:"lg-input__prefix",children:d}),jsxRuntime.jsx("input",{ref:F,className:"lg-input__inner",disabled:r,value:w,onChange:O,onFocus:V,onBlur:j,onKeyDown:B,tabIndex:t?-1:void 0,"aria-hidden":t||void 0,...H}),K&&jsxRuntime.jsx("span",{className:"lg-input__clear",onMouseDown:n=>n.preventDefault(),onClick:P,role:"button","aria-label":m.clear,children:jsxRuntime.jsx(lingeeIcon.XCircleFill,{})}),W&&jsxRuntime.jsx("span",{className:"lg-input__suffix",children:s})]})});U.displayName="Input";function Y(...l){return G.useCallback(o=>{l.forEach(a=>{a&&(typeof a=="function"?a(o):a.current=o);});},l)}exports.a=U;
|
package/dist/chunk-YNDT7LQA.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {c}from'./chunk-KXUUVDLA.mjs';import {a}from'./chunk-DN2VKVCV.mjs';import ze,{createContext,useContext,useMemo,useRef,useEffect}from'react';import {Toaster,toast}from'sonner';import {XCircleFill,ExclamationCircleFill1,CheckCircleFill,ExclamationCircleFill,XLg}from'lingee-icon';import {jsx,jsxs}from'react/jsx-runtime';var ce={locale:"zh-CN",Button:{},Breadcrumb:{more:"\u66F4\u591A",back:"\u8FD4\u56DE"},Select:{loading:"\u52A0\u8F7D\u4E2D",loadError:"\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",loadFailed:"\u52A0\u8F7D\u5931\u8D25",notFound:"\u641C\u7D22\u65E0\u7ED3\u679C",clear:"\u6E05\u7A7A"},Dropdown:{clear:"\u6E05\u9664",loading:"\u52A0\u8F7D\u4E2D",loadError:"\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",empty:"\u6682\u65E0\u6570\u636E"},Tabs:{scrollLeft:"\u5411\u5DE6\u6EDA\u52A8",scrollRight:"\u5411\u53F3\u6EDA\u52A8"},Carousel:{carousel:"\u8F6E\u64AD",prev:"\u4E0A\u4E00\u5F20",next:"\u4E0B\u4E00\u5F20",goToPage:"\u8DF3\u8F6C\u5230\u7B2C {page} \u5F20"},Form:{required:"{label}\u4E0D\u80FD\u4E3A\u7A7A",requiredNoLabel:"\u6B64\u9879\u4E0D\u80FD\u4E3A\u7A7A"},Tag:{close:"\u5173\u95ED"},Upload:{retry:"\u91CD\u65B0\u4E0A\u4F20",remove:"\u79FB\u9664\u6587\u4EF6",removeShort:"\u79FB\u9664",dragText:"\u62D6\u62FD\u6587\u4EF6\u5230\u6B64\u5904\uFF0C\u6216",clickUpload:"\u70B9\u51FB\u4E0A\u4F20"},ColorPicker:{placeholder:"\u8BF7\u9009\u62E9\u989C\u8272"},DatePicker:{placeholder:"\u5E74/\u6708/\u65E5",today:"\u4ECA\u5929",prevYear:"\u4E0A\u4E00\u5E74",nextYear:"\u4E0B\u4E00\u5E74",prevMonth:"\u4E0A\u4E00\u6708",nextMonth:"\u4E0B\u4E00\u6708",prevDecade:"\u4E0A\u4E00\u7EC4\u5E74\u4EFD",nextDecade:"\u4E0B\u4E00\u7EC4\u5E74\u4EFD",months:["1\u6708","2\u6708","3\u6708","4\u6708","5\u6708","6\u6708","7\u6708","8\u6708","9\u6708","10\u6708","11\u6708","12\u6708"],yearFormat:"{year}\u5E74",monthFormat:"{month}\u6708"},RangePicker:{startPlaceholder:"\u5E74/\u6708/\u65E5",endPlaceholder:"\u5E74/\u6708/\u65E5"},TimePicker:{now:"\u73B0\u5728",confirm:"\u786E\u5B9A",placeholder:"\u65F6:\u5206",placeholderFull:"\u65F6:\u5206:\u79D2"},Table:{loading:"\u52A0\u8F7D\u4E2D",empty:"\u6682\u65E0\u6570\u636E",loadError:"\u52A0\u8F7D\u5931\u8D25"},Tree:{empty:"\u6682\u65E0\u6570\u636E"},Pagination:{total:"\u5171 {total} \u6761",prevPage:"\u4E0A\u4E00\u9875",nextPage:"\u4E0B\u4E00\u9875",itemsPerPage:"{size}\u6761/\u9875",jumpTo:"\u8DF3\u81F3",page:"\u9875"},Dialog:{close:"\u5173\u95ED"},Drawer:{close:"\u5173\u95ED"},Input:{clear:"\u6E05\u7A7A",expand:"\u5C55\u5F00\u8F93\u5165\u6846"},Alert:{close:"\u5173\u95ED"},Toast:{close:"\u5173\u95ED\u6D88\u606F"},Spin:{loading:"\u52A0\u8F7D\u4E2D"},Empty:{retry:"\u91CD\u8BD5"},Sidebar:{expand:"\u5C55\u5F00",collapse:"\u6536\u8D77",loading:"\u52A0\u8F7D\u4E2D",empty:"\u6682\u65E0\u6570\u636E",loadError:"\u52A0\u8F7D\u5931\u8D25"}},v=ce;var _=new Map,F=0;function A(){return F+=1,{id:F}}function z(e,o,t){_.set(e.id,{site:o,depth:t});}function Y(e){_.delete(e.id);}function pe(){let e;for(let o of _.values())(!e||o.depth>=e.depth)&&(e=o);return e?.site}function E(){return pe()==="lingee"}var U={dialog:{}},h=createContext(U),D=new Map,B=0;function G(){return B+=1,{id:B}}function q(e,o,t){D.set(e.id,{config:o,depth:t});}function j(e){D.delete(e.id);}function ge(){let e;for(let o of D.values())(!e||o.depth>=e.depth)&&(e=o);return e?.config??U}function me(){return useContext(h)}var Te={locale:"en-US",Button:{},Breadcrumb:{more:"More",back:"Back"},Select:{loading:"Loading",loadError:"Failed to load, please retry",loadFailed:"Failed to load",notFound:"No results found",clear:"Clear"},Dropdown:{clear:"Clear",loading:"Loading",loadError:"Failed to load, please retry",empty:"No data"},Tabs:{scrollLeft:"Scroll left",scrollRight:"Scroll right"},Carousel:{carousel:"Carousel",prev:"Previous slide",next:"Next slide",goToPage:"Go to slide {page}"},Form:{required:"{label} is required",requiredNoLabel:"This field is required"},Tag:{close:"Close"},Upload:{retry:"Retry upload",remove:"Remove file",removeShort:"Remove",dragText:"Drag files here, or ",clickUpload:"click to upload"},ColorPicker:{placeholder:"Select a color"},DatePicker:{placeholder:"YYYY/MM/DD",today:"Today",prevYear:"Previous year",nextYear:"Next year",prevMonth:"Previous month",nextMonth:"Next month",prevDecade:"Previous decade",nextDecade:"Next decade",months:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],yearFormat:"{year}",monthFormat:"{month}"},RangePicker:{startPlaceholder:"Start date",endPlaceholder:"End date"},TimePicker:{now:"Now",confirm:"OK",placeholder:"HH:mm",placeholderFull:"HH:mm:ss"},Table:{loading:"Loading",empty:"No data",loadError:"Failed to load"},Tree:{empty:"No data"},Pagination:{total:"{total} items",prevPage:"Previous page",nextPage:"Next page",itemsPerPage:"{size} / page",jumpTo:"Go to",page:""},Dialog:{close:"Close"},Drawer:{close:"Close"},Input:{clear:"Clear",expand:"Expand input"},Alert:{close:"Close"},Toast:{close:"Close message"},Spin:{loading:"Loading"},Empty:{retry:"Retry"},Sidebar:{expand:"Expand",collapse:"Collapse",loading:"Loading",empty:"No data",loadError:"Failed to load"}},xe=Te;var V=createContext(v),Z=createContext(void 0),X=createContext(-1);function ve({locale:e=v,site:o,dialog:t,children:n}){let r=useContext(X)+1,a=useContext(h),i=t?.zIndex,s=a.dialog.zIndex,l=useMemo(()=>({dialog:{zIndex:i??s}}),[i,s]),c$1=useRef();c$1.current||(c$1.current=A());let p=c$1.current,g=useRef();g.current||(g.current=G());let m=g.current;z(p,o,r),q(m,l,r),useEffect(()=>()=>{Y(p),j(m);},[m,p]);let d=jsx(X.Provider,{value:r,children:jsx(h.Provider,{value:l,children:jsx(Z.Provider,{value:o,children:jsxs(V.Provider,{value:e,children:[n,r===0&&jsx(J,{})]})})})});return r===0?jsx(c,{children:d}):d}ve.displayName="LingeeProvider";function he(){return useContext(V)}function W(e){return he()[e]}function oo(){return useContext(Z)}var _e={info:jsx(ExclamationCircleFill,{size:20}),success:jsx(CheckCircleFill,{size:20}),warning:jsx(ExclamationCircleFill1,{size:20}),error:jsx(XCircleFill,{size:20})};function $({type:e,content:o,icon:t,closable:n,className:r,onClose:a$1}){let i=W("Toast"),s=()=>{if(t===null)return null;let l=t!==void 0?t:_e[e];return jsx("span",{className:"lg-toast__icon",children:l})};return jsxs("div",{className:a("lg-toast",`lg-toast--${e}`,r),children:[s(),jsx("span",{className:"lg-toast__content",children:o}),n&&jsx("button",{className:"lg-toast__close",onClick:a$1,"aria-label":i.close,type:"button",children:jsx(XLg,{size:16})})]})}var ee="lingee-web-bridge",oe="1.0.0",De="host",Ne="iframe",Re="lingee-web-bridge:host-toast-show",He="lingee-web-bridge:host-toast-dismiss",Ie="lingee-web-bridge:host-toast-probe",Me="lingee-web-bridge:host-toast-ready";function te(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();let e=Date.now();return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,o=>{let t=(e+Math.random()*16)%16|0;return e=Math.floor(e/16),(o==="x"?t:t&3|8).toString(16)})}function Oe(e,o){return {_protocol:ee,_version:oe,_source:e,_nonce:te(),_traceId:"",payload:o}}function Fe(e,o){if(typeof e!="object"||e===null)return false;let t=e;return t._protocol===ee&&t._version===oe&&t._source===o&&typeof t._nonce=="string"&&"payload"in t}function y(){return typeof window<"u"&&window.parent!==window}var C=false,f=new Map,Q=false;function Ae(e){if(!Fe(e,De))return false;let o=e.payload;return !!o&&typeof o=="object"&&o.type===Me}function R(e){window.parent.postMessage(Oe(Ne,e),"*");}function w(){Q||!y()||(Q=true,window.addEventListener("message",e=>{e.source===window.parent&&Ae(e.data)&&(C=true);}),window.addEventListener("pagehide",()=>{!C||f.size===0||k();}),R({type:Ie}));}function H(){return w(),C}function ne(e){if(w(),!C||!e.content)return null;let o=te();R({type:Re,toastId:o,content:e.content.slice(0,500),level:e.level,duration:e.duration,key:e.key});let t=e.duration??3e3,n=t>0?window.setTimeout(()=>f.delete(o),t+500):void 0;return f.set(o,n),o}function k(e){if(w(),!!C){if(e){let o=f.get(e);o!==void 0&&window.clearTimeout(o),f.delete(e);}else f.forEach(o=>{o!==void 0&&window.clearTimeout(o);}),f.clear();R({type:He,toastId:e});}}w();function I(){if(!(typeof window>"u"))return window.lingeeBridge}function re(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e)}function ie(e,o={}){return !(!(y()?H():E()&&typeof I()?.showToast=="function")||re(e.content)===void 0||e.icon!==void 0||e.className!==void 0||e.closable||o.getContainer!==void 0||o.top!==void 0||o.maxCount!==void 0)}function ae(e,o,t,n={}){let r=re(o.content);if(r===void 0)return null;let a={level:e,content:r,duration:t,key:o.key};if(y()){let d=ne(a);return d?(n.onAccepted?.(),{dismiss:()=>k(d)}):null}let i=I(),s=i?.showToast;if(!s)return null;let l=null,c=null,p=false,g=false,m=()=>{p||g||c||(c=n.onFallback?.()??null);};return Promise.resolve().then(()=>s(a)).then(d=>{if(!d?.ok||!d.toastId){m();return}if(g=true,l=d.toastId,p){i?.dismissToast?.(l);return}n.onAccepted?.();}).catch(d=>{console.error("[lingee-ui] showToast failed:",d),m();}),{dismiss:()=>{if(!p){if(p=true,c){c(),c=null;return}l&&i?.dismissToast?.(l);}}}}function se(){if(y())return H()?(k(),true):false;let e=I();return !E()||typeof e?.dismissToast!="function"?false:(e.dismissToast().catch(o=>{console.error("[lingee-ui] dismissToast failed:",o);}),true)}var T={};function J(){let e=T.top??16;return jsx(Toaster,{position:"top-center",offset:e,gap:8,closeButton:false,toastOptions:{unstyled:true,className:"lg-toast-wrapper"},style:{"--width":"560px"}})}function Be(e){let o=e[0];return typeof o=="object"&&o!==null&&!ze.isValidElement(o)?o:{content:o,duration:e[1],onClose:e[2]}}function le(e,o,t,n=()=>o.onClose?.()){let r=t===0?1/0:t,a=false,i=()=>{a||(a=true,n());},s=toast.custom(l=>jsx($,{type:e,content:o.content,icon:o.icon,closable:o.closable,className:o.className,onClose:()=>toast.dismiss(l)}),{...o.key!==void 0&&{id:o.key},duration:r,onAutoClose:i,onDismiss:i});return ()=>{toast.dismiss(s),i();}}var L=new Set;function Ue(e,o){let t=o.duration!==void 0?o.duration<0?T.duration??3e3:o.duration:T.duration??3e3;if(ie(o,T)){let n=false,r,a=()=>{},i=()=>{n||(n=true,r!==void 0&&clearTimeout(r),L.delete(a),o.onClose?.());},s=ae(e,o,t,{onAccepted:()=>{t>0&&!n&&(r=setTimeout(i,t));},onFallback:()=>le(e,{...o,onClose:void 0},t,i)});if(s)return a=()=>{n||(s.dismiss(),i());},L.add(a),a}return le(e,o,t)}function S(e){return (...o)=>{let t=Be(o);return Ue(e,t)}}var ko={info:S("info"),success:S("success"),warning:S("warning"),error:S("error"),destroy:()=>{Array.from(L).forEach(e=>e()),L.clear(),se(),toast.dismiss();},config:e=>{T={...T,...e};}};export{E as a,J as b,ko as c,v as d,ge as e,me as f,xe as g,ve as h,he as i,W as j,oo as k};
|