lkd-web-kit 0.10.2 → 0.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/.agents/skills/mantine-combobox/SKILL.md +73 -0
  2. package/.agents/skills/mantine-combobox/references/api.md +199 -0
  3. package/.agents/skills/mantine-combobox/references/patterns.md +279 -0
  4. package/.agents/skills/mantine-custom-components/SKILL.md +112 -0
  5. package/.agents/skills/mantine-custom-components/references/api.md +407 -0
  6. package/.agents/skills/mantine-custom-components/references/patterns.md +431 -0
  7. package/.agents/skills/publish-lkd-web-kit/SKILL.md +172 -0
  8. package/.agents/skills/publish-lkd-web-kit/agents/openai.yaml +4 -0
  9. package/.agents/skills/publish-lkd-web-kit/references/npm-trusted-publishing.md +82 -0
  10. package/.agents/skills/update-lkd-dependencies/SKILL.md +88 -0
  11. package/.agents/skills/update-lkd-dependencies/agents/openai.yaml +4 -0
  12. package/.agents/skills/update-lkd-dependencies/scripts/collect-npm-metadata.mjs +73 -0
  13. package/dist/index.cjs +2 -0
  14. package/dist/index.js +2 -1
  15. package/dist/mantine/breakpoints-with-px.cjs +3 -2
  16. package/dist/mantine/breakpoints-with-px.d.ts +2 -1
  17. package/dist/mantine/breakpoints-with-px.d.ts.map +1 -1
  18. package/dist/mantine/breakpoints-with-px.js +3 -2
  19. package/dist/mantine/create-lkd-theme.cjs +7 -0
  20. package/dist/mantine/create-lkd-theme.d.ts +3 -0
  21. package/dist/mantine/create-lkd-theme.d.ts.map +1 -0
  22. package/dist/mantine/create-lkd-theme.js +6 -0
  23. package/dist/mantine/index.d.ts +1 -0
  24. package/dist/mantine/index.d.ts.map +1 -1
  25. package/package.json +3 -3
  26. package/scripts/{install-codex-skills.mjs → install-agent-skills.mjs} +1 -1
  27. package/codex/skills/create-modal-component/SKILL.md +0 -168
  28. package/codex/skills/create-modal-component/agents/openai.yaml +0 -4
  29. package/codex/skills/create-svg-icon/SKILL.md +0 -41
  30. package/codex/skills/create-svg-icon/agents/openai.yaml +0 -3
  31. package/codex/skills/create-table-component/SKILL.md +0 -189
  32. package/codex/skills/create-table-component/agents/openai.yaml +0 -3
  33. package/codex/skills/rhf-lkd-forms/SKILL.md +0 -186
