@lobehub/ui 6.9.0 → 6.10.0

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.
Files changed (47) hide show
  1. package/es/Accordion/style.d.mts +1 -1
  2. package/es/Button/style.mjs +14 -14
  3. package/es/ColorPicker/style.mjs +2 -2
  4. package/es/ColorSwatches/style.mjs +2 -2
  5. package/es/ConfigProvider/cdnAssets.mjs +28 -1
  6. package/es/ConfigProvider/cdnAssets.mjs.map +1 -1
  7. package/es/ConfigProvider/index.mjs +2 -23
  8. package/es/ConfigProvider/index.mjs.map +1 -1
  9. package/es/DraggablePanel/style.mjs +1 -1
  10. package/es/DraggableSideNav/style.mjs +1 -1
  11. package/es/FloatingPanel/style.mjs +1 -1
  12. package/es/Image/style.mjs +1 -1
  13. package/es/Input/style.mjs +3 -3
  14. package/es/Markdown/plugins/rehypeCustomFootnotes.mjs +1 -1
  15. package/es/Markdown/plugins/rehypeKatexDir.mjs +1 -1
  16. package/es/Markdown/plugins/remarkBr.mjs +1 -1
  17. package/es/Markdown/plugins/remarkCjkAutolink.mjs +1 -1
  18. package/es/Markdown/plugins/remarkColor.mjs +1 -1
  19. package/es/Markdown/plugins/remarkCustomFootnotes.mjs +1 -1
  20. package/es/Markdown/plugins/remarkGfmPlus.mjs +1 -1
  21. package/es/Markdown/plugins/remarkVideo.mjs +1 -1
  22. package/es/Select/style.mjs +1 -1
  23. package/es/Slider/style.mjs +1 -1
  24. package/es/Tabs/style.d.mts +1 -1
  25. package/es/Text/style.d.mts +1 -1
  26. package/es/awesome/GradientButton/style.mjs +1 -1
  27. package/es/index.d.mts +2 -1
  28. package/es/index.mjs +2 -1
  29. package/es/node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs +289 -0
  30. package/es/node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.mjs.map +1 -0
  31. package/es/styles/createGlobalStyle.mjs +19 -5
  32. package/es/styles/createGlobalStyle.mjs.map +1 -1
  33. package/es/styles/css.mjs +18 -1
  34. package/es/styles/css.mjs.map +1 -1
  35. package/es/styles/index.d.mts +2 -1
  36. package/es/styles/index.mjs +2 -1
  37. package/es/styles/theme/themeCss.mjs +6 -0
  38. package/es/styles/theme/themeCss.mjs.map +1 -1
  39. package/es/styles/theme/token/base.mjs +3 -54
  40. package/es/styles/theme/token/base.mjs.map +1 -1
  41. package/es/styles/theme/token/font.d.mts +7 -0
  42. package/es/styles/theme/token/font.mjs +187 -0
  43. package/es/styles/theme/token/font.mjs.map +1 -0
  44. package/es/theme.css +52 -2
  45. package/package.json +1 -1
  46. package/es/node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs +0 -288
  47. package/es/node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.mjs.map +0 -1
