@yak/solid 0.0.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.
- package/LICENSE +21 -0
- package/README.md +126 -0
- package/dist/context/baseContext.d.ts +7 -0
- package/dist/context/baseContext.js +8 -0
- package/dist/context/baseContext.js.map +1 -0
- package/dist/context/index.d.ts +29 -0
- package/dist/context/index.js +17 -0
- package/dist/context/index.js.map +1 -0
- package/dist/index.d.ts +352 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/internal.d.ts +473 -0
- package/dist/internal.js +382 -0
- package/dist/internal.js.map +1 -0
- package/dist/isolated-source-eval/index.d.ts +30 -0
- package/dist/isolated-source-eval/index.js +315 -0
- package/dist/isolated-source-eval/index.js.map +1 -0
- package/dist/isolated-source-eval/worker.js +59 -0
- package/dist/isolated-source-eval/worker.js.map +1 -0
- package/dist/loaders/vite-plugin.d.ts +116 -0
- package/dist/loaders/vite-plugin.js +862 -0
- package/dist/loaders/vite-plugin.js.map +1 -0
- package/loaders/vite-plugin.ts +29 -0
- package/package.json +108 -0
- package/runtime/__tests__/mergeClasses.test.ts +22 -0
- package/runtime/__tests__/reactivity.test.tsx +157 -0
- package/runtime/__tests__/styled.test.tsx +270 -0
- package/runtime/__tests__/testUtils.tsx +25 -0
- package/runtime/__tests__/tsconfig.json +9 -0
- package/runtime/__tests__/typeTest.tsx +62 -0
- package/runtime/atoms.ts +44 -0
- package/runtime/context/baseContext.ts +5 -0
- package/runtime/context/index.ts +37 -0
- package/runtime/cssLiteral.ts +215 -0
- package/runtime/cssProp.ts +26 -0
- package/runtime/globalStyle.ts +54 -0
- package/runtime/index.ts +39 -0
- package/runtime/internal.ts +41 -0
- package/runtime/internals/mergeClasses.ts +36 -0
- package/runtime/internals/mergeCssProp.ts +54 -0
- package/runtime/internals/unitPostFix.ts +34 -0
- package/runtime/keyframes.ts +30 -0
- package/runtime/mocks/cssLiteral.ts +74 -0
- package/runtime/mocks/globalStyle.ts +14 -0
- package/runtime/mocks/keyframes.ts +29 -0
- package/runtime/mocks/styled.ts +8 -0
- package/runtime/publicStyledApi.ts +177 -0
- package/runtime/styled.ts +393 -0
- package/runtime/styledDom.ts +139 -0
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import { css, CSSInterpolation, Classes, yakComponentSymbol } from "./cssLiteral.js";
|
|
2
|
+
import type {
|
|
3
|
+
AnyComponent,
|
|
4
|
+
Attrs,
|
|
5
|
+
AttrsMerged,
|
|
6
|
+
Styled,
|
|
7
|
+
YakComponent,
|
|
8
|
+
AttrsFunction,
|
|
9
|
+
StyledFn,
|
|
10
|
+
HtmlTags,
|
|
11
|
+
Substitute,
|
|
12
|
+
StyledLiteral,
|
|
13
|
+
RuntimeStyleProcessor,
|
|
14
|
+
StyleObject,
|
|
15
|
+
} from "./publicStyledApi.js";
|
|
16
|
+
import { createMemo, merge } from "solid-js";
|
|
17
|
+
import { createComponent, Dynamic, type JSX } from "@solidjs/web";
|
|
18
|
+
import { normalizeClass } from "./internals/mergeClasses.js";
|
|
19
|
+
// the following import is not relative but the package-level "@yak/solid/context"
|
|
20
|
+
// export: it keeps a single context instance shared between the bundled runtime
|
|
21
|
+
// and user code (and lets the vite plugin alias the user's theme context)
|
|
22
|
+
import { useTheme } from "@yak/solid/context";
|
|
23
|
+
import type { YakTheme } from "./context/index.js";
|
|
24
|
+
import type { Accessor } from "solid-js";
|
|
25
|
+
|
|
26
|
+
//
|
|
27
|
+
// The `styled()` API without `styled.` syntax
|
|
28
|
+
//
|
|
29
|
+
// The API design is inspired by styled-components:
|
|
30
|
+
// https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/constructors/styled.tsx
|
|
31
|
+
// https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/models/StyledComponent.ts
|
|
32
|
+
//
|
|
33
|
+
/**
|
|
34
|
+
* Renders `props.component` (a tag name or component) with the remaining
|
|
35
|
+
* props. Loosely typed on purpose: the runtime passes lazily-merged Proxy
|
|
36
|
+
* props that no concrete component type can describe.
|
|
37
|
+
*/
|
|
38
|
+
const renderDynamic = (props: Record<PropertyKey, unknown>): JSX.Element =>
|
|
39
|
+
createComponent(Dynamic as (props: Record<PropertyKey, unknown>) => JSX.Element, props);
|
|
40
|
+
|
|
41
|
+
const styledFactory: StyledFn = (Component) =>
|
|
42
|
+
Object.assign(yakStyled(Component), {
|
|
43
|
+
attrs: (attrs: Attrs<any>) => yakStyled(Component, attrs),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The `styled` method works perfectly on all of your own or any third-party component,
|
|
48
|
+
* as long as they attach the passed `class` prop to a DOM element.
|
|
49
|
+
*
|
|
50
|
+
* @usage
|
|
51
|
+
*
|
|
52
|
+
* ```tsx
|
|
53
|
+
* const StyledLink = styled(Link)`
|
|
54
|
+
* color: #BF4F74;
|
|
55
|
+
* font-weight: bold;
|
|
56
|
+
* `;
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export const styled = styledFactory as Styled;
|
|
60
|
+
|
|
61
|
+
type PropsWithClassAndStyle = {
|
|
62
|
+
class?: string;
|
|
63
|
+
style?: StyleObject | string;
|
|
64
|
+
theme?: Accessor<YakTheme>;
|
|
65
|
+
} & Record<string, unknown>;
|
|
66
|
+
|
|
67
|
+
const yakStyled: StyledInternal = (Component, attrs) => {
|
|
68
|
+
// Probe with a property read, not the `in` operator: in dev, solid-refresh
|
|
69
|
+
// wraps registered components in a Proxy that forwards `get` to the live
|
|
70
|
+
// implementation but has no `has` trap, so `in` would miss the symbol and
|
|
71
|
+
// silently skip chain flattening (breaking attrs override order).
|
|
72
|
+
const isYakComponent =
|
|
73
|
+
typeof Component === "function" &&
|
|
74
|
+
(Component as Partial<YakComponent<unknown>>)[yakComponentSymbol] !== undefined;
|
|
75
|
+
|
|
76
|
+
// if the component that is wrapped is a yak component, we can extract the attrs function
|
|
77
|
+
// and the dynamic style function to merge it with the current attrs function (or dynamic
|
|
78
|
+
// style function) so that the sequence of the attrs functions is preserved
|
|
79
|
+
const [, parentAttrsFn, parentRuntimeStylesFn, parentTarget] = isYakComponent
|
|
80
|
+
? ((Component as YakComponent<unknown>)[yakComponentSymbol] as unknown as [
|
|
81
|
+
YakComponent<unknown>,
|
|
82
|
+
ExtractAttrsFunction<typeof attrs>,
|
|
83
|
+
RuntimeStyleProcessor<unknown>,
|
|
84
|
+
AnyComponent<any> | string,
|
|
85
|
+
])
|
|
86
|
+
: [];
|
|
87
|
+
|
|
88
|
+
// the ultimate render target of the whole styled(styled(...)) chain:
|
|
89
|
+
// attrs and style processors are already merged at construction time, so
|
|
90
|
+
// a chain of N levels renders the target directly in ONE component instead
|
|
91
|
+
// of re-entering every parent wrapper per element
|
|
92
|
+
const targetComponent = (isYakComponent ? parentTarget : Component) as AnyComponent<any> | string;
|
|
93
|
+
|
|
94
|
+
const mergedAttrsFn = buildRuntimeAttrsProcessor(attrs, parentAttrsFn);
|
|
95
|
+
|
|
96
|
+
return (styles, ...values) => {
|
|
97
|
+
// combine all interpolated logic into a single function
|
|
98
|
+
// e.g. styled.button`color: ${props => props.color}; margin: ${props => props.margin};`
|
|
99
|
+
const runtimeStylesFn = css(
|
|
100
|
+
styles,
|
|
101
|
+
...(values as CSSInterpolation<unknown>[]),
|
|
102
|
+
) as RuntimeStyleProcessor<unknown>;
|
|
103
|
+
const runtimeStyleProcessor = buildRuntimeStylesProcessor(
|
|
104
|
+
runtimeStylesFn,
|
|
105
|
+
parentRuntimeStylesFn,
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
// decided once per styled component: tag names render through Dynamic
|
|
109
|
+
// (which needs a `component` prop), component targets are called
|
|
110
|
+
// directly so a user prop named `component` reaches them (Dynamic
|
|
111
|
+
// would consume it). `targetProps` is merged BEFORE filterDomProps -
|
|
112
|
+
// the filter proxy must stay the outermost layer (see filterDomProps)
|
|
113
|
+
const isTag = typeof targetComponent === "string";
|
|
114
|
+
const targetProps = isTag ? { component: targetComponent } : {};
|
|
115
|
+
const renderTarget = isTag
|
|
116
|
+
? renderDynamic
|
|
117
|
+
: (finalProps: Record<PropertyKey, unknown>) =>
|
|
118
|
+
createComponent(
|
|
119
|
+
targetComponent as (props: Record<PropertyKey, unknown>) => JSX.Element,
|
|
120
|
+
finalProps,
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
// fast path for fully static components (no attrs, no dynamic styles;
|
|
124
|
+
// the most common case): contribute the chain's class names through a
|
|
125
|
+
// single reactive `class` getter and strip $-props; skips theme lookup,
|
|
126
|
+
// memo creation and style handling entirely
|
|
127
|
+
const Yak: AnyComponent<PropsWithClassAndStyle> =
|
|
128
|
+
!mergedAttrsFn && !runtimeStyleProcessor.$dynamic
|
|
129
|
+
? (props) =>
|
|
130
|
+
renderTarget(
|
|
131
|
+
filterDomProps(
|
|
132
|
+
merge(props, targetProps, {
|
|
133
|
+
// reading props.class inside the getter keeps the class
|
|
134
|
+
// binding reactive without re-creating the element
|
|
135
|
+
get class(): string | undefined {
|
|
136
|
+
const classes = new Classes(normalizeClass(props.class));
|
|
137
|
+
runtimeStyleProcessor(props, classes, undefined as unknown as StyleObject);
|
|
138
|
+
return classes.value || undefined;
|
|
139
|
+
},
|
|
140
|
+
}),
|
|
141
|
+
),
|
|
142
|
+
)
|
|
143
|
+
: (props) => {
|
|
144
|
+
// the component body runs ONCE in Solid: all per-update work
|
|
145
|
+
// lives in memos/getters so only the affected DOM bindings update
|
|
146
|
+
|
|
147
|
+
// attrs functions and dynamic style functions receive the theme;
|
|
148
|
+
// fully static components take the fast path above and never
|
|
149
|
+
// subscribe to the theme context
|
|
150
|
+
const theme = useTheme();
|
|
151
|
+
|
|
152
|
+
// getter-preserving merge: compiled prop functions like
|
|
153
|
+
// `({ $bottom }) => ...` destructure this proxy INSIDE the memo
|
|
154
|
+
// below, so every read is tracked at its use-site
|
|
155
|
+
const propsWithTheme = merge({ theme }, props) as PropsWithClassAndStyle & {
|
|
156
|
+
theme: Accessor<YakTheme>;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// The first component which is not wrapped in a yak component executes all attrs
|
|
160
|
+
// functions starting from the innermost yak component to the outermost (itself)
|
|
161
|
+
const attrsProps = mergedAttrsFn
|
|
162
|
+
? createMemo(() => mergedAttrsFn(propsWithTheme as any) as PropsWithClassAndStyle)
|
|
163
|
+
: undefined;
|
|
164
|
+
|
|
165
|
+
// input for the style processor: props + theme + attrs output
|
|
166
|
+
const styleInput = attrsProps ? merge(propsWithTheme, attrsProps) : propsWithTheme;
|
|
167
|
+
|
|
168
|
+
// execute all functions inside the style literal
|
|
169
|
+
// e.g. styled.button`color: ${props => props.color};`
|
|
170
|
+
// only reads inside this memo re-run it; the element itself is
|
|
171
|
+
// never re-created, only its class/style bindings update
|
|
172
|
+
const computed = createMemo(() => {
|
|
173
|
+
const attrsResult = attrsProps?.();
|
|
174
|
+
const classes = new Classes(normalizeClass(props.class));
|
|
175
|
+
const attrsClass = normalizeClass(attrsResult?.class);
|
|
176
|
+
if (attrsClass) {
|
|
177
|
+
classes.add(attrsClass);
|
|
178
|
+
}
|
|
179
|
+
// static processors never write style values, so the incoming
|
|
180
|
+
// style object can be passed through without a defensive copy
|
|
181
|
+
const style =
|
|
182
|
+
runtimeStyleProcessor.$dynamic || attrsResult?.style
|
|
183
|
+
? { ...unwrapStyle(props.style), ...unwrapStyle(attrsResult?.style) }
|
|
184
|
+
: unwrapStyle(props.style);
|
|
185
|
+
runtimeStyleProcessor(styleInput, classes, style as StyleObject);
|
|
186
|
+
return {
|
|
187
|
+
class: classes.value || undefined,
|
|
188
|
+
style: style && Object.keys(style).length > 0 ? style : undefined,
|
|
189
|
+
};
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
const merged = merge(props, attrsProps ?? {}, {
|
|
193
|
+
get class(): string | undefined {
|
|
194
|
+
return computed().class;
|
|
195
|
+
},
|
|
196
|
+
get style(): StyleObject | undefined {
|
|
197
|
+
return computed().style;
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// keep the theme prop only if an attrs function intentionally
|
|
202
|
+
// replaced it; the context theme itself never reaches the target
|
|
203
|
+
const allowTheme = () => {
|
|
204
|
+
const attrsResult = attrsProps?.();
|
|
205
|
+
return !!attrsResult && "theme" in attrsResult && attrsResult.theme !== theme;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// render the chain's target directly; parent wrappers contribute
|
|
209
|
+
// only their (already merged) attrs and style processors
|
|
210
|
+
return renderTarget(filterDomProps(merge(merged, targetProps), allowTheme));
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
return Object.assign(Yak, {
|
|
214
|
+
[yakComponentSymbol]: [Yak, mergedAttrsFn, runtimeStyleProcessor, targetComponent] as [
|
|
215
|
+
unknown,
|
|
216
|
+
unknown,
|
|
217
|
+
unknown,
|
|
218
|
+
unknown,
|
|
219
|
+
],
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Normalize a Solid style prop to an object the style processor can extend.
|
|
226
|
+
* Solid allows string styles on elements; they are converted here so CSS custom
|
|
227
|
+
* properties from dynamic values can be merged in (prefer object styles).
|
|
228
|
+
*/
|
|
229
|
+
const unwrapStyle = (style: StyleObject | string | undefined): StyleObject | undefined => {
|
|
230
|
+
if (typeof style !== "string") {
|
|
231
|
+
return style;
|
|
232
|
+
}
|
|
233
|
+
const result: Record<string, string> = {};
|
|
234
|
+
for (const declaration of style.split(";")) {
|
|
235
|
+
const colonIndex = declaration.indexOf(":");
|
|
236
|
+
if (colonIndex === -1) continue;
|
|
237
|
+
const property = declaration.slice(0, colonIndex).trim();
|
|
238
|
+
const value = declaration.slice(colonIndex + 1).trim();
|
|
239
|
+
if (property && value) {
|
|
240
|
+
result[property] = value;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return result as StyleObject;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const isBlockedProp = (key: PropertyKey, allowTheme?: () => boolean): boolean =>
|
|
247
|
+
typeof key === "string" &&
|
|
248
|
+
(key.startsWith("$") || (key === "theme" && !(allowTheme && allowTheme())));
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Remove all props that start with a $ sign (plus the internal theme) so
|
|
252
|
+
* they reach neither DOM elements nor custom components.
|
|
253
|
+
*
|
|
254
|
+
* Implemented as a lazy Proxy instead of an eager copy: Solid's compiled
|
|
255
|
+
* spread reads props through getters, and copying would read every prop
|
|
256
|
+
* exactly once and freeze its value, killing reactivity.
|
|
257
|
+
*/
|
|
258
|
+
const filterDomProps = <T extends object>(props: T, allowTheme?: () => boolean): T =>
|
|
259
|
+
new Proxy(props, {
|
|
260
|
+
get: (target, key) => (isBlockedProp(key, allowTheme) ? undefined : Reflect.get(target, key)),
|
|
261
|
+
has: (target, key) => !isBlockedProp(key, allowTheme) && Reflect.has(target, key),
|
|
262
|
+
ownKeys: (target) => Reflect.ownKeys(target).filter((key) => !isBlockedProp(key, allowTheme)),
|
|
263
|
+
getOwnPropertyDescriptor: (target, key) =>
|
|
264
|
+
isBlockedProp(key, allowTheme) ? undefined : Reflect.getOwnPropertyDescriptor(target, key),
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// util function to merge class names, as they are concatenated with a space
|
|
268
|
+
const mergeClasses = (a?: string, b?: string) => {
|
|
269
|
+
if (!a && !b) return undefined;
|
|
270
|
+
if (!a) return b;
|
|
271
|
+
if (!b) return a;
|
|
272
|
+
return a + " " + b;
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* merge props and processed props (including class names and styles)
|
|
277
|
+
* e.g.:\
|
|
278
|
+
* `{ class: "a", foo: 1 }` and `{ class: "b", bar: 2 }` \
|
|
279
|
+
* => `{ class: "a b", foo: 1, bar: 2 }`
|
|
280
|
+
*/
|
|
281
|
+
const combineProps = <
|
|
282
|
+
T extends {
|
|
283
|
+
class?: string;
|
|
284
|
+
style?: StyleObject | string;
|
|
285
|
+
},
|
|
286
|
+
TOther extends
|
|
287
|
+
| {
|
|
288
|
+
class?: string;
|
|
289
|
+
style?: StyleObject | string;
|
|
290
|
+
}
|
|
291
|
+
| null
|
|
292
|
+
| undefined,
|
|
293
|
+
>(
|
|
294
|
+
props: T,
|
|
295
|
+
newProps: TOther,
|
|
296
|
+
) =>
|
|
297
|
+
newProps
|
|
298
|
+
? (props.class === newProps.class || !newProps.class) &&
|
|
299
|
+
(props.style === newProps.style || !newProps.style)
|
|
300
|
+
? // shortcut if no style and class merging is necessary
|
|
301
|
+
{
|
|
302
|
+
...props,
|
|
303
|
+
...newProps,
|
|
304
|
+
}
|
|
305
|
+
: // merge class names and styles
|
|
306
|
+
{
|
|
307
|
+
...props,
|
|
308
|
+
...newProps,
|
|
309
|
+
class: mergeClasses(props.class, newProps.class),
|
|
310
|
+
style: { ...unwrapStyle(props.style), ...unwrapStyle(newProps.style) },
|
|
311
|
+
}
|
|
312
|
+
: // if no new props are provided, no merging is necessary
|
|
313
|
+
props;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Merges the attrs function of the current component with the attrs function of the parent component
|
|
317
|
+
* in order to preserve the sequence of the attrs functions.
|
|
318
|
+
* Note: In theory, the parentAttrsFn can have different types for TAttrsIn and TAttrsOut
|
|
319
|
+
* but as this is only used internally, we can ignore and simplify this case
|
|
320
|
+
* @param attrs The attrs object or function of the current component (if any)
|
|
321
|
+
* @param parentAttrsFn The attrs function of the parent/wrapped component (if any)
|
|
322
|
+
* @returns A function that receives the props and returns the transformed props
|
|
323
|
+
*/
|
|
324
|
+
const buildRuntimeAttrsProcessor = <
|
|
325
|
+
T,
|
|
326
|
+
TAttrsIn extends object,
|
|
327
|
+
TAttrsOut extends AttrsMerged<T, TAttrsIn>,
|
|
328
|
+
>(
|
|
329
|
+
attrs?: Attrs<T, TAttrsIn, TAttrsOut>,
|
|
330
|
+
parentAttrsFn?: AttrsFunction<T, TAttrsIn, TAttrsOut>,
|
|
331
|
+
): AttrsFunction<T, TAttrsIn, TAttrsOut> | undefined => {
|
|
332
|
+
const ownAttrsFn = attrs && (typeof attrs === "function" ? attrs : () => attrs);
|
|
333
|
+
|
|
334
|
+
if (ownAttrsFn && parentAttrsFn) {
|
|
335
|
+
return (props) => {
|
|
336
|
+
const parentProps = parentAttrsFn(props);
|
|
337
|
+
|
|
338
|
+
// overwrite and merge the parent props with the props received from the attrs function
|
|
339
|
+
// after they went through the parent attrs function.
|
|
340
|
+
//
|
|
341
|
+
// This makes sure the linearity of the attrs functions is preserved and all attrs function receive
|
|
342
|
+
// the whole props object calculated from the previous attrs functions
|
|
343
|
+
return combineProps(
|
|
344
|
+
parentProps as any,
|
|
345
|
+
ownAttrsFn(combineProps(props as any, parentProps as any) as any),
|
|
346
|
+
) as any;
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
return ownAttrsFn || parentAttrsFn;
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Merges the runtime style function of the current component with the runtime style function of the parent component
|
|
355
|
+
* in order to preserve the sequence of the attrs functions.
|
|
356
|
+
* @param runtimeStylesFn The current runtime styles function
|
|
357
|
+
* @param parentRuntimeStylesFn The parent runtime styles function
|
|
358
|
+
* @returns The merged runtime styles function
|
|
359
|
+
*/
|
|
360
|
+
const buildRuntimeStylesProcessor = <T>(
|
|
361
|
+
runtimeStylesFn: RuntimeStyleProcessor<T>,
|
|
362
|
+
parentRuntimeStylesFn?: RuntimeStyleProcessor<T>,
|
|
363
|
+
) => {
|
|
364
|
+
if (runtimeStylesFn && parentRuntimeStylesFn) {
|
|
365
|
+
const combined: RuntimeStyleProcessor<T> = Object.assign(
|
|
366
|
+
(props: T, classes: Parameters<RuntimeStyleProcessor<T>>[1], style: StyleObject) => {
|
|
367
|
+
parentRuntimeStylesFn(props, classes, style);
|
|
368
|
+
runtimeStylesFn(props, classes, style);
|
|
369
|
+
},
|
|
370
|
+
// the chain is dynamic if any level is dynamic
|
|
371
|
+
{ $dynamic: runtimeStylesFn.$dynamic || parentRuntimeStylesFn.$dynamic },
|
|
372
|
+
);
|
|
373
|
+
return combined;
|
|
374
|
+
}
|
|
375
|
+
return runtimeStylesFn || parentRuntimeStylesFn;
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Internal function where attrs are passed to be processed
|
|
380
|
+
*/
|
|
381
|
+
export type StyledInternal = <
|
|
382
|
+
T extends object,
|
|
383
|
+
TAttrsIn extends object = {},
|
|
384
|
+
TAttrsOut extends AttrsMerged<T, TAttrsIn> = AttrsMerged<T, TAttrsIn>,
|
|
385
|
+
>(
|
|
386
|
+
Component: AnyComponent<T> | YakComponent<T> | HtmlTags | string,
|
|
387
|
+
attrs?: Attrs<T, TAttrsIn, TAttrsOut>,
|
|
388
|
+
) => StyledLiteral<Substitute<T, TAttrsIn>>;
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Utility type to extract the AttrsFunction from the Attrs type
|
|
392
|
+
*/
|
|
393
|
+
export type ExtractAttrsFunction<T> = T extends (p: any) => any ? T : never;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { styled } from "./styled.js";
|
|
2
|
+
/// Internal API to create styled components
|
|
3
|
+
/// Optimization for faster rendering and smaller bundle size in production
|
|
4
|
+
/// thanks to better minification and dead code elimination
|
|
5
|
+
///
|
|
6
|
+
/// List taken from https://github.com/styled-components/styled-components/blob/e0019ba666fab4b5aaa2bff71ba6ad0005a299fd/packages/styled-components/src/utils/domElements.ts#L90
|
|
7
|
+
export const __yak_a = /*#__PURE__*/ styled("a");
|
|
8
|
+
export const __yak_abbr = /*#__PURE__*/ styled("abbr");
|
|
9
|
+
export const __yak_address = /*#__PURE__*/ styled("address");
|
|
10
|
+
export const __yak_area = /*#__PURE__*/ styled("area");
|
|
11
|
+
export const __yak_article = /*#__PURE__*/ styled("article");
|
|
12
|
+
export const __yak_aside = /*#__PURE__*/ styled("aside");
|
|
13
|
+
export const __yak_audio = /*#__PURE__*/ styled("audio");
|
|
14
|
+
export const __yak_b = /*#__PURE__*/ styled("b");
|
|
15
|
+
export const __yak_base = /*#__PURE__*/ styled("base");
|
|
16
|
+
export const __yak_bdi = /*#__PURE__*/ styled("bdi");
|
|
17
|
+
export const __yak_bdo = /*#__PURE__*/ styled("bdo");
|
|
18
|
+
export const __yak_big = /*#__PURE__*/ styled("big");
|
|
19
|
+
export const __yak_blockquote = /*#__PURE__*/ styled("blockquote");
|
|
20
|
+
export const __yak_body = /*#__PURE__*/ styled("body");
|
|
21
|
+
export const __yak_br = /*#__PURE__*/ styled("br");
|
|
22
|
+
export const __yak_button = /*#__PURE__*/ styled("button");
|
|
23
|
+
export const __yak_canvas = /*#__PURE__*/ styled("canvas");
|
|
24
|
+
export const __yak_caption = /*#__PURE__*/ styled("caption");
|
|
25
|
+
export const __yak_cite = /*#__PURE__*/ styled("cite");
|
|
26
|
+
export const __yak_code = /*#__PURE__*/ styled("code");
|
|
27
|
+
export const __yak_col = /*#__PURE__*/ styled("col");
|
|
28
|
+
export const __yak_colgroup = /*#__PURE__*/ styled("colgroup");
|
|
29
|
+
export const __yak_data = /*#__PURE__*/ styled("data");
|
|
30
|
+
export const __yak_datalist = /*#__PURE__*/ styled("datalist");
|
|
31
|
+
export const __yak_dd = /*#__PURE__*/ styled("dd");
|
|
32
|
+
export const __yak_del = /*#__PURE__*/ styled("del");
|
|
33
|
+
export const __yak_details = /*#__PURE__*/ styled("details");
|
|
34
|
+
export const __yak_dfn = /*#__PURE__*/ styled("dfn");
|
|
35
|
+
export const __yak_dialog = /*#__PURE__*/ styled("dialog");
|
|
36
|
+
export const __yak_div = /*#__PURE__*/ styled("div");
|
|
37
|
+
export const __yak_dl = /*#__PURE__*/ styled("dl");
|
|
38
|
+
export const __yak_dt = /*#__PURE__*/ styled("dt");
|
|
39
|
+
export const __yak_em = /*#__PURE__*/ styled("em");
|
|
40
|
+
export const __yak_embed = /*#__PURE__*/ styled("embed");
|
|
41
|
+
export const __yak_fieldset = /*#__PURE__*/ styled("fieldset");
|
|
42
|
+
export const __yak_figcaption = /*#__PURE__*/ styled("figcaption");
|
|
43
|
+
export const __yak_figure = /*#__PURE__*/ styled("figure");
|
|
44
|
+
export const __yak_footer = /*#__PURE__*/ styled("footer");
|
|
45
|
+
export const __yak_form = /*#__PURE__*/ styled("form");
|
|
46
|
+
export const __yak_h1 = /*#__PURE__*/ styled("h1");
|
|
47
|
+
export const __yak_h2 = /*#__PURE__*/ styled("h2");
|
|
48
|
+
export const __yak_h3 = /*#__PURE__*/ styled("h3");
|
|
49
|
+
export const __yak_h4 = /*#__PURE__*/ styled("h4");
|
|
50
|
+
export const __yak_h5 = /*#__PURE__*/ styled("h5");
|
|
51
|
+
export const __yak_h6 = /*#__PURE__*/ styled("h6");
|
|
52
|
+
export const __yak_header = /*#__PURE__*/ styled("header");
|
|
53
|
+
export const __yak_hgroup = /*#__PURE__*/ styled("hgroup");
|
|
54
|
+
export const __yak_hr = /*#__PURE__*/ styled("hr");
|
|
55
|
+
export const __yak_html = /*#__PURE__*/ styled("html");
|
|
56
|
+
export const __yak_i = /*#__PURE__*/ styled("i");
|
|
57
|
+
export const __yak_iframe = /*#__PURE__*/ styled("iframe");
|
|
58
|
+
export const __yak_img = /*#__PURE__*/ styled("img");
|
|
59
|
+
export const __yak_input = /*#__PURE__*/ styled("input");
|
|
60
|
+
export const __yak_ins = /*#__PURE__*/ styled("ins");
|
|
61
|
+
export const __yak_kbd = /*#__PURE__*/ styled("kbd");
|
|
62
|
+
export const __yak_keygen = /*#__PURE__*/ styled("keygen");
|
|
63
|
+
export const __yak_label = /*#__PURE__*/ styled("label");
|
|
64
|
+
export const __yak_legend = /*#__PURE__*/ styled("legend");
|
|
65
|
+
export const __yak_li = /*#__PURE__*/ styled("li");
|
|
66
|
+
export const __yak_link = /*#__PURE__*/ styled("link");
|
|
67
|
+
export const __yak_main = /*#__PURE__*/ styled("main");
|
|
68
|
+
export const __yak_map = /*#__PURE__*/ styled("map");
|
|
69
|
+
export const __yak_mark = /*#__PURE__*/ styled("mark");
|
|
70
|
+
export const __yak_menu = /*#__PURE__*/ styled("menu");
|
|
71
|
+
export const __yak_menuitem = /*#__PURE__*/ styled("menuitem");
|
|
72
|
+
export const __yak_meta = /*#__PURE__*/ styled("meta");
|
|
73
|
+
export const __yak_meter = /*#__PURE__*/ styled("meter");
|
|
74
|
+
export const __yak_nav = /*#__PURE__*/ styled("nav");
|
|
75
|
+
export const __yak_noscript = /*#__PURE__*/ styled("noscript");
|
|
76
|
+
export const __yak_object = /*#__PURE__*/ styled("object");
|
|
77
|
+
export const __yak_ol = /*#__PURE__*/ styled("ol");
|
|
78
|
+
export const __yak_optgroup = /*#__PURE__*/ styled("optgroup");
|
|
79
|
+
export const __yak_option = /*#__PURE__*/ styled("option");
|
|
80
|
+
export const __yak_output = /*#__PURE__*/ styled("output");
|
|
81
|
+
export const __yak_p = /*#__PURE__*/ styled("p");
|
|
82
|
+
export const __yak_param = /*#__PURE__*/ styled("param");
|
|
83
|
+
export const __yak_picture = /*#__PURE__*/ styled("picture");
|
|
84
|
+
export const __yak_pre = /*#__PURE__*/ styled("pre");
|
|
85
|
+
export const __yak_progress = /*#__PURE__*/ styled("progress");
|
|
86
|
+
export const __yak_q = /*#__PURE__*/ styled("q");
|
|
87
|
+
export const __yak_rp = /*#__PURE__*/ styled("rp");
|
|
88
|
+
export const __yak_rt = /*#__PURE__*/ styled("rt");
|
|
89
|
+
export const __yak_ruby = /*#__PURE__*/ styled("ruby");
|
|
90
|
+
export const __yak_s = /*#__PURE__*/ styled("s");
|
|
91
|
+
export const __yak_samp = /*#__PURE__*/ styled("samp");
|
|
92
|
+
export const __yak_script = /*#__PURE__*/ styled("script");
|
|
93
|
+
export const __yak_section = /*#__PURE__*/ styled("section");
|
|
94
|
+
export const __yak_select = /*#__PURE__*/ styled("select");
|
|
95
|
+
export const __yak_small = /*#__PURE__*/ styled("small");
|
|
96
|
+
export const __yak_source = /*#__PURE__*/ styled("source");
|
|
97
|
+
export const __yak_span = /*#__PURE__*/ styled("span");
|
|
98
|
+
export const __yak_strong = /*#__PURE__*/ styled("strong");
|
|
99
|
+
export const __yak_style = /*#__PURE__*/ styled("style");
|
|
100
|
+
export const __yak_sub = /*#__PURE__*/ styled("sub");
|
|
101
|
+
export const __yak_summary = /*#__PURE__*/ styled("summary");
|
|
102
|
+
export const __yak_sup = /*#__PURE__*/ styled("sup");
|
|
103
|
+
export const __yak_table = /*#__PURE__*/ styled("table");
|
|
104
|
+
export const __yak_tbody = /*#__PURE__*/ styled("tbody");
|
|
105
|
+
export const __yak_td = /*#__PURE__*/ styled("td");
|
|
106
|
+
export const __yak_textarea = /*#__PURE__*/ styled("textarea");
|
|
107
|
+
export const __yak_tfoot = /*#__PURE__*/ styled("tfoot");
|
|
108
|
+
export const __yak_th = /*#__PURE__*/ styled("th");
|
|
109
|
+
export const __yak_thead = /*#__PURE__*/ styled("thead");
|
|
110
|
+
export const __yak_time = /*#__PURE__*/ styled("time");
|
|
111
|
+
export const __yak_tr = /*#__PURE__*/ styled("tr");
|
|
112
|
+
export const __yak_track = /*#__PURE__*/ styled("track");
|
|
113
|
+
export const __yak_u = /*#__PURE__*/ styled("u");
|
|
114
|
+
export const __yak_ul = /*#__PURE__*/ styled("ul");
|
|
115
|
+
export const __yak_use = /*#__PURE__*/ styled("use");
|
|
116
|
+
export const __yak_var = /*#__PURE__*/ styled("var");
|
|
117
|
+
export const __yak_video = /*#__PURE__*/ styled("video");
|
|
118
|
+
export const __yak_wbr = /*#__PURE__*/ styled("wbr");
|
|
119
|
+
export const __yak_circle = /*#__PURE__*/ styled("circle");
|
|
120
|
+
export const __yak_clipPath = /*#__PURE__*/ styled("clipPath");
|
|
121
|
+
export const __yak_defs = /*#__PURE__*/ styled("defs");
|
|
122
|
+
export const __yak_ellipse = /*#__PURE__*/ styled("ellipse");
|
|
123
|
+
export const __yak_foreignObject = /*#__PURE__*/ styled("foreignObject");
|
|
124
|
+
export const __yak_g = /*#__PURE__*/ styled("g");
|
|
125
|
+
export const __yak_image = /*#__PURE__*/ styled("image");
|
|
126
|
+
export const __yak_line = /*#__PURE__*/ styled("line");
|
|
127
|
+
export const __yak_linearGradient = /*#__PURE__*/ styled("linearGradient");
|
|
128
|
+
export const __yak_marker = /*#__PURE__*/ styled("marker");
|
|
129
|
+
export const __yak_mask = /*#__PURE__*/ styled("mask");
|
|
130
|
+
export const __yak_path = /*#__PURE__*/ styled("path");
|
|
131
|
+
export const __yak_pattern = /*#__PURE__*/ styled("pattern");
|
|
132
|
+
export const __yak_polygon = /*#__PURE__*/ styled("polygon");
|
|
133
|
+
export const __yak_polyline = /*#__PURE__*/ styled("polyline");
|
|
134
|
+
export const __yak_radialGradient = /*#__PURE__*/ styled("radialGradient");
|
|
135
|
+
export const __yak_rect = /*#__PURE__*/ styled("rect");
|
|
136
|
+
export const __yak_stop = /*#__PURE__*/ styled("stop");
|
|
137
|
+
export const __yak_svg = /*#__PURE__*/ styled("svg");
|
|
138
|
+
export const __yak_text = /*#__PURE__*/ styled("text");
|
|
139
|
+
export const __yak_tspan = /*#__PURE__*/ styled("tspan");
|