@@ -0,0 +1,407 @@
1
+ # Custom Components API Reference
2
+
3
+ ## Table of Contents
4
+ - [Imports cheatsheet](#imports-cheatsheet)
5
+ - [factory / polymorphicFactory / genericFactory](#factory--polymorphicfactory--genericfactory)
6
+ - [Factory type fields](#factory-type-fields)
7
+ - [useProps](#usepropss)
8
+ - [useStyles](#usestyles)
9
+ - [createVarsResolver](#createvarsresolver)
10
+ - [StylesApiProps and CompoundStylesApiProps](#stylesapiprops-and-compoundstylesapiprops)
11
+ - [BoxProps and ElementProps](#boxprops-and-elementprops)
12
+ - [createSafeContext](#createsafecontext)
13
+ - [Theme helper functions](#theme-helper-functions)
14
+ - [Static properties](#static-properties)
15
+
16
+ ---
17
+
18
+ ## Imports cheatsheet
19
+
20
+ ```ts
21
+ import {
22
+ // Factory functions
23
+ factory,
24
+ polymorphicFactory,
25
+ genericFactory,
26
+
27
+ // Types
28
+ Factory,
29
+ PolymorphicFactory,
30
+ StylesApiProps,
31
+ CompoundStylesApiProps,
32
+ BoxProps,
33
+ ElementProps,
34
+
35
+ // Hooks
36
+ useProps,
37
+ useStyles,
38
+
39
+ // Vars
40
+ createVarsResolver,
41
+
42
+ // Context
43
+ createSafeContext,
44
+
45
+ // Base component
46
+ Box,
47
+
48
+ // Theme helpers
49
+ getSize,
50
+ getSpacing,
51
+ getRadius,
52
+ getFontSize,
53
+ getLineHeight,
54
+ getShadow,
55
+ rem,
56
+ em,
57
+ } from '@mantine/core';
58
+ ```
59
+
60
+ ---
61
+
62
+ ## factory / polymorphicFactory / genericFactory
63
+
64
+ ### factory()
65
+
66
+ Standard factory for non-polymorphic components.
67
+
68
+ ```ts
69
+ factory<Payload extends FactoryPayload>(
70
+ ui: (props: Payload['props'] & { ref?: React.Ref<Payload['ref']> }) => React.ReactNode
71
+ ): MantineComponent<Payload>
72
+ ```
73
+
74
+ The returned component has static properties: `.extend()`, `.withProps()`, `.classes`, `.displayName`, `.varsResolver` (if vars are used), and any sub-components assigned.
75
+
76
+ ### polymorphicFactory()
77
+
78
+ For components that accept a `component` prop to render as a different element. Same signature as `factory()`, but uses `PolymorphicFactory` type.
79
+
80
+ ```ts
81
+ // Type uses PolymorphicFactory<{}> instead of Factory<{}>
82
+ export type MyFactory = PolymorphicFactory<{
83
+ props: MyProps;
84
+ defaultRef: HTMLButtonElement; // default ref type
85
+ defaultComponent: 'button'; // default element
86
+ stylesNames: ...;
87
+ vars: ...;
88
+ }>;
89
+
90
+ export const My = polymorphicFactory<MyFactory>((_props) => { ... });
91
+ ```
92
+
93
+ ### genericFactory()
94
+
95
+ For components whose prop types depend on a generic argument.
96
+
97
+ ```ts
98
+ // Factory uses 'signature' field
99
+ export type MyFactory = Factory<{
100
+ props: MyProps<boolean>;
101
+ signature: <T extends boolean = false>(props: MyProps<T>) => React.JSX.Element;
102
+ ref: HTMLDivElement;
103
+ // ... other fields
104
+ }>;
105
+
106
+ export const My = genericFactory<MyFactory>((_props) => { ... });
107
+ ```
108
+
109
+ ---
110
+
111
+ ## Factory type fields
112
+
113
+ All fields except `props` are optional.
114
+
115
+ ```ts
116
+ Factory<{
117
+ props: MyComponentProps;
118
+
119
+ // Forwarded ref element type
120
+ ref: HTMLDivElement;
121
+
122
+ // Union of Styles API selector strings (must match CSS module class names)
123
+ stylesNames: 'root' | 'label' | 'icon';
124
+
125
+ // CSS variables definition: { selectorName: '--var-name' | '--other-var' }
126
+ vars: {
127
+ root: '--my-height' | '--my-color';
128
+ label: '--my-label-fz';
129
+ };
130
+
131
+ // Accepted values for the variant prop
132
+ variant: 'filled' | 'outline' | 'subtle';
133
+
134
+ // Sub-components for compound pattern
135
+ staticComponents: {
136
+ Item: typeof MyItem;
137
+ Label: typeof MyLabel;
138
+ };
139
+
140
+ // Set to true for sub-components — disables theme classNames/styles/vars for this component
141
+ compound: true;
142
+
143
+ // Context type passed as 3rd argument to styles/vars resolvers
144
+ ctx: { opened: boolean };
145
+
146
+ // Generic signature (genericFactory only)
147
+ signature: <T extends boolean = false>(props: MyProps<T>) => React.JSX.Element;
148
+ }>
149
+ ```
150
+
151
+ ---
152
+
153
+ ## useProps
154
+
155
+ Merges default props from three sources in priority order (highest → lowest):
156
+ 1. Props passed by the user
157
+ 2. Default props from `MantineProvider` theme (`components.MyComponent.defaultProps`)
158
+ 3. Component-level `defaultProps`
159
+
160
+ ```ts
161
+ useProps<T extends Record<string, any>>(
162
+ componentName: string, // must match the name used in theme.components
163
+ defaultProps: Partial<T>, // use 'satisfies Partial<T>' for correct inference
164
+ props: T
165
+ ): T
166
+ ```
167
+
168
+ **Important:** Always call `useProps` before destructuring. Always use `satisfies Partial<Props>` (not `: Partial<Props>`) for `defaultProps` to preserve narrowed types.
169
+
170
+ ```ts
171
+ const defaultProps = { size: 'md', variant: 'filled' } satisfies Partial<MyProps>;
172
+
173
+ const props = useProps('MyComponent', defaultProps, _props);
174
+ const { className, style, classNames, styles, unstyled, vars, attributes, ...others } = props;
175
+ ```
176
+
177
+ ---
178
+
179
+ ## useStyles
180
+
181
+ Returns a `getStyles` function that provides `className` and `style` for each Styles API selector.
182
+
183
+ ```ts
184
+ useStyles<Payload extends FactoryPayload>(input: {
185
+ name: string | string[]; // component name(s) for static CSS class generation
186
+ classes: Record<string, string>; // CSS module classes object
187
+ props: Payload['props'];
188
+ stylesCtx?: Payload['ctx']; // optional context for styles/vars resolvers
189
+ className?: string; // spread to rootSelector
190
+ style?: MantineStyleProp; // spread to rootSelector
191
+ rootSelector?: string; // which selector gets className/style (default: 'root')
192
+ unstyled?: boolean;
193
+ classNames?: ClassNames<Payload>;
194
+ styles?: Styles<Payload>;
195
+ vars?: PartialVarsResolver<Payload>;
196
+ varsResolver?: VarsResolver<Payload>;
197
+ attributes?: Attributes<Payload>;
198
+ }): GetStylesApi<Payload>
199
+ ```
200
+
201
+ **`getStyles` function:**
202
+ ```ts
203
+ getStyles(
204
+ selector: StylesNames,
205
+ options?: {
206
+ className?: string; // additional className merged in
207
+ style?: CSSProperties; // additional style merged in
208
+ focusable?: boolean;
209
+ active?: boolean;
210
+ withStaticClass?: boolean;
211
+ }
212
+ ): { className: string; style: CSSProperties }
213
+ ```
214
+
215
+ Usage:
216
+ ```tsx
217
+ <Box {...getStyles('root')} {...others} />
218
+ <div {...getStyles('label', { className: cx(extraClass), style: { color: 'red' } })} />
219
+ ```
220
+
221
+ ---
222
+
223
+ ## createVarsResolver
224
+
225
+ Defines how component props map to CSS variables.
226
+
227
+ ```ts
228
+ createVarsResolver<Payload extends FactoryPayload>(
229
+ resolver: (
230
+ theme: MantineTheme,
231
+ props: Payload['props'],
232
+ ctx: Payload['ctx'] // only if Factory has ctx field
233
+ ) => TransformVars<Payload['vars']>
234
+ ): VarsResolver<Payload>
235
+ ```
236
+
237
+ The resolver must return an object matching the `vars` structure defined in `Factory`:
238
+
239
+ ```ts
240
+ // Factory vars: { root: '--my-height' | '--my-color' }
241
+ const varsResolver = createVarsResolver<MyFactory>((_theme, { size, color }) => ({
242
+ root: {
243
+ '--my-height': getSize(size, 'my-height'),
244
+ '--my-color': color ?? undefined, // undefined = CSS var not set (uses CSS fallback)
245
+ },
246
+ }));
247
+ ```
248
+
249
+ Assign to the component after creation:
250
+ ```ts
251
+ MyComponent.varsResolver = varsResolver;
252
+ ```
253
+
254
+ ---
255
+
256
+ ## StylesApiProps and CompoundStylesApiProps
257
+
258
+ **`StylesApiProps`** — extend on the root/main component's props interface:
259
+ ```ts
260
+ interface StylesApiProps<Payload extends FactoryPayload> {
261
+ unstyled?: boolean;
262
+ variant?: Payload['variant'] | (string & {});
263
+ classNames?: ClassNames<Payload>; // { root: 'my-class', inner: 'other' } or callback
264
+ styles?: Styles<Payload>; // { root: { color: 'red' } } or callback
265
+ vars?: PartialVarsResolver<Payload>; // (theme, props) => { root: { '--my-var': '...' } }
266
+ attributes?: Attributes<Payload>; // { root: { 'data-custom': value } }
267
+ }
268
+ ```
269
+
270
+ **`CompoundStylesApiProps`** — extend on sub-component (compound) props instead. Subset of `StylesApiProps` — no `unstyled` or `attributes`.
271
+
272
+ ```ts
273
+ interface CompoundStylesApiProps<Payload extends FactoryPayload>
274
+ extends Omit<StylesApiProps<Payload>, 'unstyled' | 'attributes'> {}
275
+ ```
276
+
277
+ Compound sub-components also use `Factory<{ ..., compound: true }>` and access styles via the parent context's `getStyles`.
278
+
279
+ ---
280
+
281
+ ## BoxProps and ElementProps
282
+
283
+ **`BoxProps`** — extends `MantineStyleProps`, adds:
284
+ ```ts
285
+ interface BoxProps extends MantineStyleProps {
286
+ className?: string;
287
+ style?: MantineStyleProp; // accepts function: (theme) => CSSProperties
288
+ mod?: string | Record<string, any> | (string | Record<string, any>)[]; // data-* attributes
289
+ hiddenFrom?: MantineBreakpoint; // hidden at this breakpoint and above
290
+ visibleFrom?: MantineBreakpoint; // visible only at this breakpoint and above
291
+ lightHidden?: boolean; // hidden in light color scheme
292
+ darkHidden?: boolean; // hidden in dark color scheme
293
+ }
294
+ ```
295
+
296
+ **`MantineStyleProps`** — shorthand style props (all accept responsive `{ base, sm, md, lg, xl }` objects):
297
+
298
+ | Prop | CSS property | Prop | CSS property |
299
+ |---|---|---|---|
300
+ | `m` `mt` `mb` `ml` `mr` `mx` `my` `ms` `me` | margin variants | `p` `pt` `pb` `pl` `pr` `px` `py` `ps` `pe` | padding variants |
301
+ | `w` `miw` `maw` | width | `h` `mih` `mah` | height |
302
+ | `c` | color | `bg` | background |
303
+ | `fz` | font-size | `fw` | font-weight |
304
+ | `ff` | font-family | `fs` | font-style |
305
+ | `lh` | line-height | `lts` | letter-spacing |
306
+ | `ta` | text-align | `tt` | text-transform |
307
+ | `td` | text-decoration | `bd` | border |
308
+ | `bdrs` | border-radius | `opacity` | opacity |
309
+ | `pos` | position | `top` `left` `bottom` `right` `inset` | positioning |
310
+ | `display` | display | `flex` | flex |
311
+
312
+ **`ElementProps`** — gets HTML element props, remapping `style` to Mantine's type:
313
+ ```ts
314
+ // Include all div props except style (remapped) and any conflicting props
315
+ interface MyProps extends ElementProps<'div'> {}
316
+
317
+ // Omit conflicting HTML attrs (e.g. input has native 'size' and 'color')
318
+ interface MyProps extends ElementProps<'input', 'size' | 'color'> {
319
+ size?: MantineSize;
320
+ color?: MantineColor;
321
+ }
322
+
323
+ // Can also accept a React component type instead of element string
324
+ interface MyProps extends ElementProps<typeof OtherComponent> {}
325
+ ```
326
+
327
+ ---
328
+
329
+ ## createSafeContext
330
+
331
+ Used inside compound components to share state from the parent to sub-components.
332
+
333
+ ```ts
334
+ createSafeContext<ContextValue>(
335
+ errorMessage: string // thrown when hook is used outside the provider
336
+ ): [
337
+ Context: React.Context<ContextValue | null>,
338
+ useContext: () => ContextValue // throws errorMessage if used outside provider
339
+ ]
340
+ ```
341
+
342
+ **Usage pattern (in ComponentName.context.ts):**
343
+ ```ts
344
+ import { createSafeContext, GetStylesApi } from '@mantine/core';
345
+ import { MyFactory } from './MyComponent';
346
+
347
+ interface MyContextValue {
348
+ getStyles: GetStylesApi<MyFactory>;
349
+ // other shared state...
350
+ }
351
+
352
+ export const [MyProvider, useMyContext] = createSafeContext<MyContextValue>(
353
+ 'MyComponent was not found in tree'
354
+ );
355
+ ```
356
+
357
+ In the root component:
358
+ ```tsx
359
+ return (
360
+ <MyProvider value={{ getStyles }}>
361
+ <Box {...getStyles('root')} {...others}>{children}</Box>
362
+ </MyProvider>
363
+ );
364
+ ```
365
+
366
+ In sub-components:
367
+ ```tsx
368
+ const { getStyles } = useMyContext();
369
+ return <div {...getStyles('item')} />;
370
+ ```
371
+
372
+ ---
373
+
374
+ ## Theme helper functions
375
+
376
+ Use these in `createVarsResolver` to convert Mantine size tokens to CSS values:
377
+
378
+ | Function | Input | Output example |
379
+ |---|---|---|
380
+ | `getSize(size, prefix)` | `'sm'`, `'button-height'` | `'var(--mantine-button-height-sm)'` |
381
+ | `getSpacing(size)` | `'md'` or `16` | `'var(--mantine-spacing-md)'` or `'1rem'` |
382
+ | `getRadius(size)` | `'sm'` or `4` | `'var(--mantine-radius-sm)'` or `'0.25rem'` |
383
+ | `getFontSize(size)` | `'sm'` | `'var(--mantine-font-size-sm)'` |
384
+ | `getLineHeight(size)` | `'sm'` | `'var(--mantine-line-height-sm)'` |
385
+ | `getShadow(size)` | `'md'` | `'var(--mantine-shadow-md)'` |
386
+ | `rem(value)` | `16` | `'1rem'` |
387
+ | `em(value)` | `16` | `'1em'` |
388
+
389
+ Return `undefined` from a var resolver entry to leave that CSS variable unset (CSS fallback applies).
390
+
391
+ ---
392
+
393
+ ## Static properties
394
+
395
+ These must be set on every component after creation:
396
+
397
+ ```ts
398
+ MyComponent.displayName = '@mantine/core/MyComponent'; // or '@mantine/package/Name'
399
+ MyComponent.classes = classes; // CSS module classes object
400
+ MyComponent.varsResolver = varsResolver; // only if component defines vars
401
+
402
+ // Sub-components (compound pattern)
403
+ MyComponent.Item = MyItem;
404
+ MyComponent.Label = MyLabel;
405
+ ```
406
+
407
+ `.extend()` and `.withProps()` are added automatically by `factory()`.