@@ -0,0 +1,289 @@
1
+ import { SKIP as SKIP$1, visitParents } from "unist-util-visit-parents";
2
+ // node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.js
3
+ /**
4
+ * @import {Node as UnistNode, Parent as UnistParent} from 'unist'
5
+ * @import {
6
+ * InclusiveDescendant,
7
+ * Matches,
8
+ * Visitors as ParentsVisitors,
9
+ * VisitorResult,
10
+ * VisitorResultExit
11
+ * } from 'unist-util-visit-parents'
12
+ */
13
+ /**
14
+ * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test
15
+ * Test from `unist-util-is`.
16
+ *
17
+ * Note: we have remove and add `undefined`, because otherwise when generating
18
+ * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,
19
+ * which doesn’t work when publishing on npm.
20
+ */
21
+ /**
22
+ * @typedef {(
23
+ * Node extends UnistParent
24
+ * ? Node extends {children: Array<infer Children>}
25
+ * ? Child extends Children ? Node : never
26
+ * : never
27
+ * : never
28
+ * )} InternalParent
29
+ * Collect nodes that can be parents of `Child`.
30
+ * @template {UnistNode} Node
31
+ * All node types in a tree.
32
+ * @template {UnistNode} Child
33
+ * Node to search for.
34
+ */
35
+ /**
36
+ * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent
37
+ * Collect nodes in `Tree` that can be parents of `Child`.
38
+ * @template {UnistNode} Tree
39
+ * All node types in a tree.
40
+ * @template {UnistNode} Child
41
+ * Node to search for.
42
+ */
43
+ /**
44
+ * @callback Visitor
45
+ * Handle a node (matching `test`, if given) before its children.
46
+ *
47
+ * Like `Visitor` in `unist-util-visit-parents`,
48
+ * but with `index` and `parent` instead of `parents`.
49
+ * @param {Visited} node
50
+ * Found node.
51
+ * @param {Visited extends UnistNode ? number | undefined : never} index
52
+ * Index of `node` in `parent`,
53
+ * or `undefined` for the tree itself.
54
+ * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent
55
+ * Parent of `node`,
56
+ * or `undefined` for the tree itself.
57
+ * @returns {VisitorResult}
58
+ * What to do next.
59
+ * @template {UnistNode} [Visited=UnistNode]
60
+ * Visited node type.
61
+ * @template {UnistParent} [Ancestor=UnistParent]
62
+ * Ancestor type.
63
+ */
64
+ /**
65
+ * @callback VisitorExit
66
+ * Handle a node (matching `test`, if given) after its children.
67
+ *
68
+ * Like `VisitorExit` in `unist-util-visit-parents`,
69
+ * but with `index` and `parent` instead of `parents`.
70
+ * @param {Visited} node
71
+ * Found node.
72
+ * @param {Visited extends UnistNode ? number | undefined : never} index
73
+ * Index of `node` in `parent`,
74
+ * or `undefined` for the tree itself.
75
+ * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent
76
+ * Parent of `node`,
77
+ * or `undefined` for the tree itself.
78
+ * @returns {VisitorResultExit}
79
+ * What to do next.
80
+ * @template {UnistNode} [Visited=UnistNode]
81
+ * Visited node type.
82
+ * @template {UnistParent} [Ancestor=UnistParent]
83
+ * Ancestor type.
84
+ */
85
+ /**
86
+ * @template {UnistNode} [Visited=UnistNode]
87
+ * Visited node type.
88
+ * @template {UnistParent} [Ancestor=UnistParent]
89
+ * Ancestor type.
90
+ * @typedef Visitors
91
+ * Handle nodes when entering and exiting them.
92
+ *
93
+ * Like `Visitors` in `unist-util-visit-parents`.
94
+ * @property {Visitor<Visited, Ancestor> | null | undefined} [enter]
95
+ * Handle a node before its children (optional).
96
+ * @property {VisitorExit<Visited, Ancestor>} exit
97
+ * Handle a node after its children.
98
+ */
99
+ /**
100
+ * @typedef {Visitor<Visited, Parent<Ancestor, Visited>>} BuildVisitorFromMatch
101
+ * Build a typed `Visitor` function from a node and all possible parents.
102
+ *
103
+ * It will infer which values are passed as `node` and which as `parent`.
104
+ * @template {UnistNode} Visited
105
+ * Node type.
106
+ * @template {UnistParent} Ancestor
107
+ * Parent type.
108
+ */
109
+ /**
110
+ * @typedef {(
111
+ * BuildVisitorFromMatch<
112
+ * Matches<Descendant, Check>,
113
+ * Extract<Descendant, UnistParent>
114
+ * >
115
+ * )} BuildVisitorFromDescendants
116
+ * Build a typed `Visitor` function from a list of descendants and a test.
117
+ *
118
+ * It will infer which values are passed as `node` and which as `parent`.
119
+ * @template {UnistNode} Descendant
120
+ * Node type.
121
+ * @template {Test} Check
122
+ * Test type.
123
+ */
124
+ /**
125
+ * @typedef {(
126
+ * BuildVisitorFromDescendants<
127
+ * InclusiveDescendant<Tree>,
128
+ * Check
129
+ * >
130
+ * )} BuildVisitor
131
+ * Build a typed `Visitor` function from a tree and a test.
132
+ *
133
+ * It will infer which values are passed as `node` and which as `parent`.
134
+ * @template {UnistNode} [Tree=UnistNode]
135
+ * Node type.
136
+ * @template {Test} [Check=Test]
137
+ * Test type.
138
+ */
139
+ /**
140
+ * @typedef {(
141
+ * Visitors<
142
+ * Matches<InclusiveDescendant<Tree>, Check>,
143
+ * Parent<
144
+ * Extract<InclusiveDescendant<Tree>, UnistParent>,
145
+ * Matches<InclusiveDescendant<Tree>, Check>
146
+ * >
147
+ * >
148
+ * )} BuildVisitors
149
+ * Build typed `Visitors` from a tree and a test.
150
+ *
151
+ * It will infer which values are passed as `node` and which as `parent`.
152
+ * @template {UnistNode} [Tree=UnistNode]
153
+ * Node type.
154
+ * @template {Test} [Check=Test]
155
+ * Test type.
156
+ */
157
+ /**
158
+ * Visit nodes.
159
+ *
160
+ * This algorithm performs *depth-first* *tree traversal* in *preorder*
161
+ * (**NLR**) or if `reverse` is given,
162
+ * in *reverse preorder* (**NRL**).
163
+ * An `exit` visitor is called in *postorder* (**LRN**)
164
+ * or if `reverse` is given, in *reverse postorder* (**RLN**).
165
+ *
166
+ * You can choose which nodes are visited by passing a `test`.
167
+ * For complex tests, you should test yourself in a visitor, as it will be
168
+ * faster and will have improved type information.
169
+ *
170
+ * Walking the tree is an intensive task.
171
+ * Make use of the return values of the visitor when possible.
172
+ * Instead of walking a tree multiple times, walk it once, use `unist-util-is`
173
+ * to check if a node matches, and then perform different operations.
174
+ *
175
+ * You can change the tree.
176
+ * Changes inside a node made when entering it are walked,
177
+ * changes made when exiting it are not.
178
+ * See `Visitor` and `VisitorExit` for more info.
179
+ *
180
+ * @overload
181
+ * @param {Tree} tree
182
+ * Tree to traverse.
183
+ * @param {Check} check
184
+ * `unist-util-is`-compatible test.
185
+ * @param {BuildVisitor<Tree, Check> | BuildVisitors<Tree, Check>} visitors
186
+ * Handle each node when entering it,
187
+ * or `{enter, exit}` to also handle it when exiting it.
188
+ * @param {boolean | null | undefined} [reverse]
189
+ * Walk children from last to first;
190
+ * for `enter`, reverse preorder (NRL) instead of preorder (NLR);
191
+ * for `exit`, reverse postorder (RLN) instead of postorder (LRN).
192
+ * @returns {undefined}
193
+ * Nothing.
194
+ *
195
+ * @overload
196
+ * @param {Tree} tree
197
+ * Tree to traverse.
198
+ * @param {BuildVisitor<Tree> | BuildVisitors<Tree>} visitors
199
+ * Handle each node when entering it,
200
+ * or `{enter, exit}` to also handle it when exiting it.
201
+ * @param {boolean | null | undefined} [reverse]
202
+ * Walk children from last to first;
203
+ * for `enter`, reverse preorder (NRL) instead of preorder (NLR);
204
+ * for `exit`, reverse postorder (RLN) instead of postorder (LRN).
205
+ * @returns {undefined}
206
+ * Nothing.
207
+ *
208
+ * @param {UnistNode} tree
209
+ * Tree to traverse.
210
+ * @param {Visitor | Visitors | Test} testOrEnterOrVisitors
211
+ * `unist-util-is`-compatible test, `enter`, or `visitors`.
212
+ * @param {Visitor | Visitors | boolean | null | undefined} [enterOrVisitorsOrReverse]
213
+ * `enter`, `visitors`, or `reverse` after a test.
214
+ * @param {boolean | null | undefined} [maybeReverse]
215
+ * Walk children from last to first;
216
+ * for `enter`, reverse preorder (NRL) instead of preorder (NLR);
217
+ * for `exit`, reverse postorder (RLN) instead of postorder (LRN).
218
+ * @returns {undefined}
219
+ * Nothing.
220
+ *
221
+ * @template {UnistNode} Tree
222
+ * Node type.
223
+ * @template {Test} Check
224
+ * `unist-util-is`-compatible test.
225
+ */
226
+ function visit(tree, testOrEnterOrVisitors, enterOrVisitorsOrReverse, maybeReverse) {
227
+ /** @type {Test} */
228
+ let check;
229
+ /** @type {Visitor | Visitors} */
230
+ let visitors;
231
+ /** @type {boolean | null | undefined} */
232
+ let reverse;
233
+ if (typeof enterOrVisitorsOrReverse === "function" || enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === "object") {
234
+ check = testOrEnterOrVisitors;
235
+ visitors = enterOrVisitorsOrReverse;
236
+ reverse = maybeReverse;
237
+ } else {
238
+ visitors = testOrEnterOrVisitors;
239
+ reverse = enterOrVisitorsOrReverse;
240
+ }
241
+ if (typeof visitors === "function") visitParents(tree, check, wrap(visitors), reverse);
242
+ else visitParents(tree, check, wrapVisitors(visitors), reverse);
243
+ }
244
+ /**
245
+ * Turn `visit` visitors into `visitParents` visitors.
246
+ *
247
+ * @param {Visitors} visitors
248
+ * Visitors for `visit`.
249
+ * @returns {ParentsVisitors}
250
+ * Visitors for `visitParents`.
251
+ */
252
+ function wrapVisitors(visitors) {
253
+ if (!visitors || typeof visitors !== "object") return visitors;
254
+ return {
255
+ enter: typeof visitors.enter === "function" ? wrap(visitors.enter) : visitors.enter,
256
+ exit: typeof visitors.exit === "function" ? wrap(visitors.exit) : visitors.exit
257
+ };
258
+ }
259
+ /**
260
+ * Turn a `visit` visitor into a `visitParents` one.
261
+ *
262
+ * @template {VisitorResult} Result
263
+ * Result type.
264
+ * @param {(node: UnistNode, index: number | undefined, parent: UnistParent | undefined) => Result} visitor
265
+ * Visitor for `visit`.
266
+ * @returns {(node: UnistNode, parents: Array<UnistParent>, index: number | undefined) => Result}
267
+ * Visitor for `visitParents`.
268
+ */
269
+ function wrap(visitor) {
270
+ return overload;
271
+ /**
272
+ * Call `visitor` with `index` and `parent` instead of `parents`.
273
+ *
274
+ * @param {UnistNode} node
275
+ * Visited node.
276
+ * @param {Array<UnistParent>} parents
277
+ * Ancestors of `node`.
278
+ * @param {number | undefined} index
279
+ * Index of `node` in its parent.
280
+ * @returns {Result}
281
+ * What to do next.
282
+ */
283
+ function overload(node, parents, index) {
284
+ return visitor(node, index, parents[parents.length - 1]);
285
+ }
286
+ }
287
+ export { SKIP$1 as SKIP, visit };
288
+
289
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.js"],"sourcesContent":["/**\n * @import {Node as UnistNode, Parent as UnistParent} from 'unist'\n * @import {\n * InclusiveDescendant,\n * Matches,\n * Visitors as ParentsVisitors,\n * VisitorResult,\n * VisitorResultExit\n * } from 'unist-util-visit-parents'\n */\n\n/**\n * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test\n * Test from `unist-util-is`.\n *\n * Note: we have remove and add `undefined`, because otherwise when generating\n * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,\n * which doesn’t work when publishing on npm.\n */\n\n/**\n * @typedef {(\n * Node extends UnistParent\n * ? Node extends {children: Array<infer Children>}\n * ? Child extends Children ? Node : never\n * : never\n * : never\n * )} InternalParent\n * Collect nodes that can be parents of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent\n * Collect nodes in `Tree` that can be parents of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @callback Visitor\n * Handle a node (matching `test`, if given) before its children.\n *\n * Like `Visitor` in `unist-util-visit-parents`,\n * but with `index` and `parent` instead of `parents`.\n * @param {Visited} node\n * Found node.\n * @param {Visited extends UnistNode ? number | undefined : never} index\n * Index of `node` in `parent`,\n * or `undefined` for the tree itself.\n * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent\n * Parent of `node`,\n * or `undefined` for the tree itself.\n * @returns {VisitorResult}\n * What to do next.\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [Ancestor=UnistParent]\n * Ancestor type.\n */\n\n/**\n * @callback VisitorExit\n * Handle a node (matching `test`, if given) after its children.\n *\n * Like `VisitorExit` in `unist-util-visit-parents`,\n * but with `index` and `parent` instead of `parents`.\n * @param {Visited} node\n * Found node.\n * @param {Visited extends UnistNode ? number | undefined : never} index\n * Index of `node` in `parent`,\n * or `undefined` for the tree itself.\n * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent\n * Parent of `node`,\n * or `undefined` for the tree itself.\n * @returns {VisitorResultExit}\n * What to do next.\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [Ancestor=UnistParent]\n * Ancestor type.\n */\n\n/**\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [Ancestor=UnistParent]\n * Ancestor type.\n * @typedef Visitors\n * Handle nodes when entering and exiting them.\n *\n * Like `Visitors` in `unist-util-visit-parents`.\n * @property {Visitor<Visited, Ancestor> | null | undefined} [enter]\n * Handle a node before its children (optional).\n * @property {VisitorExit<Visited, Ancestor>} exit\n * Handle a node after its children.\n */\n\n/**\n * @typedef {Visitor<Visited, Parent<Ancestor, Visited>>} BuildVisitorFromMatch\n * Build a typed `Visitor` function from a node and all possible parents.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} Visited\n * Node type.\n * @template {UnistParent} Ancestor\n * Parent type.\n */\n\n/**\n * @typedef {(\n * BuildVisitorFromMatch<\n * Matches<Descendant, Check>,\n * Extract<Descendant, UnistParent>\n * >\n * )} BuildVisitorFromDescendants\n * Build a typed `Visitor` function from a list of descendants and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} Descendant\n * Node type.\n * @template {Test} Check\n * Test type.\n */\n\n/**\n * @typedef {(\n * BuildVisitorFromDescendants<\n * InclusiveDescendant<Tree>,\n * Check\n * >\n * )} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} [Tree=UnistNode]\n * Node type.\n * @template {Test} [Check=Test]\n * Test type.\n */\n\n/**\n * @typedef {(\n * Visitors<\n * Matches<InclusiveDescendant<Tree>, Check>,\n * Parent<\n * Extract<InclusiveDescendant<Tree>, UnistParent>,\n * Matches<InclusiveDescendant<Tree>, Check>\n * >\n * >\n * )} BuildVisitors\n * Build typed `Visitors` from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} [Tree=UnistNode]\n * Node type.\n * @template {Test} [Check=Test]\n * Test type.\n */\n\nimport {visitParents} from 'unist-util-visit-parents'\n\nexport {CONTINUE, EXIT, SKIP} from 'unist-util-visit-parents'\n\n/**\n * Visit nodes.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given,\n * in *reverse preorder* (**NRL**).\n * An `exit` visitor is called in *postorder* (**LRN**)\n * or if `reverse` is given, in *reverse postorder* (**RLN**).\n *\n * You can choose which nodes are visited by passing a `test`.\n * For complex tests, you should test yourself in a visitor, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * Changes inside a node made when entering it are walked,\n * changes made when exiting it are not.\n * See `Visitor` and `VisitorExit` for more info.\n *\n * @overload\n * @param {Tree} tree\n * Tree to traverse.\n * @param {Check} check\n * `unist-util-is`-compatible test.\n * @param {BuildVisitor<Tree, Check> | BuildVisitors<Tree, Check>} visitors\n * Handle each node when entering it,\n * or `{enter, exit}` to also handle it when exiting it.\n * @param {boolean | null | undefined} [reverse]\n * Walk children from last to first;\n * for `enter`, reverse preorder (NRL) instead of preorder (NLR);\n * for `exit`, reverse postorder (RLN) instead of postorder (LRN).\n * @returns {undefined}\n * Nothing.\n *\n * @overload\n * @param {Tree} tree\n * Tree to traverse.\n * @param {BuildVisitor<Tree> | BuildVisitors<Tree>} visitors\n * Handle each node when entering it,\n * or `{enter, exit}` to also handle it when exiting it.\n * @param {boolean | null | undefined} [reverse]\n * Walk children from last to first;\n * for `enter`, reverse preorder (NRL) instead of preorder (NLR);\n * for `exit`, reverse postorder (RLN) instead of postorder (LRN).\n * @returns {undefined}\n * Nothing.\n *\n * @param {UnistNode} tree\n * Tree to traverse.\n * @param {Visitor | Visitors | Test} testOrEnterOrVisitors\n * `unist-util-is`-compatible test, `enter`, or `visitors`.\n * @param {Visitor | Visitors | boolean | null | undefined} [enterOrVisitorsOrReverse]\n * `enter`, `visitors`, or `reverse` after a test.\n * @param {boolean | null | undefined} [maybeReverse]\n * Walk children from last to first;\n * for `enter`, reverse preorder (NRL) instead of preorder (NLR);\n * for `exit`, reverse postorder (RLN) instead of postorder (LRN).\n * @returns {undefined}\n * Nothing.\n *\n * @template {UnistNode} Tree\n * Node type.\n * @template {Test} Check\n * `unist-util-is`-compatible test.\n */\nexport function visit(\n tree,\n testOrEnterOrVisitors,\n enterOrVisitorsOrReverse,\n maybeReverse\n) {\n /** @type {Test} */\n let check\n /** @type {Visitor | Visitors} */\n let visitors\n /** @type {boolean | null | undefined} */\n let reverse\n\n // Third parameter is an enter visitor or a visitors object, so expect a `test` too.\n if (\n typeof enterOrVisitorsOrReverse === 'function' ||\n (enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === 'object')\n ) {\n check = /** @type {Test} */ (testOrEnterOrVisitors)\n visitors = enterOrVisitorsOrReverse\n reverse = maybeReverse\n }\n // Assume no test.\n else {\n visitors = /** @type {Visitor | Visitors} */ (testOrEnterOrVisitors)\n reverse = enterOrVisitorsOrReverse\n }\n\n if (typeof visitors === 'function') {\n visitParents(tree, check, wrap(visitors), reverse)\n } else {\n visitParents(tree, check, wrapVisitors(visitors), reverse)\n }\n}\n\n/**\n * Turn `visit` visitors into `visitParents` visitors.\n *\n * @param {Visitors} visitors\n * Visitors for `visit`.\n * @returns {ParentsVisitors}\n * Visitors for `visitParents`.\n */\nfunction wrapVisitors(visitors) {\n // Pass anything else straight to `visitParents` to get its errors.\n if (!visitors || typeof visitors !== 'object') return visitors\n\n return {\n enter:\n typeof visitors.enter === 'function'\n ? wrap(visitors.enter)\n : visitors.enter,\n exit:\n typeof visitors.exit === 'function' ? wrap(visitors.exit) : visitors.exit\n }\n}\n\n/**\n * Turn a `visit` visitor into a `visitParents` one.\n *\n * @template {VisitorResult} Result\n * Result type.\n * @param {(node: UnistNode, index: number | undefined, parent: UnistParent | undefined) => Result} visitor\n * Visitor for `visit`.\n * @returns {(node: UnistNode, parents: Array<UnistParent>, index: number | undefined) => Result}\n * Visitor for `visitParents`.\n */\nfunction wrap(visitor) {\n return overload\n\n /**\n * Call `visitor` with `index` and `parent` instead of `parents`.\n *\n * @param {UnistNode} node\n * Visited node.\n * @param {Array<UnistParent>} parents\n * Ancestors of `node`.\n * @param {number | undefined} index\n * Index of `node` in its parent.\n * @returns {Result}\n * What to do next.\n */\n function overload(node, parents, index) {\n return visitor(node, index, parents[parents.length - 1])\n }\n}\n"],"ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8OA,SAAgB,MACd,MACA,uBACA,0BACA,cACA;;CAEA,IAAI;;CAEJ,IAAI;;CAEJ,IAAI;CAGJ,IACE,OAAO,6BAA6B,cACnC,4BAA4B,OAAO,6BAA6B,UACjE;EACA,QAA6B;EAC7B,WAAW;EACX,UAAU;CACZ,OAEK;EACH,WAA8C;EAC9C,UAAU;CACZ;CAEA,IAAI,OAAO,aAAa,YACtB,aAAa,MAAM,OAAO,KAAK,QAAQ,GAAG,OAAO;MAEjD,aAAa,MAAM,OAAO,aAAa,QAAQ,GAAG,OAAO;AAE7D;;;;;;;;;AAUA,SAAS,aAAa,UAAU;CAE9B,IAAI,CAAC,YAAY,OAAO,aAAa,UAAU,OAAO;CAEtD,OAAO;EACL,OACE,OAAO,SAAS,UAAU,aACtB,KAAK,SAAS,KAAK,IACnB,SAAS;EACf,MACE,OAAO,SAAS,SAAS,aAAa,KAAK,SAAS,IAAI,IAAI,SAAS;CACzE;AACF;;;;;;;;;;;AAYA,SAAS,KAAK,SAAS;CACrB,OAAO;;;;;;;;;;;;;CAcP,SAAS,SAAS,MAAM,SAAS,OAAO;EACtC,OAAO,QAAQ,MAAM,OAAO,QAAQ,QAAQ,SAAS,EAAE;CACzD;AACF"}
@@ -1,16 +1,30 @@
1
1
  "use client";
2
- import { css, injectGlobal } from "./css.mjs";
2
+ import { createGlobalSheet, css, injectGlobal } from "./css.mjs";
3
3
  import { useTheme } from "./theme/scope.mjs";
4
- import { useMemo } from "react";
4
+ import { useInsertionEffect, useMemo, useRef } from "react";
5
5
  // src/styles/createGlobalStyle.ts
6
+ const isServer = typeof document === "undefined";
6
7
  const createGlobalStyle = (template, ...args) => {
7
8
  const GlobalStyle = () => {
8
9
  const theme = useTheme();
9
- useMemo(() => {
10
+ const sheetRef = useRef(null);
11
+ const styles = useMemo(() => {
10
12
  const props = { theme };
11
- const styles = typeof template === "function" ? template(props) : css(template, ...args.map((arg) => typeof arg === "function" ? arg(props) : arg));
12
- injectGlobal(styles);
13
+ const resolved = typeof template === "function" ? template(props) : css(template, ...args.map((arg) => typeof arg === "function" ? arg(props) : arg));
14
+ if (isServer) injectGlobal(resolved);
15
+ return resolved;
13
16
  }, [theme]);
17
+ useInsertionEffect(() => {
18
+ const sheet = createGlobalSheet();
19
+ sheetRef.current = sheet;
20
+ return () => {
21
+ sheet.remove();
22
+ sheetRef.current = null;
23
+ };
24
+ }, []);
25
+ useInsertionEffect(() => {
26
+ sheetRef.current?.update(styles);
27
+ }, [styles]);
14
28
  return null;
15
29
  };
16
30
  return GlobalStyle;
@@ -1 +1 @@
1
- {"version":3,"file":"createGlobalStyle.mjs","names":[],"sources":["../../src/styles/createGlobalStyle.ts"],"sourcesContent":["'use client';\n\nimport type { CSSInterpolation } from '@emotion/serialize';\nimport { useMemo } from 'react';\n\nimport { css, injectGlobal } from './css';\nimport { type LobeTheme, useTheme } from './theme/scope';\n\ntype GlobalStyleProps = { theme: LobeTheme };\ntype GlobalInterpolation = CSSInterpolation | ((props: GlobalStyleProps) => CSSInterpolation);\n\nexport const createGlobalStyle = (\n template: TemplateStringsArray | ((props: GlobalStyleProps) => CSSInterpolation),\n ...args: GlobalInterpolation[]\n) => {\n const GlobalStyle = () => {\n const theme = useTheme();\n\n useMemo(() => {\n const props = { theme };\n const styles =\n typeof template === 'function'\n ? template(props)\n : css(template, ...args.map((arg) => (typeof arg === 'function' ? arg(props) : arg)));\n injectGlobal(styles as TemplateStringsArray);\n }, [theme]);\n\n return null;\n };\n\n return GlobalStyle;\n};\n"],"mappings":";;;;;AAWA,MAAa,qBACX,UACA,GAAG,SACA;CACH,MAAM,oBAAoB;EACxB,MAAM,QAAQ,SAAS;EAEvB,cAAc;GACZ,MAAM,QAAQ,EAAE,MAAM;GACtB,MAAM,SACJ,OAAO,aAAa,aAChB,SAAS,KAAK,IACd,IAAI,UAAU,GAAG,KAAK,KAAK,QAAS,OAAO,QAAQ,aAAa,IAAI,KAAK,IAAI,GAAI,CAAC;GACxF,aAAa,MAA8B;EAC7C,GAAG,CAAC,KAAK,CAAC;EAEV,OAAO;CACT;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"createGlobalStyle.mjs","names":[],"sources":["../../src/styles/createGlobalStyle.ts"],"sourcesContent":["'use client';\n\nimport type { CSSInterpolation } from '@emotion/serialize';\nimport { useInsertionEffect, useMemo, useRef } from 'react';\n\nimport { createGlobalSheet, css, injectGlobal } from './css';\nimport { type LobeTheme, useTheme } from './theme/scope';\n\ntype GlobalStyleProps = { theme: LobeTheme };\ntype GlobalInterpolation = CSSInterpolation | ((props: GlobalStyleProps) => CSSInterpolation);\n\nconst isServer = typeof document === 'undefined';\n\nexport const createGlobalStyle = (\n template: TemplateStringsArray | ((props: GlobalStyleProps) => CSSInterpolation),\n ...args: GlobalInterpolation[]\n) => {\n const GlobalStyle = () => {\n const theme = useTheme();\n const sheetRef = useRef<ReturnType<typeof createGlobalSheet>>(null);\n\n const styles = useMemo(() => {\n const props = { theme };\n const resolved =\n typeof template === 'function'\n ? template(props)\n : css(template, ...args.map((arg) => (typeof arg === 'function' ? arg(props) : arg)));\n // Server renders keep feeding the shared cache so extractStaticStyle ships them.\n if (isServer) injectGlobal(resolved as TemplateStringsArray);\n return resolved;\n }, [theme]);\n\n useInsertionEffect(() => {\n const sheet = createGlobalSheet();\n sheetRef.current = sheet;\n return () => {\n sheet.remove();\n sheetRef.current = null;\n };\n }, []);\n\n useInsertionEffect(() => {\n sheetRef.current?.update(styles);\n }, [styles]);\n\n return null;\n };\n\n return GlobalStyle;\n};\n"],"mappings":";;;;;AAWA,MAAM,WAAW,OAAO,aAAa;AAErC,MAAa,qBACX,UACA,GAAG,SACA;CACH,MAAM,oBAAoB;EACxB,MAAM,QAAQ,SAAS;EACvB,MAAM,WAAW,OAA6C,IAAI;EAElE,MAAM,SAAS,cAAc;GAC3B,MAAM,QAAQ,EAAE,MAAM;GACtB,MAAM,WACJ,OAAO,aAAa,aAChB,SAAS,KAAK,IACd,IAAI,UAAU,GAAG,KAAK,KAAK,QAAS,OAAO,QAAQ,aAAa,IAAI,KAAK,IAAI,GAAI,CAAC;GAExF,IAAI,UAAU,aAAa,QAAgC;GAC3D,OAAO;EACT,GAAG,CAAC,KAAK,CAAC;EAEV,yBAAyB;GACvB,MAAM,QAAQ,kBAAkB;GAChC,SAAS,UAAU;GACnB,aAAa;IACX,MAAM,OAAO;IACb,SAAS,UAAU;GACrB;EACF,GAAG,CAAC,CAAC;EAEL,yBAAyB;GACvB,SAAS,SAAS,OAAO,MAAM;EACjC,GAAG,CAAC,MAAM,CAAC;EAEX,OAAO;CACT;CAEA,OAAO;AACT"}
package/es/styles/css.mjs CHANGED
@@ -45,6 +45,23 @@ const isSerialized = (value) => typeof value === "object" && value !== null && "
45
45
  const css = (template, ...args) => serializeStyles([template, ...args], emotion.cache.registered);
46
46
  const cx = (...classNames) => emotion.cx(...classNames.map((value) => isSerialized(value) ? emotion.css(value) : value));
47
47
  const { injectGlobal, keyframes } = emotion;
48
+ const compileGlobal = (styles) => {
49
+ let rules = "";
50
+ emotion.cache.insert("", serializeStyles([styles], emotion.cache.registered), { insert: (rule) => rules += rule }, false);
51
+ return rules;
52
+ };
53
+ const createGlobalSheet = () => {
54
+ const element = document.createElement("style");
55
+ element.dataset.emotion = `${emotion.cache.key}-global`;
56
+ const { container, tags } = emotion.sheet;
57
+ container.insertBefore(element, tags[0] ?? null);
58
+ return {
59
+ remove: () => element.remove(),
60
+ update: (styles) => {
61
+ element.textContent = compileGlobal(styles);
62
+ }
63
+ };
64
+ };
48
65
  const staticCss = (template, ...args) => emotion.css(template, ...args);
49
66
  const createStaticStyles = (stylesFn) => stylesFn({
50
67
  css: staticCss,
@@ -65,6 +82,6 @@ const extractStaticStyle = Object.assign((html, _options) => {
65
82
  tag: `<style data-emotion="${key} ${ids.join(" ")}">${styles}</style>`
66
83
  }];
67
84
  }, { cache: emotion.cache });
68
- export { createStaticStyles, css, cssVar, cx, extractStaticStyle, injectGlobal, keyframes, responsive, toCssVarName, toCssVariables, toKebabCase };
85
+ export { createGlobalSheet, createStaticStyles, css, cssVar, cx, extractStaticStyle, injectGlobal, keyframes, responsive, toCssVarName, toCssVariables, toKebabCase };
69
86
 
70
87
  //# sourceMappingURL=css.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"css.mjs","names":[],"sources":["../../src/styles/css.ts"],"sourcesContent":["import createEmotion from '@emotion/css/create-instance';\nimport { type CSSInterpolation, type SerializedStyles, serializeStyles } from '@emotion/serialize';\n\nimport { createLobeToken, type LobeToken } from './theme/createLobeToken';\n\nconst UNITLESS = new Set([\n 'fontWeightStrong',\n 'lineHeight',\n 'lineHeightHeading1',\n 'lineHeightHeading2',\n 'lineHeightHeading3',\n 'lineHeightHeading4',\n 'lineHeightHeading5',\n 'lineHeightLG',\n 'lineHeightSM',\n 'opacityImage',\n 'opacityLoading',\n 'zIndexBase',\n 'zIndexPopupBase',\n]);\n\nconst IGNORED = new Set(['motionBase', 'motionUnit']);\n\nexport const toKebabCase = (str: string) =>\n str\n .replaceAll(/([a-z])([A-Z])/g, '$1-$2')\n .replaceAll(/([a-z])(\\d)/g, '$1-$2')\n .replaceAll(/(\\d)([A-Z])/g, '$1-$2')\n .replaceAll(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')\n .toLowerCase();\n\nexport const toCssVarName = (key: string) => `--lobe-${toKebabCase(key)}`;\n\nexport const toCssVariables = (token: Record<string, number | string>) =>\n Object.fromEntries(\n Object.entries(token)\n .filter(([key]) => !IGNORED.has(key))\n .map(([key, value]) => [\n toCssVarName(key),\n typeof value === 'number' && !UNITLESS.has(key)\n ? `${value}px`\n : String(value).replaceAll(/\\s+/g, ' ').trim(),\n ]),\n );\n\nexport type LobeCssVar = Record<Exclude<keyof LobeToken, 'motionBase' | 'motionUnit'>, string>;\n\nexport const cssVar = Object.fromEntries(\n Object.keys(createLobeToken({ appearance: 'light' }))\n .filter((key) => !IGNORED.has(key))\n .map((key) => [key, `var(${toCssVarName(key)})`]),\n) as LobeCssVar;\n\nconst breakpoints = {\n xs: '@media (max-width: 479.98px)',\n sm: '@media (max-width: 575.98px)',\n md: '@media (max-width: 767.98px)',\n lg: '@media (max-width: 991.98px)',\n xl: '@media (max-width: 1199.98px)',\n xxl: '@media (min-width: 1200px)',\n};\n\nexport const responsive = {\n ...breakpoints,\n desktop: breakpoints.xxl,\n laptop: breakpoints.lg,\n mobile: breakpoints.xs,\n tablet: breakpoints.md,\n};\n\nexport interface StaticStyleUtils {\n css: (template: TemplateStringsArray, ...args: any[]) => string;\n cssVar: LobeCssVar;\n cx: (...classNames: any[]) => string;\n responsive: typeof responsive;\n}\n\nconst emotion = createEmotion({ key: 'acss', speedy: true });\n\nconst isSerialized = (value: unknown): value is SerializedStyles =>\n typeof value === 'object' && value !== null && 'name' in value && 'styles' in value;\n\nexport const css = (\n template: TemplateStringsArray | CSSInterpolation,\n ...args: CSSInterpolation[]\n): SerializedStyles =>\n serializeStyles([template as CSSInterpolation, ...args], emotion.cache.registered);\n\nexport const cx = (...classNames: unknown[]): string =>\n emotion.cx(\n ...(classNames.map((value) => (isSerialized(value) ? emotion.css(value) : value)) as Parameters<\n typeof emotion.cx\n >),\n );\n\nexport const { injectGlobal, keyframes } = emotion;\n\nconst staticCss: StaticStyleUtils['css'] = (template, ...args) => emotion.css(template, ...args);\n\nexport const createStaticStyles = <T>(stylesFn: (utils: StaticStyleUtils) => T): T =>\n stylesFn({ css: staticCss, cssVar, cx, responsive });\n\nexport interface StaticStyleExtract {\n css: string;\n ids: string[];\n key: string;\n tag: string;\n}\n\n// emotion rehydrates `<style data-emotion=\"acss id…\">` from SSR into its cache on the client\nexport const extractStaticStyle = Object.assign(\n (html?: string, _options?: Record<string, unknown>): StaticStyleExtract[] => {\n const { inserted, key, registered } = emotion.cache;\n const used = html\n ? new Set([...html.matchAll(new RegExp(`${key}-([\\\\w-]+)`, 'g'))].map((match) => match[1]))\n : undefined;\n // Same rule as @emotion/server extractCritical: unregistered ids are globals/keyframes and always ship\n const ids = Object.keys(inserted).filter(\n (id) =>\n typeof inserted[id] === 'string' &&\n (!used || used.has(id) || registered[`${key}-${id}`] === undefined),\n );\n const styles = ids.map((id) => inserted[id]).join('');\n if (!styles) return [];\n return [\n {\n css: styles,\n ids,\n key,\n tag: `<style data-emotion=\"${key} ${ids.join(' ')}\">${styles}</style>`,\n },\n ];\n },\n { cache: emotion.cache },\n);\n"],"mappings":";;;;AAKA,MAAM,2BAAW,IAAI,IAAI;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,0BAAU,IAAI,IAAI,CAAC,cAAc,YAAY,CAAC;AAEpD,MAAa,eAAe,QAC1B,IACG,WAAW,mBAAmB,OAAO,CAAC,CACtC,WAAW,gBAAgB,OAAO,CAAC,CACnC,WAAW,gBAAgB,OAAO,CAAC,CACnC,WAAW,yBAAyB,OAAO,CAAC,CAC5C,YAAY;AAEjB,MAAa,gBAAgB,QAAgB,UAAU,YAAY,GAAG;AAEtE,MAAa,kBAAkB,UAC7B,OAAO,YACL,OAAO,QAAQ,KAAK,CAAC,CAClB,QAAQ,CAAC,SAAS,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC,CACpC,KAAK,CAAC,KAAK,WAAW,CACrB,aAAa,GAAG,GAChB,OAAO,UAAU,YAAY,CAAC,SAAS,IAAI,GAAG,IAC1C,GAAG,MAAM,MACT,OAAO,KAAK,CAAC,CAAC,WAAW,QAAQ,GAAG,CAAC,CAAC,KAAK,CACjD,CAAC,CACL;AAIF,MAAa,SAAS,OAAO,YAC3B,OAAO,KAAK,gBAAgB,EAAE,YAAY,Q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vB,CAAC,QAAQ,KAAK,IAAI,EAAE,KAAK,WAAW,GAAG,IAAI,GAAG,UAAU,KAAA,EAC7D;CACA,MAAM,SAAS,IAAI,KAAK,OAAO,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE;CACpD,IAAI,CAAC,QAAQ,OAAO,CAAC;CACrB,OAAO,CACL;EACE,KAAK;EACL;EACA;EACA,KAAK,wBAAwB,IAAI,GAAG,IAAI,KAAK,GAAG,EAAE,IAAI,OAAO;CAC/D,CACF;AACF,GACA,EAAE,OAAO,QAAQ,MAAM,CACzB"}
1
+ {"version":3,"file":"css.mjs","names":[],"sources":["../../src/styles/css.ts"],"sourcesContent":["import createEmotion from '@emotion/css/create-instance';\nimport { type CSSInterpolation, type SerializedStyles, serializeStyles } from '@emotion/serialize';\n\nimport { createLobeToken, type LobeToken } from './theme/createLobeToken';\n\nconst UNITLESS = new Set([\n 'fontWeightStrong',\n 'lineHeight',\n 'lineHeightHeading1',\n 'lineHeightHeading2',\n 'lineHeightHeading3',\n 'lineHeightHeading4',\n 'lineHeightHeading5',\n 'lineHeightLG',\n 'lineHeightSM',\n 'opacityImage',\n 'opacityLoading',\n 'zIndexBase',\n 'zIndexPopupBase',\n]);\n\nconst IGNORED = new Set(['motionBase', 'motionUnit']);\n\nexport const toKebabCase = (str: string) =>\n str\n .replaceAll(/([a-z])([A-Z])/g, '$1-$2')\n .replaceAll(/([a-z])(\\d)/g, '$1-$2')\n .replaceAll(/(\\d)([A-Z])/g, '$1-$2')\n .replaceAll(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')\n .toLowerCase();\n\nexport const toCssVarName = (key: string) => `--lobe-${toKebabCase(key)}`;\n\nexport const toCssVariables = (token: Record<string, number | string>) =>\n Object.fromEntries(\n Object.entries(token)\n .filter(([key]) => !IGNORED.has(key))\n .map(([key, value]) => [\n toCssVarName(key),\n typeof value === 'number' && !UNITLESS.has(key)\n ? `${value}px`\n : String(value).replaceAll(/\\s+/g, ' ').trim(),\n ]),\n );\n\nexport type LobeCssVar = Record<Exclude<keyof LobeToken, 'motionBase' | 'motionUnit'>, string>;\n\nexport const cssVar = Object.fromEntries(\n Object.keys(createLobeToken({ appearance: 'light' }))\n .filter((key) => !IGNORED.has(key))\n .map((key) => [key, `var(${toCssVarName(key)})`]),\n) as LobeCssVar;\n\nconst breakpoints = {\n xs: '@media (max-width: 479.98px)',\n sm: '@media (max-width: 575.98px)',\n md: '@media (max-width: 767.98px)',\n lg: '@media (max-width: 991.98px)',\n xl: '@media (max-width: 1199.98px)',\n xxl: '@media (min-width: 1200px)',\n};\n\nexport const responsive = {\n ...breakpoints,\n desktop: breakpoints.xxl,\n laptop: breakpoints.lg,\n mobile: breakpoints.xs,\n tablet: breakpoints.md,\n};\n\nexport interface StaticStyleUtils {\n css: (template: TemplateStringsArray, ...args: any[]) => string;\n cssVar: LobeCssVar;\n cx: (...classNames: any[]) => string;\n responsive: typeof responsive;\n}\n\nconst emotion = createEmotion({ key: 'acss', speedy: true });\n\nconst isSerialized = (value: unknown): value is SerializedStyles =>\n typeof value === 'object' && value !== null && 'name' in value && 'styles' in value;\n\nexport const css = (\n template: TemplateStringsArray | CSSInterpolation,\n ...args: CSSInterpolation[]\n): SerializedStyles =>\n serializeStyles([template as CSSInterpolation, ...args], emotion.cache.registered);\n\nexport const cx = (...classNames: unknown[]): string =>\n emotion.cx(\n ...(classNames.map((value) => (isSerialized(value) ? emotion.css(value) : value)) as Parameters<\n typeof emotion.cx\n >),\n );\n\nexport const { injectGlobal, keyframes } = emotion;\n\ntype EmotionSheet = Parameters<typeof emotion.cache.insert>[2];\n\nconst compileGlobal = (styles: CSSInterpolation): string => {\n let rules = '';\n const collector = { insert: (rule: string) => (rules += rule) } as unknown as EmotionSheet;\n emotion.cache.insert('', serializeStyles([styles], emotion.cache.registered), collector, false);\n return rules;\n};\n\n// Owns its rules instead of going through `injectGlobal`, whose per-hash dedupe never\n// re-inserts a style it has seen: switching A → B → A would leave B's rules last and winning.\nexport const createGlobalSheet = () => {\n const element = document.createElement('style');\n element.dataset.emotion = `${emotion.cache.key}-global`;\n const { container, tags } = emotion.sheet as unknown as { container: Node; tags: Node[] };\n container.insertBefore(element, tags[0] ?? null);\n\n return {\n remove: () => element.remove(),\n update: (styles: CSSInterpolation) => {\n element.textContent = compileGlobal(styles);\n },\n };\n};\n\nconst staticCss: StaticStyleUtils['css'] = (template, ...args) => emotion.css(template, ...args);\n\nexport const createStaticStyles = <T>(stylesFn: (utils: StaticStyleUtils) => T): T =>\n stylesFn({ css: staticCss, cssVar, cx, responsive });\n\nexport interface StaticStyleExtract {\n css: string;\n ids: string[];\n key: string;\n tag: string;\n}\n\n// emotion rehydrates `<style data-emotion=\"acss id…\">` from SSR into its cache on the client\nexport const extractStaticStyle = Object.assign(\n (html?: string, _options?: Record<string, unknown>): StaticStyleExtract[] => {\n const { inserted, key, registered } = emotion.cache;\n const used = html\n ? new Set([...html.matchAll(new RegExp(`${key}-([\\\\w-]+)`, 'g'))].map((match) => match[1]))\n : undefined;\n // Same rule as @emotion/server extractCritical: unregistered ids are globals/keyframes and always ship\n const ids = Object.keys(inserted).filter(\n (id) =>\n typeof inserted[id] === 'string' &&\n (!used || used.has(id) || registered[`${key}-${id}`] === undefined),\n );\n const styles = ids.map((id) => inserted[id]).join('');\n if (!styles) return [];\n return [\n {\n css: styles,\n ids,\n key,\n tag: `<style data-emotion=\"${key} ${ids.join(' ')}\">${styles}</style>`,\n },\n ];\n },\n { cache: emotion.cache },\n);\n"],"mappings":";;;;AAKA,MAAM,2BAAW,IAAI,IAAI;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,0BAAU,IAAI,IAAI,CAAC,cAAc,YAAY,CAAC;AAEpD,MAAa,eAAe,QAC1B,IACG,WAAW,mBAAmB,OAAO,CAAC,CACtC,WAAW,gBAAgB,OAAO,CAAC,CACnC,WAAW,gBAAgB,OAAO,CAAC,CACnC,WAAW,yBAAyB,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G,EAAE,IAAI,OAAO;CAC/D,CACF;AACF,GACA,EAAE,OAAO,QAAQ,MAAM,CACzB"}
@@ -9,4 +9,5 @@ import { LobeStatusPalette, registerLobePalette } from "./theme/customPalette.mj
9
9
  import { staticStylish } from "./theme/customStylishStatic.mjs";
10
10
  import { generateColorNeutralPalette, generateColorPalette } from "./theme/generateColorPalette.mjs";
11
11
  import { getCustomNeutralCss, getCustomPaletteCss, getCustomPrimaryCss, getGlobalCss, getThemeCss } from "./theme/themeCss.mjs";
12
- export { type CreateLobeTokenParams, type CustomNeutralColor, type CustomPrimaryColor, type LobeAppearance, type LobeCssVar, type LobeNeutralColor, type LobeNeutralScale, type LobePrimaryColor, type LobeStatusPalette, type LobeTheme, LobeThemeScript, type LobeThemeScriptProps, type LobeThemeState, type LobeToken, NeutralColors, NeutralColorsObj, PrimaryColors, PrimaryColorsObj, type ResponsiveState, type StaticStyleExtract, type StaticStyleUtils, ThemeScope, type ThemeScopeProps, createGlobalStyle, createLobeToken, createStaticStyles, css, cssVar, cx, extractStaticStyle, findCustomThemeName, generateColorNeutralPalette, generateColorPalette, generateNeutralScale, getCustomNeutralCss, getCustomPaletteCss, getCustomPrimaryCss, getGlobalCss, getThemeCss, injectGlobal, isCustomNeutralColor, isCustomPrimaryColor, keyframes, staticStylish as lobeStaticStylish, neutralColors, neutralColorsSwatches, primaryColors, primaryColorsSwatches, registerLobeNeutral, registerLobePalette, responsive, setLobeTheme, useResponsive, useTheme, useThemeMode };
12
+ import { GenFontFamilyOptions, genFontFamily, genFontFamilyCode } from "./theme/token/font.mjs";
13
+ export { type CreateLobeTokenParams, type CustomNeutralColor, type CustomPrimaryColor, type GenFontFamilyOptions, type LobeAppearance, type LobeCssVar, type LobeNeutralColor, type LobeNeutralScale, type LobePrimaryColor, type LobeStatusPalette, type LobeTheme, LobeThemeScript, type LobeThemeScriptProps, type LobeThemeState, type LobeToken, NeutralColors, NeutralColorsObj, PrimaryColors, PrimaryColorsObj, type ResponsiveState, type StaticStyleExtract, type StaticStyleUtils, ThemeScope, type ThemeScopeProps, createGlobalStyle, createLobeToken, createStaticStyles, css, cssVar, cx, extractStaticStyle, findCustomThemeName, genFontFamily, genFontFamilyCode, generateColorNeutralPalette, generateColorPalette, generateNeutralScale, getCustomNeutralCss, getCustomPaletteCss, getCustomPrimaryCss, getGlobalCss, getThemeCss, injectGlobal, isCustomNeutralColor, isCustomPrimaryColor, keyframes, staticStylish as lobeStaticStylish, neutralColors, neutralColorsSwatches, primaryColors, primaryColorsSwatches, registerLobeNeutral, registerLobePalette, responsive, setLobeTheme, useResponsive, useTheme, useThemeMode };
@@ -3,10 +3,11 @@ import { generateNeutralScale, isCustomNeutralColor, registerLobeNeutral } from
3
3
  import { generateColorNeutralPalette, generateColorPalette } from "./theme/generateColorPalette.mjs";
4
4
  import { findCustomThemeName, neutralColors, neutralColorsSwatches, primaryColors, primaryColorsSwatches } from "./customTheme.mjs";
5
5
  import { isCustomPrimaryColor } from "./theme/customPrimary.mjs";
6
+ import { genFontFamily, genFontFamilyCode } from "./theme/token/font.mjs";
6
7
  import { createLobeToken } from "./theme/createLobeToken.mjs";
7
8
  import { createStaticStyles, css, cssVar, cx, extractStaticStyle, injectGlobal, keyframes, responsive } from "./css.mjs";
8
9
  import { getCustomNeutralCss, getCustomPaletteCss, getCustomPrimaryCss, getGlobalCss, getThemeCss } from "./theme/themeCss.mjs";
9
10
  import { LobeThemeScript, ThemeScope, setLobeTheme, useResponsive, useTheme, useThemeMode } from "./theme/scope.mjs";
10
11
  import { createGlobalStyle } from "./createGlobalStyle.mjs";
11
12
  import { staticStylish } from "./theme/customStylishStatic.mjs";
12
- export { LobeThemeScript, ThemeScope, createGlobalStyle, createLobeToken, createStaticStyles, css, cssVar, cx, extractStaticStyle, findCustomThemeName, generateColorNeutralPalette, generateColorPalette, generateNeutralScale, getCustomNeutralCss, getCustomPaletteCss, getCustomPrimaryCss, getGlobalCss, getThemeCss, injectGlobal, isCustomNeutralColor, isCustomPrimaryColor, keyframes, staticStylish as lobeStaticStylish, neutralColors, neutralColorsSwatches, primaryColors, primaryColorsSwatches, registerLobeNeutral, registerLobePalette, responsive, setLobeTheme, useResponsive, useTheme, useThemeMode };
13
+ export { LobeThemeScript, ThemeScope, createGlobalStyle, createLobeToken, createStaticStyles, css, cssVar, cx, extractStaticStyle, findCustomThemeName, genFontFamily, genFontFamilyCode, generateColorNeutralPalette, generateColorPalette, generateNeutralScale, getCustomNeutralCss, getCustomPaletteCss, getCustomPrimaryCss, getGlobalCss, getThemeCss, injectGlobal, isCustomNeutralColor, isCustomPrimaryColor, keyframes, staticStylish as lobeStaticStylish, neutralColors, neutralColorsSwatches, primaryColors, primaryColorsSwatches, registerLobeNeutral, registerLobePalette, responsive, setLobeTheme, useResponsive, useTheme, useThemeMode };
@@ -1,6 +1,7 @@
1
1
  import { isRegisteredPalette } from "./customPalette.mjs";
2
2
  import { isCustomNeutral } from "./customNeutral.mjs";
3
3
  import { neutralColors, primaryColors } from "../customTheme.mjs";
4
+ import { LOCALE_FONTS, genFontFamily, genFontFamilyCode } from "./token/font.mjs";
4
5
  import { createLobeTokenGroups } from "./createLobeToken.mjs";
5
6
  import { toCssVarName, toCssVariables } from "../css.mjs";
6
7
  // src/styles/theme/themeCss.ts
@@ -51,6 +52,10 @@ const colorRules = (appearance) => [...Object.keys(primaryColors).map((primaryCo
51
52
  appearance,
52
53
  neutralColor
53
54
  }).neutral)))];
55
+ const localeFontRules = () => LOCALE_FONTS.map(({ langs }) => rule(langs.map((lang) => `:is(:root, [data-theme]):lang(${lang})`).join(", "), {
56
+ [toCssVarName("fontFamily")]: genFontFamily({ locale: langs[0] }),
57
+ [toCssVarName("fontFamilyCode")]: genFontFamilyCode({ locale: langs[0] })
58
+ }));
54
59
  const getCustomPrimaryCss = (color) => {
55
60
  const hex = color.toLowerCase();
56
61
  return ["light", "dark"].map((appearance) => rule(`[data-primary-color='${hex}']${appearanceSelector(appearance)}`, toCssVariables(createLobeTokenGroups({
@@ -376,6 +381,7 @@ const getThemeCss = () => cached ??= [
376
381
  appearanceRule("[data-theme='dark']", "dark"),
377
382
  ...colorRules("light"),
378
383
  ...colorRules("dark"),
384
+ ...localeFontRules(),
379
385
  essentialCss
380
386
  ].join("\n\n");
381
387
  const getGlobalCss = () => `${layerOrder}\n\n${globalCss}`;
@@ -1 +1 @@
1
- {"version":3,"file":"themeCss.mjs","names":[],"sources":["../../../src/styles/theme/themeCss.ts"],"sourcesContent":["import { toCssVariables, toCssVarName } from '../css';\nimport { neutralColors, primaryColors } from '../customTheme';\nimport { createLobeTokenGroups } from './createLobeToken';\nimport { isCustomNeutral } from './customNeutral';\nimport { isRegisteredPalette } from './customPalette';\nimport type { CustomPrimaryColor } from './customPrimary';\nimport type { LobeAppearance } from './scope';\n\nconst v = (key: string) => `var(${toCssVarName(key)})`;\n\nconst ring: Record<LobeAppearance, string> = {\n dark: '0 0 0 1px rgb(255 255 255 / 18%)',\n light: '0 0 0 1px rgb(0 0 0 / 5%)',\n};\n\n/* `initial` makes a light scope nested in a dark one fall back to each variant's own fill\n instead of inheriting the dark table surface. */\nconst surface: Record<LobeAppearance, Record<string, string>> = {\n dark: {\n '--lobe-fill-border': v('colorFillSecondary'),\n '--lobe-fill-border-strong': v('colorFill'),\n '--lobe-table-cell-bg': 'transparent',\n '--lobe-table-surface': v('colorFillQuaternary'),\n },\n light: {\n '--lobe-fill-border': v('colorFill'),\n '--lobe-fill-border-strong': `color-mix(in srgb, ${v('colorFill')}, ${v('colorText')} 15%)`,\n '--lobe-table-cell-bg': 'initial',\n '--lobe-table-surface': 'initial',\n },\n};\n\nconst rule = (selector: string, declarations: Record<string, number | string>) =>\n `${selector} {\\n${Object.entries(declarations)\n .map(([name, value]) => ` ${name}: ${value};`)\n .join('\\n')}\\n}`;\n\nconst appearanceRule = (selector: string, appearance: LobeAppearance) => {\n const { neutral, palette, primary, static: base } = createLobeTokenGroups({ appearance });\n const token =\n appearance === 'light'\n ? { ...base, ...palette, ...primary, ...neutral }\n : { ...palette, ...primary, ...neutral };\n\n return rule(selector, {\n ...toCssVariables(token),\n '--lobe-ring': ring[appearance],\n ...surface[appearance],\n 'color-scheme': appearance,\n });\n};\n\nconst appearanceSelector = (appearance: LobeAppearance) =>\n appearance === 'dark' ? \"[data-theme='dark']\" : \":not([data-theme='dark'])\";\n\nconst colorRules = (appearance: LobeAppearance) => [\n ...(Object.keys(primaryColors) as (keyof typeof primaryColors)[]).map((primaryColor) =>\n rule(\n `[data-primary-color='${primaryColor}']${appearanceSelector(appearance)}`,\n toCssVariables(createLobeTokenGroups({ appearance, primaryColor }).primary),\n ),\n ),\n ...(Object.keys(neutralColors) as (keyof typeof neutralColors)[]).map((neutralColor) =>\n rule(\n `[data-neutral-color='${neutralColor}']${appearanceSelector(appearance)}`,\n toCssVariables(createLobeTokenGroups({ appearance, neutralColor }).neutral),\n ),\n ),\n];\n\nexport const getCustomPrimaryCss = (color: CustomPrimaryColor) => {\n const hex = color.toLowerCase();\n return (['light', 'dark'] as const)\n .map((appearance) =>\n rule(\n `[data-primary-color='${hex}']${appearanceSelector(appearance)}`,\n toCssVariables(\n createLobeTokenGroups({ appearance, primaryColor: hex as CustomPrimaryColor }).primary,\n ),\n ),\n )\n .join('\\n\\n');\n};\n\n/** CSS for a custom neutral (6-digit hex or a `registerLobeNeutral` name); '' for presets. */\nexport const getCustomNeutralCss = (value: string) => {\n const key = value.startsWith('#') ? value.toLowerCase() : value;\n if (!isCustomNeutral(key)) return '';\n return (['light', 'dark'] as const)\n .map((appearance) =>\n rule(\n `[data-neutral-color='${key}']${appearanceSelector(appearance)}`,\n toCssVariables(createLobeTokenGroups({ appearance, neutralColor: key }).neutral),\n ),\n )\n .join('\\n\\n');\n};\n\nexport const getCustomPaletteCss = (name: string) => {\n if (!isRegisteredPalette(name)) return '';\n return (['light', 'dark'] as const)\n .map((appearance) => {\n const { neutral, palette } = createLobeTokenGroups({ appearance, palette: name });\n return rule(\n `[data-palette='${name}']${appearanceSelector(appearance)}`,\n toCssVariables({\n ...palette,\n colorErrorOutline: neutral.colorErrorOutline,\n colorWarningOutline: neutral.colorWarningOutline,\n }),\n );\n })\n .join('\\n\\n');\n};\n\n/**\n * The outline tokens depend on both the neutral and the status palette, so the standalone\n * neutral / palette stylesheets each compute them against the other's default. This rule\n * (higher specificity) recomputes them for the actual combination.\n */\nexport const getPaletteNeutralCss = (name: string, neutralColor: string) => {\n if (!isRegisteredPalette(name) || !neutralColor) return '';\n const key = neutralColor.startsWith('#') ? neutralColor.toLowerCase() : neutralColor;\n return (['light', 'dark'] as const)\n .map((appearance) => {\n const { neutral } = createLobeTokenGroups({ appearance, neutralColor: key, palette: name });\n return rule(\n `[data-palette='${name}'][data-neutral-color='${key}']${appearanceSelector(appearance)}`,\n toCssVariables({\n colorErrorOutline: neutral.colorErrorOutline,\n colorWarningOutline: neutral.colorWarningOutline,\n }),\n );\n })\n .join('\\n\\n');\n};\n\nconst essentialCss = `@layer lobe-ui {\n .lobe-brand-loading path {\n fill: currentcolor;\n fill-opacity: 0;\n stroke: currentcolor;\n stroke-dasharray: 1000;\n stroke-dashoffset: 1000;\n stroke-width: 0.25em;\n\n animation:\n draw 2s cubic-bezier(0.4, 0, 0.2, 1) infinite,\n fill 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n }\n}\n\n@layer lobe-popup {\n .lobe-context-trigger[data-popup-open],\n .lobe-dropdown-menu-trigger[data-popup-open] {\n background: ${v('colorFillTertiary')};\n }\n}\n\n@layer lobe-base {\n :where(body, body [data-theme]) {\n color: ${v('colorText')};\n font-family: ${v('fontFamily')};\n font-size: ${v('fontSize')};\n line-height: ${v('lineHeight')};\n }\n\n :where(body) :where(a) {\n cursor: pointer;\n\n color: ${v('colorLink')};\n text-decoration: none;\n\n background-color: transparent;\n outline: none;\n\n transition: color ${v('motionDurationSlow')};\n }\n\n :where(body) :where(a):hover {\n color: ${v('colorLinkHover')};\n }\n\n :where(body) :where(a):active {\n color: ${v('colorLinkActive')};\n }\n\n :where(body) :where(a):focus-visible {\n outline: ${v('lineWidthFocus')} solid ${v('colorPrimaryBorder')};\n outline-offset: 1px;\n }\n\n :where(body) :where(a)[disabled] {\n cursor: not-allowed;\n color: ${v('colorTextDisabled')};\n }\n\n :where(.lobe-flex) {\n --lobe-flex: 0 1 auto;\n --lobe-flex-direction: column;\n --lobe-flex-wrap: nowrap;\n --lobe-flex-justify: flex-start;\n --lobe-flex-align: stretch;\n --lobe-flex-width: auto;\n --lobe-flex-height: auto;\n --lobe-flex-padding: 0;\n --lobe-flex-padding-inline: var(--lobe-flex-padding);\n --lobe-flex-padding-block: var(--lobe-flex-padding);\n --lobe-flex-gap: 0;\n\n display: flex;\n flex: var(--lobe-flex);\n flex-flow: var(--lobe-flex-direction) var(--lobe-flex-wrap);\n gap: var(--lobe-flex-gap);\n align-items: var(--lobe-flex-align);\n justify-content: var(--lobe-flex-justify);\n\n width: var(--lobe-flex-width);\n height: var(--lobe-flex-height);\n padding: var(--lobe-flex-padding);\n padding-block: var(--lobe-flex-padding-block);\n padding-inline: var(--lobe-flex-padding-inline);\n }\n\n .lobe-flex-hidden {\n display: none;\n }\n}\n\n@keyframes draw {\n 0% {\n stroke-dashoffset: 1000;\n }\n\n 100% {\n stroke-dashoffset: 0;\n }\n}\n\n@keyframes fill {\n 30% {\n fill-opacity: 0.05;\n }\n\n 100% {\n fill-opacity: 1;\n }\n}`;\n\nconst globalCss = `@layer lobe-base {\n :root {\n --font-settings: 'cv01', 'tnum', 'kern';\n --font-variations: 'opsz' auto, tabular-nums;\n\n font-synthesis: style;\n text-autospace: normal;\n }\n\n html {\n overscroll-behavior: none;\n }\n\n body {\n overflow: hidden auto;\n\n min-height: 100vh;\n margin: 0;\n padding: 0;\n\n font-feature-settings: var(--font-settings);\n font-variation-settings: var(--font-variations);\n font-optical-sizing: auto;\n font-kerning: normal;\n font-variant-ligatures: common-ligatures contextual;\n font-variant-numeric: tabular-nums;\n font-size-adjust: from-font;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-wrap: pretty;\n text-size-adjust: 100%;\n text-rendering: optimizelegibility;\n overflow-wrap: anywhere;\n vertical-align: baseline;\n\n background-color: ${v('colorBgLayout')};\n\n font-synthesis: style;\n\n -webkit-overflow-scrolling: touch;\n -webkit-tap-highlight-color: transparent;\n }\n\n html,\n body {\n width: 100%;\n height: 100%;\n }\n\n [tabindex='-1']:focus {\n outline: none;\n }\n\n [hidden] {\n display: none !important;\n }\n\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n margin-block: 0 0.5em;\n font-weight: 500;\n }\n\n p,\n ol,\n ul,\n dl,\n pre {\n margin-block: 0 1em;\n }\n\n ol ol,\n ul ul,\n ol ul,\n ul ol {\n margin-block-end: 0;\n }\n\n dd {\n margin-block-end: 0.5em;\n margin-inline-start: 0;\n }\n\n blockquote,\n figure {\n margin-block: 0 1em;\n margin-inline: 0;\n }\n\n img {\n border-style: none;\n vertical-align: middle;\n }\n\n table {\n border-collapse: collapse;\n }\n\n input,\n button,\n select,\n optgroup,\n textarea {\n margin: 0;\n\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n color: inherit;\n }\n\n textarea {\n resize: vertical;\n overflow: auto;\n }\n\n fieldset {\n min-width: 0;\n margin: 0;\n padding: 0;\n border: 0;\n }\n\n code,\n kbd,\n samp,\n pre {\n font-family: ${v('fontFamilyCode')} !important;\n font-feature-settings:\n 'liga' 0,\n 'calt' 0;\n font-variant-ligatures: none;\n\n span {\n font-family: ${v('fontFamilyCode')} !important;\n }\n }\n\n ::selection {\n color: #000;\n background: ${v('yellow9')};\n\n -webkit-text-fill-color: unset !important;\n }\n\n * {\n scrollbar-color: ${v('colorFill')} transparent;\n scrollbar-width: thin;\n box-sizing: border-box;\n vertical-align: baseline;\n }\n}`;\n\nconst layerOrder = '@layer lobe-base, lobe-popup, lobe-ui;';\n\nlet cached: string | undefined;\n\nexport const getThemeCss = () =>\n (cached ??= [\n layerOrder,\n appearanceRule(\":root, [data-theme='light']\", 'light'),\n appearanceRule(\"[data-theme='dark']\", 'dark'),\n ...colorRules('light'),\n ...colorRules('dark'),\n essentialCss,\n ].join('\\n\\n'));\n\nexport const getGlobalCss = () => `${layerOrder}\\n\\n${globalCss}`;\n"],"mappings":";;;;;;AAQA,MAAM,KAAK,QAAgB,OAAO,aAAa,GAAG,EAAE;AAEpD,MAAM,OAAuC;CAC3C,MAAM;CACN,OAAO;AACT;AAIA,MAAM,UAA0D;CAC9D,MAAM;EACJ,sBAAsB,EAAE,oBAAoB;EAC5C,6BAA6B,EAAE,WAAW;EAC1C,wBAAwB;EACxB,wBAAwB,EAAE,qBAAqB;CACjD;CACA,OAAO;EACL,sBAAsB,EAAE,WAAW;EACnC,6BAA6B,sBAAsB,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE;EACrF,wBAAwB;EACxB,wBAAwB;CAC1B;AACF;AAEA,MAAM,QAAQ,UAAkB,iBAC9B,GAAG,SAAS,MAAM,OAAO,QAAQ,YAAY,CAAC,CAC3C,KAAK,CAAC,MAAM,WAAW,KAAK,KAAK,IAAI,MAAM,EAAE,CAAC,CAC9C,KAAK,IAAI,EAAE;AAEhB,MAAM,kBAAkB,UAAkB,eAA+B;CACvE,MAAM,EAAE,SAAS,SAAS,SAAS,QAAQ,SAAS,sBAAsB,EAAE,WAAW,CAAC;CACxF,MAAM,QACJ,eAAe,UACX;EAAE,GAAG;EAAM,GAAG;EAAS,GAAG;EAAS,GAAG;CAAQ,IAC9C;EAAE,GAAG;EAAS,GAAG;EAAS,GAAG;CAAQ;CAE3C,OAAO,KAAK,UAAU;EACpB,GAAG,eAAe,KAAK;EACvB,eAAe,KAAK;EACpB,GAAG,QAAQ;EACX,gBAAgB;CAClB,CAAC;AACH;AAEA,MAAM,sBAAsB,eAC1B,eAAe,SAAS,wBAAwB;AAElD,MAAM,cAAc,eAA+B,CACjD,GAAI,OAAO,KAAK,aAAa,CAAC,CAAoC,KAAK,iBACrE,KACE,wBAAwB,aAAa,IAAI,mBAA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BAMR,EAAE,WAAW,EAAE;;;;;;AAOtC,MAAM,aAAa;AAEnB,IAAI;AAEJ,MAAa,oBACV,WAAW;CACV;CACA,eAAe,+BAA+B,OAAO;CACrD,eAAe,uBAAuB,MAAM;CAC5C,GAAG,WAAW,OAAO;CACrB,GAAG,WAAW,MAAM;CACpB;AACF,CAAC,CAAC,KAAK,MAAM;AAEf,MAAa,qBAAqB,GAAG,WAAW,MAAM"}
1
+ {"version":3,"file":"themeCss.mjs","names":[],"sources":["../../../src/styles/theme/themeCss.ts"],"sourcesContent":["import { toCssVariables, toCssVarName } from '../css';\nimport { neutralColors, primaryColors } from '../customTheme';\nimport { createLobeTokenGroups } from './createLobeToken';\nimport { isCustomNeutral } from './customNeutral';\nimport { isRegisteredPalette } from './customPalette';\nimport type { CustomPrimaryColor } from './customPrimary';\nimport type { LobeAppearance } from './scope';\nimport { genFontFamily, genFontFamilyCode, LOCALE_FONTS } from './token/font';\n\nconst v = (key: string) => `var(${toCssVarName(key)})`;\n\nconst ring: Record<LobeAppearance, string> = {\n dark: '0 0 0 1px rgb(255 255 255 / 18%)',\n light: '0 0 0 1px rgb(0 0 0 / 5%)',\n};\n\n/* `initial` makes a light scope nested in a dark one fall back to each variant's own fill\n instead of inheriting the dark table surface. */\nconst surface: Record<LobeAppearance, Record<string, string>> = {\n dark: {\n '--lobe-fill-border': v('colorFillSecondary'),\n '--lobe-fill-border-strong': v('colorFill'),\n '--lobe-table-cell-bg': 'transparent',\n '--lobe-table-surface': v('colorFillQuaternary'),\n },\n light: {\n '--lobe-fill-border': v('colorFill'),\n '--lobe-fill-border-strong': `color-mix(in srgb, ${v('colorFill')}, ${v('colorText')} 15%)`,\n '--lobe-table-cell-bg': 'initial',\n '--lobe-table-surface': 'initial',\n },\n};\n\nconst rule = (selector: string, declarations: Record<string, number | string>) =>\n `${selector} {\\n${Object.entries(declarations)\n .map(([name, value]) => ` ${name}: ${value};`)\n .join('\\n')}\\n}`;\n\nconst appearanceRule = (selector: string, appearance: LobeAppearance) => {\n const { neutral, palette, primary, static: base } = createLobeTokenGroups({ appearance });\n const token =\n appearance === 'light'\n ? { ...base, ...palette, ...primary, ...neutral }\n : { ...palette, ...primary, ...neutral };\n\n return rule(selector, {\n ...toCssVariables(token),\n '--lobe-ring': ring[appearance],\n ...surface[appearance],\n 'color-scheme': appearance,\n });\n};\n\nconst appearanceSelector = (appearance: LobeAppearance) =>\n appearance === 'dark' ? \"[data-theme='dark']\" : \":not([data-theme='dark'])\";\n\nconst colorRules = (appearance: LobeAppearance) => [\n ...(Object.keys(primaryColors) as (keyof typeof primaryColors)[]).map((primaryColor) =>\n rule(\n `[data-primary-color='${primaryColor}']${appearanceSelector(appearance)}`,\n toCssVariables(createLobeTokenGroups({ appearance, primaryColor }).primary),\n ),\n ),\n ...(Object.keys(neutralColors) as (keyof typeof neutralColors)[]).map((neutralColor) =>\n rule(\n `[data-neutral-color='${neutralColor}']${appearanceSelector(appearance)}`,\n toCssVariables(createLobeTokenGroups({ appearance, neutralColor }).neutral),\n ),\n ),\n];\n\nconst localeFontRules = () =>\n LOCALE_FONTS.map(({ langs }) =>\n rule(langs.map((lang) => `:is(:root, [data-theme]):lang(${lang})`).join(', '), {\n [toCssVarName('fontFamily')]: genFontFamily({ locale: langs[0] }),\n [toCssVarName('fontFamilyCode')]: genFontFamilyCode({ locale: langs[0] }),\n }),\n );\n\nexport const getCustomPrimaryCss = (color: CustomPrimaryColor) => {\n const hex = color.toLowerCase();\n return (['light', 'dark'] as const)\n .map((appearance) =>\n rule(\n `[data-primary-color='${hex}']${appearanceSelector(appearance)}`,\n toCssVariables(\n createLobeTokenGroups({ appearance, primaryColor: hex as CustomPrimaryColor }).primary,\n ),\n ),\n )\n .join('\\n\\n');\n};\n\n/** CSS for a custom neutral (6-digit hex or a `registerLobeNeutral` name); '' for presets. */\nexport const getCustomNeutralCss = (value: string) => {\n const key = value.startsWith('#') ? value.toLowerCase() : value;\n if (!isCustomNeutral(key)) return '';\n return (['light', 'dark'] as const)\n .map((appearance) =>\n rule(\n `[data-neutral-color='${key}']${appearanceSelector(appearance)}`,\n toCssVariables(createLobeTokenGroups({ appearance, neutralColor: key }).neutral),\n ),\n )\n .join('\\n\\n');\n};\n\nexport const getCustomPaletteCss = (name: string) => {\n if (!isRegisteredPalette(name)) return '';\n return (['light', 'dark'] as const)\n .map((appearance) => {\n const { neutral, palette } = createLobeTokenGroups({ appearance, palette: name });\n return rule(\n `[data-palette='${name}']${appearanceSelector(appearance)}`,\n toCssVariables({\n ...palette,\n colorErrorOutline: neutral.colorErrorOutline,\n colorWarningOutline: neutral.colorWarningOutline,\n }),\n );\n })\n .join('\\n\\n');\n};\n\n/**\n * The outline tokens depend on both the neutral and the status palette, so the standalone\n * neutral / palette stylesheets each compute them against the other's default. This rule\n * (higher specificity) recomputes them for the actual combination.\n */\nexport const getPaletteNeutralCss = (name: string, neutralColor: string) => {\n if (!isRegisteredPalette(name) || !neutralColor) return '';\n const key = neutralColor.startsWith('#') ? neutralColor.toLowerCase() : neutralColor;\n return (['light', 'dark'] as const)\n .map((appearance) => {\n const { neutral } = createLobeTokenGroups({ appearance, neutralColor: key, palette: name });\n return rule(\n `[data-palette='${name}'][data-neutral-color='${key}']${appearanceSelector(appearance)}`,\n toCssVariables({\n colorErrorOutline: neutral.colorErrorOutline,\n colorWarningOutline: neutral.colorWarningOutline,\n }),\n );\n })\n .join('\\n\\n');\n};\n\nconst essentialCss = `@layer lobe-ui {\n .lobe-brand-loading path {\n fill: currentcolor;\n fill-opacity: 0;\n stroke: currentcolor;\n stroke-dasharray: 1000;\n stroke-dashoffset: 1000;\n stroke-width: 0.25em;\n\n animation:\n draw 2s cubic-bezier(0.4, 0, 0.2, 1) infinite,\n fill 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n }\n}\n\n@layer lobe-popup {\n .lobe-context-trigger[data-popup-open],\n .lobe-dropdown-menu-trigger[data-popup-open] {\n background: ${v('colorFillTertiary')};\n }\n}\n\n@layer lobe-base {\n :where(body, body [data-theme]) {\n color: ${v('colorText')};\n font-family: ${v('fontFamily')};\n font-size: ${v('fontSize')};\n line-height: ${v('lineHeight')};\n }\n\n :where(body) :where(a) {\n cursor: pointer;\n\n color: ${v('colorLink')};\n text-decoration: none;\n\n background-color: transparent;\n outline: none;\n\n transition: color ${v('motionDurationSlow')};\n }\n\n :where(body) :where(a):hover {\n color: ${v('colorLinkHover')};\n }\n\n :where(body) :where(a):active {\n color: ${v('colorLinkActive')};\n }\n\n :where(body) :where(a):focus-visible {\n outline: ${v('lineWidthFocus')} solid ${v('colorPrimaryBorder')};\n outline-offset: 1px;\n }\n\n :where(body) :where(a)[disabled] {\n cursor: not-allowed;\n color: ${v('colorTextDisabled')};\n }\n\n :where(.lobe-flex) {\n --lobe-flex: 0 1 auto;\n --lobe-flex-direction: column;\n --lobe-flex-wrap: nowrap;\n --lobe-flex-justify: flex-start;\n --lobe-flex-align: stretch;\n --lobe-flex-width: auto;\n --lobe-flex-height: auto;\n --lobe-flex-padding: 0;\n --lobe-flex-padding-inline: var(--lobe-flex-padding);\n --lobe-flex-padding-block: var(--lobe-flex-padding);\n --lobe-flex-gap: 0;\n\n display: flex;\n flex: var(--lobe-flex);\n flex-flow: var(--lobe-flex-direction) var(--lobe-flex-wrap);\n gap: var(--lobe-flex-gap);\n align-items: var(--lobe-flex-align);\n justify-content: var(--lobe-flex-justify);\n\n width: var(--lobe-flex-width);\n height: var(--lobe-flex-height);\n padding: var(--lobe-flex-padding);\n padding-block: var(--lobe-flex-padding-block);\n padding-inline: var(--lobe-flex-padding-inline);\n }\n\n .lobe-flex-hidden {\n display: none;\n }\n}\n\n@keyframes draw {\n 0% {\n stroke-dashoffset: 1000;\n }\n\n 100% {\n stroke-dashoffset: 0;\n }\n}\n\n@keyframes fill {\n 30% {\n fill-opacity: 0.05;\n }\n\n 100% {\n fill-opacity: 1;\n }\n}`;\n\nconst globalCss = `@layer lobe-base {\n :root {\n --font-settings: 'cv01', 'tnum', 'kern';\n --font-variations: 'opsz' auto, tabular-nums;\n\n font-synthesis: style;\n text-autospace: normal;\n }\n\n html {\n overscroll-behavior: none;\n }\n\n body {\n overflow: hidden auto;\n\n min-height: 100vh;\n margin: 0;\n padding: 0;\n\n font-feature-settings: var(--font-settings);\n font-variation-settings: var(--font-variations);\n font-optical-sizing: auto;\n font-kerning: normal;\n font-variant-ligatures: common-ligatures contextual;\n font-variant-numeric: tabular-nums;\n font-size-adjust: from-font;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-wrap: pretty;\n text-size-adjust: 100%;\n text-rendering: optimizelegibility;\n overflow-wrap: anywhere;\n vertical-align: baseline;\n\n background-color: ${v('colorBgLayout')};\n\n font-synthesis: style;\n\n -webkit-overflow-scrolling: touch;\n -webkit-tap-highlight-color: transparent;\n }\n\n html,\n body {\n width: 100%;\n height: 100%;\n }\n\n [tabindex='-1']:focus {\n outline: none;\n }\n\n [hidden] {\n display: none !important;\n }\n\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n margin-block: 0 0.5em;\n font-weight: 500;\n }\n\n p,\n ol,\n ul,\n dl,\n pre {\n margin-block: 0 1em;\n }\n\n ol ol,\n ul ul,\n ol ul,\n ul ol {\n margin-block-end: 0;\n }\n\n dd {\n margin-block-end: 0.5em;\n margin-inline-start: 0;\n }\n\n blockquote,\n figure {\n margin-block: 0 1em;\n margin-inline: 0;\n }\n\n img {\n border-style: none;\n vertical-align: middle;\n }\n\n table {\n border-collapse: collapse;\n }\n\n input,\n button,\n select,\n optgroup,\n textarea {\n margin: 0;\n\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n color: inherit;\n }\n\n textarea {\n resize: vertical;\n overflow: auto;\n }\n\n fieldset {\n min-width: 0;\n margin: 0;\n padding: 0;\n border: 0;\n }\n\n code,\n kbd,\n samp,\n pre {\n font-family: ${v('fontFamilyCode')} !important;\n font-feature-settings:\n 'liga' 0,\n 'calt' 0;\n font-variant-ligatures: none;\n\n span {\n font-family: ${v('fontFamilyCode')} !important;\n }\n }\n\n ::selection {\n color: #000;\n background: ${v('yellow9')};\n\n -webkit-text-fill-color: unset !important;\n }\n\n * {\n scrollbar-color: ${v('colorFill')} transparent;\n scrollbar-width: thin;\n box-sizing: border-box;\n vertical-align: baseline;\n }\n}`;\n\nconst layerOrder = '@layer lobe-base, lobe-popup, lobe-ui;';\n\nlet cached: string | undefined;\n\nexport const getThemeCss = () =>\n (cached ??= [\n layerOrder,\n appearanceRule(\":root, [data-theme='light']\", 'light'),\n appearanceRule(\"[data-theme='dark']\", 'dark'),\n ...colorRules('light'),\n ...colorRules('dark'),\n ...localeFontRules(),\n essentialCss,\n ].join('\\n\\n'));\n\nexport const getGlobalCss = () => `${layerOrder}\\n\\n${globalCss}`;\n"],"mappings":";;;;;;;AASA,MAAM,KAAK,QAAgB,OAAO,aAAa,GAAG,EAAE;AAEpD,MAAM,OAAuC;CAC3C,MAAM;CACN,OAAO;AACT;AAIA,MAAM,UAA0D;CAC9D,MAAM;EACJ,sBAAsB,EAAE,oBAAoB;EAC5C,6BAA6B,EAAE,WAAW;EAC1C,wBAAwB;EACxB,wBAAwB,EAAE,qBAAqB;CACjD;CACA,OAAO;EACL,sBAAsB,EAAE,WAAW;EACnC,6BAA6B,sBAAsB,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE;EACrF,wBAAwB;EACxB,wBAAwB;CAC1B;AACF;AAEA,MAAM,QAAQ,UAAkB,iBAC9B,GAAG,SAAS,MAAM,OAAO,QAAQ,YAAY,CAAC,CAC3C,KAAK,CAAC,MAAM,WAAW,KAAK,KAAK,IAAI,MAAM,EAAE,CAAC,CAC9C,KAAK,IAAI,EAAE;AAEhB,MAAM,kBAAkB,UAAkB,eAA+B;CACvE,MAAM,EAAE,SAAS,SAAS,SAAS,QAAQ,SAAS,sBAAsB,EAAE,WAAW,CAAC;CACxF,MAAM,QACJ,eAAe,UACX;EAAE,GAAG;EAAM,GAAG;EAAS,GAAG;EAAS,GAAG;CAAQ,IA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;;;;;;aAMtB,EAAE,WAAW,EAAE;;;;;;wBAMJ,EAAE,oBAAoB,EAAE;;;;aAInC,EAAE,gBAAgB,EAAE;;;;aAIpB,EAAE,iBAAiB,EAAE;;;;eAInB,EAAE,gBAAgB,EAAE,SAAS,EAAE,oBAAoB,EAAE;;;;;;aAMvD,EAAE,mBAAmB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDpC,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmCM,EAAE,eAAe,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAgGxB,EAAE,gBAAgB,EAAE;;;;;;;qBAOlB,EAAE,gBAAgB,EAAE;;;;;;kBAMvB,EAAE,SAAS,EAAE;;;;;;uBAMR,EAAE,WAAW,EAAE;;;;;;AAOtC,MAAM,aAAa;AAEnB,IAAI;AAEJ,MAAa,oBACV,WAAW;CACV;CACA,eAAe,+BAA+B,OAAO;CACrD,eAAe,uBAAuB,MAAM;CAC5C,GAAG,WAAW,OAAO;CACrB,GAAG,WAAW,MAAM;CACpB,GAAG,gBAAgB;CACnB;AACF,CAAC,CAAC,KAAK,MAAM;AAEf,MAAa,qBAAqB,GAAG,WAAW,MAAM"}
@@ -1,64 +1,13 @@
1
+ import { genFontFamily, genFontFamilyCode } from "./font.mjs";
1
2
  // src/styles/theme/token/base.ts
2
- const joinFontFamily = (fonts) => fonts.map((font) => font.includes(" ") ? `"${font}"` : font).join(",");
3
- const FONT_EMOJI = [
4
- "/* EMOJI */",
5
- "Apple Color Emoji",
6
- "Segoe UI Emoji",
7
- "Segoe UI Symbol",
8
- "Noto Color Emoji"
9
- ];
10
- const FONT_EN = [
11
- "HarmonyOS Sans",
12
- "-apple-system",
13
- "BlinkMacSystemFont",
14
- "Segoe UI Variable Display",
15
- "Segoe UI",
16
- "Roboto",
17
- "Helvetica Neue",
18
- "Arial"
19
- ];
20
- const FONT_CN = [
21
- "/* SC */",
22
- "HarmonyOS Sans SC",
23
- "PingFang SC",
24
- "Hiragino Sans GB",
25
- "Microsoft YaHei UI",
26
- "Microsoft YaHei",
27
- "Source Han Sans SC",
28
- "Noto Sans CJK SC"
29
- ];
30
3
  const baseToken = {
31
4
  borderRadius: 8,
32
5
  borderRadiusLG: 12,
33
6
  borderRadiusSM: 6,
34
7
  borderRadiusXS: 4,
35
8
  controlHeight: 36,
36
- fontFamily: joinFontFamily([
37
- FONT_EN,
38
- FONT_CN,
39
- [
40
- "/* FALLBACK */",
41
- "ui-sans-serif",
42
- "system-ui",
43
- "sans-serif"
44
- ],
45
- FONT_EMOJI
46
- ].flat()),
47
- fontFamilyCode: joinFontFamily([
48
- [
49
- "Hack",
50
- "ui-monospace",
51
- "SFMono-Regular",
52
- "SF Mono",
53
- "Menlo",
54
- "Cascadia Code",
55
- "Consolas",
56
- "Liberation Mono"
57
- ],
58
- FONT_CN,
59
- ["/* FALLBACK */", "monospace"],
60
- FONT_EMOJI
61
- ].flat())
9
+ fontFamily: genFontFamily(),
10
+ fontFamilyCode: genFontFamilyCode()
62
11
  };
63
12
  export { baseToken };
64
13
 
@@ -1 +1 @@
1
- {"version":3,"file":"base.mjs","names":[],"sources":["../../../../src/styles/theme/token/base.ts"],"sourcesContent":["const joinFontFamily = (fonts: string[]) =>\n fonts.map((font) => (font.includes(' ') ? `\"${font}\"` : font)).join(',');\n\nconst FONT_EMOJI = [\n '/* EMOJI */',\n 'Apple Color Emoji',\n 'Segoe UI Emoji',\n 'Segoe UI Symbol',\n 'Noto Color Emoji',\n];\n\nconst FONT_EN = [\n 'HarmonyOS Sans',\n '-apple-system',\n 'BlinkMacSystemFont',\n 'Segoe UI Variable Display',\n 'Segoe UI',\n 'Roboto',\n 'Helvetica Neue',\n 'Arial',\n];\n\nconst FONT_CN = [\n '/* SC */',\n 'HarmonyOS Sans SC',\n 'PingFang SC',\n 'Hiragino Sans GB',\n 'Microsoft YaHei UI',\n 'Microsoft YaHei',\n 'Source Han Sans SC',\n 'Noto Sans CJK SC',\n];\n\nconst FONT_CODE = [\n 'Hack',\n 'ui-monospace',\n 'SFMono-Regular',\n 'SF Mono',\n 'Menlo',\n 'Cascadia Code',\n 'Consolas',\n 'Liberation Mono',\n];\n\nconst FALLBACK = ['/* FALLBACK */', 'ui-sans-serif', 'system-ui', 'sans-serif'];\n\nconst FALLBACK_CODE = ['/* FALLBACK */', 'monospace'];\n\nexport const baseToken = {\n borderRadius: 8,\n borderRadiusLG: 12,\n borderRadiusSM: 6,\n borderRadiusXS: 4,\n controlHeight: 36,\n fontFamily: joinFontFamily([FONT_EN, FONT_CN, FALLBACK, FONT_EMOJI].flat()),\n fontFamilyCode: joinFontFamily([FONT_CODE, FONT_CN, FALLBACK_CODE, FONT_EMOJI].flat()),\n};\n"],"mappings":";AAAA,MAAM,kBAAkB,UACtB,MAAM,KAAK,SAAU,KAAK,SAAS,GAAG,IAAI,IAAI,KAAK,KAAK,IAAK,CAAC,CAAC,KAAK,GAAG;AAEzE,MAAM,aAAa;CACjB;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,UAAU;CACd;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,UAAU;CACd;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAiBA,MAAa,YAAY;CACvB,cAAc;CACd,gBAAgB;CAChB,gBAAgB;CAChB,gBAAgB;CAChB,eAAe;CACf,YAAY,eAAe;EAAC;EAAS;EAAS;GAV9B;GAAkB;GAAiB;GAAa;EAUlB;EAAU;CAAU,CAAC,CAAC,KAAK,CAAC;CAC1E,gBAAgB,eAAe;EAAC;GArBhC;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EAcgC;EAAW;EAAS,CAT/B,kBAAkB,WASa;EAAe;CAAU,CAAC,CAAC,KAAK,CAAC;AACvF"}
1
+ {"version":3,"file":"base.mjs","names":[],"sources":["../../../../src/styles/theme/token/base.ts"],"sourcesContent":["import { genFontFamily, genFontFamilyCode } from './font';\n\nexport const baseToken = {\n borderRadius: 8,\n borderRadiusLG: 12,\n borderRadiusSM: 6,\n borderRadiusXS: 4,\n controlHeight: 36,\n fontFamily: genFontFamily(),\n fontFamilyCode: genFontFamilyCode(),\n};\n"],"mappings":";;AAEA,MAAa,YAAY;CACvB,cAAc;CACd,gBAAgB;CAChB,gBAAgB;CAChB,gBAAgB;CAChB,eAAe;CACf,YAAY,cAAc;CAC1B,gBAAgB,kBAAkB;AACpC"}