@omerdlw/base-framework 3.4.1 → 4.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/dist/ambient/index.js +4 -5
- package/dist/background/index.js +3 -4
- package/dist/{chunk-DC4XZPDK.js → chunk-3FSDBJ7V.js} +4 -4
- package/dist/{chunk-DC4XZPDK.js.map → chunk-3FSDBJ7V.js.map} +1 -1
- package/dist/{chunk-GTJMM32W.js → chunk-5TQSH6KE.js} +6 -7
- package/dist/chunk-5TQSH6KE.js.map +1 -0
- package/dist/{chunk-DGVRHX3C.js → chunk-6P3F4JU3.js} +5 -6
- package/dist/{chunk-DGVRHX3C.js.map → chunk-6P3F4JU3.js.map} +1 -1
- package/dist/{chunk-3JLG24KI.js → chunk-AKPH5CEJ.js} +199 -9
- package/dist/chunk-AKPH5CEJ.js.map +1 -0
- package/dist/{chunk-KRHH3UQ6.js → chunk-AWLK2I56.js} +7 -8
- package/dist/{chunk-KRHH3UQ6.js.map → chunk-AWLK2I56.js.map} +1 -1
- package/dist/{chunk-M36DFIJ6.js → chunk-C527JOJQ.js} +4 -4
- package/dist/{chunk-M36DFIJ6.js.map → chunk-C527JOJQ.js.map} +1 -1
- package/dist/{chunk-E2QQJZYY.js → chunk-EXB7VFD3.js} +4 -4
- package/dist/{chunk-E2QQJZYY.js.map → chunk-EXB7VFD3.js.map} +1 -1
- package/dist/chunk-FG2AKFXP.js +108 -0
- package/dist/chunk-FG2AKFXP.js.map +1 -0
- package/dist/chunk-GA5SZ6E2.js +17 -0
- package/dist/{chunk-2E6OASVV.js.map → chunk-GA5SZ6E2.js.map} +1 -1
- package/dist/chunk-GG2ILNK2.js +44 -0
- package/dist/chunk-GG2ILNK2.js.map +1 -0
- package/dist/{chunk-VMR7ZKIF.js → chunk-JA75E4BG.js} +5 -5
- package/dist/{chunk-VMR7ZKIF.js.map → chunk-JA75E4BG.js.map} +1 -1
- package/dist/{chunk-BLWJZHRL.js → chunk-QZA5AIT6.js} +6 -9
- package/dist/chunk-QZA5AIT6.js.map +1 -0
- package/dist/{chunk-ST7QOM4O.js → chunk-T53WFIZN.js} +3 -3
- package/dist/{chunk-ST7QOM4O.js.map → chunk-T53WFIZN.js.map} +1 -1
- package/dist/{chunk-KN4KOTC7.js → chunk-WVED7PDH.js} +4 -4
- package/dist/{chunk-KN4KOTC7.js.map → chunk-WVED7PDH.js.map} +1 -1
- package/dist/{chunk-HPJWMBUS.js → chunk-XIFQMK2Z.js} +34 -37
- package/dist/chunk-XIFQMK2Z.js.map +1 -0
- package/dist/{chunk-7A47AXKI.js → chunk-YKHAFHB7.js} +4 -5
- package/dist/{chunk-7A47AXKI.js.map → chunk-YKHAFHB7.js.map} +1 -1
- package/dist/context-menu/index.js +7 -10
- package/dist/controls/index.js +3 -3
- package/dist/core/error/boundary.d.ts.map +1 -1
- package/dist/core/provider/index.d.ts +3 -8
- package/dist/core/provider/index.d.ts.map +1 -1
- package/dist/dock/index.js +6 -9
- package/dist/error/index.js +2 -5
- package/dist/foundation/recipes/index.d.ts +0 -7
- package/dist/foundation/recipes/index.d.ts.map +1 -1
- package/dist/index.js +15 -18
- package/dist/loading/index.js +2 -4
- package/dist/modal/index.js +10 -12
- package/dist/modal/index.js.map +1 -1
- package/dist/modules/dock/card/icon.d.ts.map +1 -1
- package/dist/modules/dock/card/use-card.d.ts +38 -38
- package/dist/modules/dock/media/controls.d.ts.map +1 -1
- package/dist/modules/dock/motion.d.ts +24 -24
- package/dist/modules/dock/status/model.d.ts.map +1 -1
- package/dist/modules/dock/surface/controls.d.ts.map +1 -1
- package/dist/modules/dock/surface/header-button.d.ts.map +1 -1
- package/dist/modules/dock/theme.d.ts +14 -14
- package/dist/modules/index.js +13 -16
- package/dist/modules/modal/container.d.ts.map +1 -1
- package/dist/notification/index.js +4 -4
- package/dist/overlay-ZCMQVNYT.js +12 -0
- package/dist/{overlay-YMLS3SAQ.js.map → overlay-ZCMQVNYT.js.map} +1 -1
- package/dist/provider/index.js +3 -8
- package/dist/react/theme/index.d.ts +7 -2
- package/dist/react/theme/index.d.ts.map +1 -1
- package/dist/react/theme/parts.d.ts +89 -0
- package/dist/react/theme/parts.d.ts.map +1 -0
- package/dist/recipes/index.js +1 -115
- package/dist/recipes/index.js.map +1 -1
- package/dist/theme/index.js +1 -1
- package/docs/README.md +11 -12
- package/docs/architecture-and-rules.md +8 -8
- package/docs/core-engine.md +11 -13
- package/docs/custom-modules.md +1 -1
- package/docs/design.md +60 -153
- package/docs/getting-started.md +3 -5
- package/docs/modules/README.md +1 -1
- package/docs/modules/background.md +1 -1
- package/docs/modules/context-menu.md +1 -1
- package/docs/modules/dock.md +23 -23
- package/docs/modules/error-boundary.md +1 -1
- package/docs/modules/loading.md +1 -1
- package/docs/modules/modal.md +1 -1
- package/package.json +1 -7
- package/templates/AGENTS.md +4 -3
- package/MIGRATION.md +0 -99
- package/dist/chunk-2E6OASVV.js +0 -17
- package/dist/chunk-3JLG24KI.js.map +0 -1
- package/dist/chunk-6LWCTP2Y.js +0 -448
- package/dist/chunk-6LWCTP2Y.js.map +0 -1
- package/dist/chunk-BLWJZHRL.js.map +0 -1
- package/dist/chunk-EBNZXYLT.js +0 -704
- package/dist/chunk-EBNZXYLT.js.map +0 -1
- package/dist/chunk-FLYL76ZT.js +0 -139
- package/dist/chunk-FLYL76ZT.js.map +0 -1
- package/dist/chunk-GTJMM32W.js.map +0 -1
- package/dist/chunk-HPJWMBUS.js.map +0 -1
- package/dist/chunk-ICFPSAJZ.js +0 -112
- package/dist/chunk-ICFPSAJZ.js.map +0 -1
- package/dist/chunk-S2ZOLTTS.js +0 -140
- package/dist/chunk-S2ZOLTTS.js.map +0 -1
- package/dist/foundation/recipes/anatomy.d.ts +0 -139
- package/dist/foundation/recipes/anatomy.d.ts.map +0 -1
- package/dist/foundation/recipes/define.d.ts +0 -133
- package/dist/foundation/recipes/define.d.ts.map +0 -1
- package/dist/overlay-YMLS3SAQ.js +0 -14
- package/dist/react/ui/components/avatar.d.ts +0 -10
- package/dist/react/ui/components/avatar.d.ts.map +0 -1
- package/dist/react/ui/components/button.d.ts +0 -6
- package/dist/react/ui/components/button.d.ts.map +0 -1
- package/dist/react/ui/components/carousel.d.ts +0 -27
- package/dist/react/ui/components/carousel.d.ts.map +0 -1
- package/dist/react/ui/components/checkbox.d.ts +0 -10
- package/dist/react/ui/components/checkbox.d.ts.map +0 -1
- package/dist/react/ui/components/icon.d.ts +0 -6
- package/dist/react/ui/components/icon.d.ts.map +0 -1
- package/dist/react/ui/components/image.d.ts +0 -6
- package/dist/react/ui/components/image.d.ts.map +0 -1
- package/dist/react/ui/components/indicator.d.ts +0 -55
- package/dist/react/ui/components/indicator.d.ts.map +0 -1
- package/dist/react/ui/components/input.d.ts +0 -10
- package/dist/react/ui/components/input.d.ts.map +0 -1
- package/dist/react/ui/components/loader.d.ts +0 -10
- package/dist/react/ui/components/loader.d.ts.map +0 -1
- package/dist/react/ui/components/segmented.d.ts +0 -6
- package/dist/react/ui/components/segmented.d.ts.map +0 -1
- package/dist/react/ui/components/select/options.d.ts +0 -22
- package/dist/react/ui/components/select/options.d.ts.map +0 -1
- package/dist/react/ui/components/select/select.d.ts +0 -6
- package/dist/react/ui/components/select/select.d.ts.map +0 -1
- package/dist/react/ui/components/skeleton.d.ts +0 -10
- package/dist/react/ui/components/skeleton.d.ts.map +0 -1
- package/dist/react/ui/components/switch.d.ts +0 -6
- package/dist/react/ui/components/switch.d.ts.map +0 -1
- package/dist/react/ui/components/tooltip/group.d.ts +0 -35
- package/dist/react/ui/components/tooltip/group.d.ts.map +0 -1
- package/dist/react/ui/components/tooltip/placement.d.ts +0 -42
- package/dist/react/ui/components/tooltip/placement.d.ts.map +0 -1
- package/dist/react/ui/components/tooltip/slot.d.ts +0 -23
- package/dist/react/ui/components/tooltip/slot.d.ts.map +0 -1
- package/dist/react/ui/components/tooltip/tooltip.d.ts +0 -13
- package/dist/react/ui/components/tooltip/tooltip.d.ts.map +0 -1
- package/dist/react/ui/index.d.ts +0 -20
- package/dist/react/ui/index.d.ts.map +0 -1
- package/dist/react/ui/provider.d.ts +0 -22
- package/dist/react/ui/provider.d.ts.map +0 -1
- package/dist/react/ui/types.d.ts +0 -341
- package/dist/react/ui/types.d.ts.map +0 -1
- package/dist/ui/index.d.ts +0 -1
- package/dist/ui/index.js +0 -2259
- package/dist/ui/index.js.map +0 -1
package/dist/modules/index.js
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { defaultModules } from '../chunk-
|
|
2
|
+
export { defaultModules } from '../chunk-GA5SZ6E2.js';
|
|
3
|
+
export { contextMenuModule } from '../chunk-AWLK2I56.js';
|
|
4
|
+
export { controlsModule } from '../chunk-C527JOJQ.js';
|
|
5
|
+
export { dockModule } from '../chunk-XIFQMK2Z.js';
|
|
6
|
+
export { notificationModule } from '../chunk-JA75E4BG.js';
|
|
7
|
+
export { loadingModule } from '../chunk-YKHAFHB7.js';
|
|
8
|
+
export { modalModule } from '../chunk-3FSDBJ7V.js';
|
|
9
|
+
import '../chunk-WVED7PDH.js';
|
|
10
|
+
import '../chunk-T53WFIZN.js';
|
|
3
11
|
export { navigationModule } from '../chunk-DMQKXBWO.js';
|
|
4
|
-
export { ambientModule } from '../chunk-E2QQJZYY.js';
|
|
5
|
-
export { backgroundModule } from '../chunk-DGVRHX3C.js';
|
|
6
|
-
export { contextMenuModule } from '../chunk-KRHH3UQ6.js';
|
|
7
|
-
export { controlsModule } from '../chunk-M36DFIJ6.js';
|
|
8
|
-
export { dockModule } from '../chunk-HPJWMBUS.js';
|
|
9
12
|
import '../chunk-UWX7GCNX.js';
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
13
|
+
export { ambientModule } from '../chunk-EXB7VFD3.js';
|
|
14
|
+
export { backgroundModule } from '../chunk-6P3F4JU3.js';
|
|
12
15
|
export { mediaModule } from '../chunk-C3SEBNF5.js';
|
|
13
|
-
|
|
14
|
-
import '../chunk-KN4KOTC7.js';
|
|
15
|
-
import '../chunk-EBNZXYLT.js';
|
|
16
|
-
import '../chunk-ST7QOM4O.js';
|
|
16
|
+
import '../chunk-GG2ILNK2.js';
|
|
17
17
|
import '../chunk-ED32WLAD.js';
|
|
18
18
|
import '../chunk-JWUKAZ3A.js';
|
|
19
|
-
import '../chunk-
|
|
20
|
-
import '../chunk-6LWCTP2Y.js';
|
|
21
|
-
import '../chunk-ICFPSAJZ.js';
|
|
22
|
-
import '../chunk-3JLG24KI.js';
|
|
19
|
+
import '../chunk-AKPH5CEJ.js';
|
|
23
20
|
import '../chunk-S67HGKJ2.js';
|
|
24
21
|
import '../chunk-J3VTDBC6.js';
|
|
25
22
|
import '../chunk-YHWA7FXX.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../src/modules/modal/container.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../src/modules/modal/container.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAGV,mBAAmB,EAEpB,MAAM,SAAS,CAAC;AAUjB;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAC7B,aAAa,EACb,QAAQ,EACR,SAAS,EACT,KAAK,EACL,MAAM,EACN,MAAW,EACX,QAAe,GAChB,EAAE,mBAAmB,+BA+DrB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { DOCK_STACK_ELEMENT_ID, INERT_NOTIFICATION_ACTIONS, INITIAL_NOTIFICATION_STATE, NOOP_NOTIFICATION_STORE, NotificationContext, NotificationListener, NotificationProvider, SESSION_EXPIRED_MESSAGE, TOAST_DURATIONS, createNotificationEntry, getActiveNotification, getOutcomeMessage, isNotificationDataObject, normalizeDuration, normalizeFeedbackText, normalizeToastOptions, notificationModule, notificationTheme, useNotification, useNotificationActions, useNotificationContainerModel, useNotificationState, useNotificationVisible, useOptionalNotificationActions, useOptionalNotificationState, useToast, withDefaultDuration } from '../chunk-
|
|
3
|
-
import '../chunk-
|
|
2
|
+
export { DOCK_STACK_ELEMENT_ID, INERT_NOTIFICATION_ACTIONS, INITIAL_NOTIFICATION_STATE, NOOP_NOTIFICATION_STORE, NotificationContext, NotificationListener, NotificationProvider, SESSION_EXPIRED_MESSAGE, TOAST_DURATIONS, createNotificationEntry, getActiveNotification, getOutcomeMessage, isNotificationDataObject, normalizeDuration, normalizeFeedbackText, normalizeToastOptions, notificationModule, notificationTheme, useNotification, useNotificationActions, useNotificationContainerModel, useNotificationState, useNotificationVisible, useOptionalNotificationActions, useOptionalNotificationState, useToast, withDefaultDuration } from '../chunk-JA75E4BG.js';
|
|
3
|
+
import '../chunk-T53WFIZN.js';
|
|
4
|
+
import '../chunk-GG2ILNK2.js';
|
|
4
5
|
import '../chunk-ED32WLAD.js';
|
|
5
6
|
import '../chunk-JWUKAZ3A.js';
|
|
6
|
-
import '../chunk-
|
|
7
|
-
import '../chunk-3JLG24KI.js';
|
|
7
|
+
import '../chunk-AKPH5CEJ.js';
|
|
8
8
|
import '../chunk-S67HGKJ2.js';
|
|
9
9
|
import '../chunk-J3VTDBC6.js';
|
|
10
10
|
import '../chunk-YHWA7FXX.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { Modal } from './chunk-5TQSH6KE.js';
|
|
2
|
+
import './chunk-WVED7PDH.js';
|
|
3
|
+
import './chunk-T53WFIZN.js';
|
|
4
|
+
import './chunk-GG2ILNK2.js';
|
|
5
|
+
import './chunk-ED32WLAD.js';
|
|
6
|
+
import './chunk-JWUKAZ3A.js';
|
|
7
|
+
import './chunk-AKPH5CEJ.js';
|
|
8
|
+
import './chunk-S67HGKJ2.js';
|
|
9
|
+
import './chunk-J3VTDBC6.js';
|
|
10
|
+
import './chunk-YHWA7FXX.js';
|
|
11
|
+
//# sourceMappingURL=overlay-ZCMQVNYT.js.map
|
|
12
|
+
//# sourceMappingURL=overlay-ZCMQVNYT.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"overlay-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"overlay-ZCMQVNYT.js"}
|
package/dist/provider/index.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { CoreProvider } from '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-EBNZXYLT.js';
|
|
5
|
-
import '../chunk-ST7QOM4O.js';
|
|
2
|
+
export { CoreProvider } from '../chunk-FG2AKFXP.js';
|
|
3
|
+
import '../chunk-QZA5AIT6.js';
|
|
6
4
|
import '../chunk-ED32WLAD.js';
|
|
7
5
|
import '../chunk-JWUKAZ3A.js';
|
|
8
|
-
import '../chunk-
|
|
9
|
-
import '../chunk-6LWCTP2Y.js';
|
|
10
|
-
import '../chunk-ICFPSAJZ.js';
|
|
11
|
-
import '../chunk-3JLG24KI.js';
|
|
6
|
+
import '../chunk-AKPH5CEJ.js';
|
|
12
7
|
import '../chunk-S67HGKJ2.js';
|
|
13
8
|
import '../chunk-J3VTDBC6.js';
|
|
14
9
|
import '../chunk-YHWA7FXX.js';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode } from "react";
|
|
2
2
|
import { type MotionTokens } from "../../foundation/utils/tempo";
|
|
3
|
+
import { type ThemeComponents, type ThemeIcons } from "./parts";
|
|
4
|
+
export { type FrameworkIcon, type ThemeButtonProps, type ThemeComponents, ThemeButton, ThemeIcon, type ThemeIconProps, type ThemeIcons, ThemeSpinner, type ThemeSpinnerProps, ThemeTooltip, type ThemeTooltipProps, useIconName, useThemeComponents, } from "./parts";
|
|
3
5
|
/**
|
|
4
6
|
* A theme's identity and, through its type parameters, its slot names and motion shape.
|
|
5
7
|
*/
|
|
@@ -46,13 +48,17 @@ export declare function defineThemeSpec<S extends string, M = never>(id: string)
|
|
|
46
48
|
export declare function defineTheme<S extends string, M = never>(spec: ThemeSpec<S, M>, config: ThemeConfig<NoInfer<S>, NoInfer<M>>): ThemeEntry;
|
|
47
49
|
interface ThemeProviderProps {
|
|
48
50
|
children?: ReactNode;
|
|
51
|
+
/** The button, icon, spinner and tooltip the modules draw with. */
|
|
52
|
+
components?: Partial<ThemeComponents>;
|
|
53
|
+
/** The app's icon name for each icon the framework's modules show. */
|
|
54
|
+
icons?: ThemeIcons;
|
|
49
55
|
motion?: MotionTokens;
|
|
50
56
|
themes: readonly ThemeEntry[];
|
|
51
57
|
}
|
|
52
58
|
/**
|
|
53
59
|
* Provides themes, and motion tokens when given, to the tree below it.
|
|
54
60
|
*/
|
|
55
|
-
export declare function ThemeProvider({ children, motion, themes, }: ThemeProviderProps): import("react").JSX.Element;
|
|
61
|
+
export declare function ThemeProvider({ children, components, icons, motion, themes, }: ThemeProviderProps): import("react").JSX.Element;
|
|
56
62
|
/**
|
|
57
63
|
* Returns the slot classes and styles configured for a theme spec.
|
|
58
64
|
*/
|
|
@@ -78,5 +84,4 @@ interface ModuleMotionConfigProps {
|
|
|
78
84
|
* Applies the motion tokens' reduced-motion policy to motion components below it.
|
|
79
85
|
*/
|
|
80
86
|
export declare function ModuleMotionConfig({ children }: ModuleMotionConfigProps): import("react").JSX.Element;
|
|
81
|
-
export {};
|
|
82
87
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/theme/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAgB,MAAM,OAAO,CAAC;AAGzE,OAAO,EAGL,KAAK,YAAY,EAGlB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/theme/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAgB,MAAM,OAAO,CAAC;AAGzE,OAAO,EAGL,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GAC1B,aAAa,CAAC,CAAC,CAAC,CAOlB;AAQD;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,KAAK,CAAC,GAAG;IAC5E,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B,CAOA;AAUD;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAUhE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EACvC,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,GACzB,CAAC,GAAG,IAAI,CAKV;AAID,UAAU,uBAAuB;IAC/B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,EAAE,uBAAuB,+BAKvE"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes, type ComponentType, type CSSProperties, type MouseEventHandler, type ReactElement, type ReactNode, type Ref } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Props a module passes to the app's button. Module buttons carry no variant:
|
|
4
|
+
* the look comes from the module theme's slot in `className`.
|
|
5
|
+
*/
|
|
6
|
+
export interface ThemeButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
7
|
+
[data: `data-${string}`]: string | number | boolean | undefined;
|
|
8
|
+
ref?: Ref<HTMLButtonElement>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Props a module passes to the app's icon: an icon name (the app's own, or
|
|
12
|
+
* one of the framework's keys already resolved through `icons`) and a size in px.
|
|
13
|
+
*/
|
|
14
|
+
export interface ThemeIconProps {
|
|
15
|
+
className?: string;
|
|
16
|
+
color?: string;
|
|
17
|
+
icon: string;
|
|
18
|
+
onClick?: MouseEventHandler<HTMLElement>;
|
|
19
|
+
size?: number;
|
|
20
|
+
style?: CSSProperties;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Props a module passes to the app's spinner.
|
|
24
|
+
*/
|
|
25
|
+
export interface ThemeSpinnerProps {
|
|
26
|
+
className?: string;
|
|
27
|
+
size?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Props a module passes to the app's tooltip; `children` is the trigger.
|
|
31
|
+
*/
|
|
32
|
+
export interface ThemeTooltipProps {
|
|
33
|
+
children: ReactElement;
|
|
34
|
+
className?: string;
|
|
35
|
+
sideOffset?: number;
|
|
36
|
+
text?: ReactNode;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The components the modules draw with. Each one is optional: without it a
|
|
40
|
+
* module renders a plain `<button>`, no icon, no spinner and no tooltip.
|
|
41
|
+
*/
|
|
42
|
+
export interface ThemeComponents {
|
|
43
|
+
Button: ComponentType<ThemeButtonProps>;
|
|
44
|
+
Icon: ComponentType<ThemeIconProps>;
|
|
45
|
+
Spinner: ComponentType<ThemeSpinnerProps>;
|
|
46
|
+
Tooltip: ComponentType<ThemeTooltipProps>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The icons the framework's own modules show, by key. The app maps each key
|
|
50
|
+
* to an icon name its `Icon` understands; an unmapped key draws nothing.
|
|
51
|
+
*/
|
|
52
|
+
export type FrameworkIcon = "back" | "close" | "danger" | "error" | "forbidden" | "forward" | "next" | "pause" | "pip" | "play" | "repeat" | "rewind" | "volumeLoud" | "volumeMuted" | "volumeSmall" | "wifi" | "wifiOff";
|
|
53
|
+
/**
|
|
54
|
+
* The app's icon name for each framework icon key.
|
|
55
|
+
*/
|
|
56
|
+
export type ThemeIcons = Readonly<Partial<Record<FrameworkIcon, string>>>;
|
|
57
|
+
export declare const ComponentsContext: import("react").Context<ThemeComponents>;
|
|
58
|
+
export declare const IconsContext: import("react").Context<Readonly<Partial<Record<FrameworkIcon, string>>>>;
|
|
59
|
+
/**
|
|
60
|
+
* Merges the app's components over the plain ones (or over the ones a parent
|
|
61
|
+
* provider already set).
|
|
62
|
+
*/
|
|
63
|
+
export declare function mergeComponents(parent: ThemeComponents, own: Partial<ThemeComponents> | undefined): ThemeComponents;
|
|
64
|
+
/**
|
|
65
|
+
* The components the modules draw with.
|
|
66
|
+
*/
|
|
67
|
+
export declare function useThemeComponents(): ThemeComponents;
|
|
68
|
+
/**
|
|
69
|
+
* Resolves a framework icon key to the app's icon name; any other string (an
|
|
70
|
+
* icon name the app gave a module) passes through unchanged.
|
|
71
|
+
*/
|
|
72
|
+
export declare function useIconName(): (source: string) => string;
|
|
73
|
+
/**
|
|
74
|
+
* Draws an icon by name or framework key with the app's `Icon`.
|
|
75
|
+
*/
|
|
76
|
+
export declare function ThemeIcon({ icon, ...props }: ThemeIconProps): import("react").JSX.Element;
|
|
77
|
+
/**
|
|
78
|
+
* Draws a module button with the app's `Button`.
|
|
79
|
+
*/
|
|
80
|
+
export declare function ThemeButton(props: ThemeButtonProps): import("react").JSX.Element;
|
|
81
|
+
/**
|
|
82
|
+
* Draws a spinner with the app's `Spinner`.
|
|
83
|
+
*/
|
|
84
|
+
export declare function ThemeSpinner(props: ThemeSpinnerProps): import("react").JSX.Element;
|
|
85
|
+
/**
|
|
86
|
+
* Wraps a trigger in the app's `Tooltip`.
|
|
87
|
+
*/
|
|
88
|
+
export declare function ThemeTooltip(props: ThemeTooltipProps): import("react").JSX.Element;
|
|
89
|
+
//# sourceMappingURL=parts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../../../src/react/theme/parts.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,GAAG,EAET,MAAM,OAAO,CAAC;AAQf;;;GAGG;AACH,MAAM,WAAW,gBAAiB,SAAQ,oBAAo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AEd;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;AAqB1E,eAAO,MAAM,iBAAiB,0CAG7B,CAAC;AAEF,eAAO,MAAM,YAAY,2EAGxB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,eAAe,EACvB,GAAG,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,SAAS,GACxC,eAAe,CAEjB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,CAEpD;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAGxD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,+BAI3D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,+BAGlD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,+BAGpD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,+BAGpD"}
|
package/dist/recipes/index.js
CHANGED
|
@@ -91,79 +91,6 @@ function appendClasses(value, out) {
|
|
|
91
91
|
return next;
|
|
92
92
|
}
|
|
93
93
|
var joinClasses = (...inputs) => appendClasses(inputs, "");
|
|
94
|
-
|
|
95
|
-
// src/foundation/recipes/anatomy.ts
|
|
96
|
-
var part = () => defineRecipe({});
|
|
97
|
-
var flag = { false: "", true: "" };
|
|
98
|
-
var layout = { fill: "", intrinsic: "" };
|
|
99
|
-
var ANATOMY = {
|
|
100
|
-
button: {
|
|
101
|
-
root: defineRecipe({ variants: { intent: {} } }),
|
|
102
|
-
bare: part(),
|
|
103
|
-
busy: part(),
|
|
104
|
-
busyLabel: part(),
|
|
105
|
-
busySpinner: part()
|
|
106
|
-
},
|
|
107
|
-
input: { field: part(), area: part() },
|
|
108
|
-
switch: { track: part(), thumb: part() },
|
|
109
|
-
checkbox: {
|
|
110
|
-
root: part(),
|
|
111
|
-
box: defineRecipe({ variants: { checked: flag } }),
|
|
112
|
-
glyph: defineRecipe({ variants: { checked: flag } })
|
|
113
|
-
},
|
|
114
|
-
segmented: {
|
|
115
|
-
root: part(),
|
|
116
|
-
segment: defineRecipe({ variants: { active: flag } }),
|
|
117
|
-
pill: part(),
|
|
118
|
-
chosen: part(),
|
|
119
|
-
icon: part(),
|
|
120
|
-
count: part()
|
|
121
|
-
},
|
|
122
|
-
select: {
|
|
123
|
-
root: part(),
|
|
124
|
-
trigger: part(),
|
|
125
|
-
value: part(),
|
|
126
|
-
label: part(),
|
|
127
|
-
placeholder: part(),
|
|
128
|
-
chevron: part(),
|
|
129
|
-
menu: part(),
|
|
130
|
-
option: part(),
|
|
131
|
-
highlight: part(),
|
|
132
|
-
optionBody: part(),
|
|
133
|
-
text: part(),
|
|
134
|
-
description: part(),
|
|
135
|
-
icon: part(),
|
|
136
|
-
check: part(),
|
|
137
|
-
empty: part()
|
|
138
|
-
},
|
|
139
|
-
carousel: {
|
|
140
|
-
root: part(),
|
|
141
|
-
track: part(),
|
|
142
|
-
slide: part(),
|
|
143
|
-
arrow: defineRecipe({
|
|
144
|
-
variants: { side: { left: "", right: "" }, visible: flag }
|
|
145
|
-
}),
|
|
146
|
-
icon: part()
|
|
147
|
-
},
|
|
148
|
-
tooltip: { content: part(), label: part() },
|
|
149
|
-
loader: {
|
|
150
|
-
root: defineRecipe({ variants: { over: flag } }),
|
|
151
|
-
label: part(),
|
|
152
|
-
overlay: part(),
|
|
153
|
-
dots: part(),
|
|
154
|
-
dot: part(),
|
|
155
|
-
spinner: part(),
|
|
156
|
-
icon: part()
|
|
157
|
-
},
|
|
158
|
-
skeleton: { block: part(), lines: part(), line: part(), bar: part() },
|
|
159
|
-
image: {
|
|
160
|
-
frame: defineRecipe({ variants: { layout, loading: flag } }),
|
|
161
|
-
picture: defineRecipe({ variants: { layout } }),
|
|
162
|
-
fallback: part()
|
|
163
|
-
},
|
|
164
|
-
avatar: { root: part(), image: part(), initials: part() },
|
|
165
|
-
highlight: { fill: part() }
|
|
166
|
-
};
|
|
167
94
|
function createCn(vocabulary = {}) {
|
|
168
95
|
const merge = extendTailwindMerge({
|
|
169
96
|
extend: {
|
|
@@ -180,47 +107,6 @@ function createCn(vocabulary = {}) {
|
|
|
180
107
|
}
|
|
181
108
|
var cn = createCn();
|
|
182
109
|
|
|
183
|
-
// src/foundation/recipes/define.ts
|
|
184
|
-
var DEFAULT_LABELS = {
|
|
185
|
-
loading: "Loading",
|
|
186
|
-
placeholder: "Select an option...",
|
|
187
|
-
empty: "No options available",
|
|
188
|
-
previous: "Scroll left",
|
|
189
|
-
next: "Scroll right"
|
|
190
|
-
};
|
|
191
|
-
function compileComponent(defaults, own, cn2) {
|
|
192
|
-
const parts = {};
|
|
193
|
-
for (const part2 of /* @__PURE__ */ new Set([...Object.keys(defaults), ...Object.keys(own)])) {
|
|
194
|
-
const def = defaults[part2] ? extendRecipe(defaults[part2], own[part2]) : own[part2];
|
|
195
|
-
parts[part2] = compileRecipe(def, cn2);
|
|
196
|
-
}
|
|
197
|
-
return parts;
|
|
198
|
-
}
|
|
199
|
-
function compileParts(config, cn2) {
|
|
200
|
-
const out = {};
|
|
201
|
-
const overrides = config.parts ?? {};
|
|
202
|
-
const names2 = /* @__PURE__ */ new Set([...Object.keys(ANATOMY), ...Object.keys(overrides)]);
|
|
203
|
-
for (const component of names2) {
|
|
204
|
-
const defaults = ANATOMY[component] ?? {};
|
|
205
|
-
out[component] = compileComponent(defaults, overrides[component] ?? {}, cn2);
|
|
206
|
-
}
|
|
207
|
-
return out;
|
|
208
|
-
}
|
|
209
|
-
function defineUi(config) {
|
|
210
|
-
const own = config ?? {};
|
|
211
|
-
const cn2 = createCn(own.merge);
|
|
212
|
-
return Object.freeze({
|
|
213
|
-
// compileParts returns generic parts; the option type narrows them per component.
|
|
214
|
-
parts: compileParts(own, cn2),
|
|
215
|
-
cn: cn2,
|
|
216
|
-
motion: Object.freeze({ ...own.motion }),
|
|
217
|
-
icons: Object.freeze({ ...own.icons }),
|
|
218
|
-
labels: Object.freeze({ ...DEFAULT_LABELS, ...own.labels }),
|
|
219
|
-
config: own
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
var defaultUi = defineUi();
|
|
223
|
-
|
|
224
110
|
// src/foundation/recipes/split.ts
|
|
225
111
|
var names = /* @__PURE__ */ new WeakMap();
|
|
226
112
|
function variantNames(recipe) {
|
|
@@ -246,6 +132,6 @@ function splitVariants(props, ...recipes) {
|
|
|
246
132
|
return [variants, rest];
|
|
247
133
|
}
|
|
248
134
|
|
|
249
|
-
export {
|
|
135
|
+
export { cn, compileRecipe, createCn, defineRecipe, extendRecipe, joinClasses, resolveRecipe, splitVariants, variantNames };
|
|
250
136
|
//# sourceMappingURL=index.js.map
|
|
251
137
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/foundation/recipes/recipe.ts","../../src/foundation/recipes/anatomy.ts","../../src/foundation/recipes/cn.ts","../../src/foundation/recipes/define.ts","../../src/foundation/recipes/split.ts"],"names":["next","key","names","cn","part"],"mappings":";;;AAwGA,IAAM,MAAM,CAAC,KAAA;AAAA;AAAA,EAEX,UAAU,IAAA,IAAQ,KAAA,KAAU,MAAA,GAAY,IAAA,GAAO,OAAO,KAAK;AAAA,CAAA;AAE7D,SAAS,OAAA,CACP,UACA,QAAA,EACS;AACT,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,MAAM,KAAK,MAAA,CAAO,OAAA,CAAQ,QAAQ,CAAA,EAAG;AACrD,IAAA,IAAI,IAAA,KAAS,OAAA,IAAW,IAAA,KAAS,WAAA,EAAa;AAC9C,IAAA,MAAM,MAAA,GAAS,QAAA,CAAS,IAAI,CAAA,IAAK,IAAA;AACjC,IAAA,IAAI,KAAA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A,CAAK,IAAI,CAAA;AAC1B,QAAA,OAAO,KAAK,IAAI,CAAA;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,CAAC,UAAU,IAAS,CAAA;AAC7B","file":"index.js","sourcesContent":["/**\n * A class value: strings and numbers, nested arrays, and objects whose keys\n * apply when their value is truthy (the `clsx` contract).\n */\nexport type Classes =\n | string\n | number\n | bigint\n | boolean\n | null\n | undefined\n | readonly Classes[]\n | Readonly<Record<string, unknown>>;\n\n/**\n * Variant names mapped to their values and the classes each applies.\n */\nexport type VariantMap = Readonly<\n Record<string, Readonly<Record<string, Classes>>>\n>;\n\ntype ValueOf<K> = K extends \"true\" | \"false\" ? boolean | K : K;\n\n/**\n * The props a recipe accepts to pick a value for each variant.\n */\nexport type SelectionOf<V> = {\n -readonly [K in keyof V]?: ValueOf<keyof V[K] & string> | null;\n};\n\ntype CompoundMatch<V> = {\n -readonly [K in keyof V]?:\n ValueOf<keyof V[K] & string> | readonly ValueOf<keyof V[K] & string>[];\n};\n\n/**\n * Classes applied only when several variant values match together.\n */\nexport type CompoundVariant<V> = CompoundMatch<V> & {\n readonly class?: Classes;\n readonly className?: Classes;\n};\n\n/**\n * The declarative description of a recipe: base classes, variants, compounds and defaults.\n */\nexport interface RecipeDef<V extends VariantMap = VariantMap> {\n readonly base?: Classes;\n readonly variants?: V;\n readonly compoundVariants?: readonly CompoundVariant<V>[];\n readonly defaultVariants?: SelectionOf<V>;\n}\n\n/**\n * A partial recipe definition that extends, or with `reset` replaces, a default one.\n */\nexport interface RecipeOverride<V extends VariantMap = VariantMap> {\n readonly reset?: boolean;\n readonly base?: Classes;\n readonly variants?: {\n readonly [K in keyof V]?: {\n readonly [Value in keyof V[K]]?: Classes;\n } & Readonly<Record<string, Classes>>;\n } & Readonly<Record<string, Readonly<Record<string, Classes>>>>;\n readonly compoundVariants?: readonly ({\n readonly class?: Classes;\n readonly className?: Classes;\n } & Readonly<Record<string, unknown>>)[];\n readonly defaultVariants?: Readonly<Record<string, unknown>>;\n}\n\nexport type VariantsOf<R> = R extends { readonly variants?: infer V }\n ? V extends VariantMap\n ? V\n : {}\n : {};\n\ntype Union<A, B> = {\n readonly [K in keyof A | keyof B]: (K extends keyof A ? A[K] : {}) &\n (K extends keyof B ? B[K] : {});\n};\n\nexport type MergedVariants<D, O> = O extends { readonly reset: true }\n ? VariantsOf<O>\n : Union<VariantsOf<D>, VariantsOf<O>>;\n\n/**\n * A compiled recipe: call it with variant props to get a class string.\n */\nexport interface Recipe<V = VariantMap> {\n (\n props?: SelectionOf<V> & {\n readonly class?: Classes;\n readonly className?: Classes;\n },\n ): string;\n readonly def: RecipeDef;\n}\n\n/**\n * The variant props accepted by a recipe type.\n */\nexport type RecipeProps<R> = R extends Recipe<infer V> ? SelectionOf<V> : never;\n\nconst key = (value: unknown): string | null =>\n // eslint-disable-next-line @typescript-eslint/no-base-to-string -- any value is accepted; objects become \"[object Object]\"\n value === null || value === undefined ? null : String(value);\n\nfunction matches(\n selected: Record<string, string | null>,\n compound: Record<string, unknown>,\n): boolean {\n for (const [name, wanted] of Object.entries(compound)) {\n if (name === \"class\" || name === \"className\") continue;\n const actual = selected[name] ?? null;\n if (Array.isArray(wanted)) {\n if (!wanted.some((one) => key(one) === actual)) return false;\n } else if (key(wanted) !== actual) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Resolves a recipe definition and props to the ordered class list before merging.\n */\nexport function resolveRecipe(\n def: RecipeDef,\n props: Record<string, unknown> = {},\n): Classes[] {\n const out: Classes[] = [def.base];\n const variants = def.variants ?? {};\n const defaults = (def.defaultVariants ?? {}) as Record<string, unknown>;\n const selected: Record<string, string | null> = {};\n\n for (const name of Object.keys(variants)) {\n const value = props[name] === undefined ? defaults[name] : props[name];\n const chosen = key(value);\n selected[name] = chosen;\n if (chosen !== null) out.push(variants[name][chosen]);\n }\n for (const compound of def.compoundVariants ?? []) {\n if (matches(selected, compound)) {\n out.push(compound.class, compound.className);\n }\n }\n out.push(props.class as Classes, props.className as Classes);\n return out;\n}\n\n/**\n * Combines a default recipe definition with an override.\n */\nexport function extendRecipe(\n base: RecipeDef,\n override: RecipeOverride | undefined,\n): RecipeDef {\n if (!override) return base;\n const { reset, ...rest } = override;\n if (reset) return rest as RecipeDef;\n\n const variants: Record<string, Record<string, Classes>> = {};\n for (const [name, values] of Object.entries(base.variants ?? {})) {\n variants[name] = { ...values };\n }\n for (const [name, values] of Object.entries(rest.variants ?? {})) {\n const target = (variants[name] ??= {});\n for (const [value, classes] of Object.entries(values)) {\n target[value] =\n target[value] === undefined ? classes : [target[value], classes];\n }\n }\n\n return {\n base: rest.base === undefined ? base.base : [base.base, rest.base],\n variants,\n compoundVariants: [\n ...(base.compoundVariants ?? []),\n ...((rest.compoundVariants ?? []) as RecipeDef[\"compoundVariants\"] &\n object),\n ],\n defaultVariants: {\n ...base.defaultVariants,\n ...(rest.defaultVariants as RecipeDef[\"defaultVariants\"]),\n },\n };\n}\n\n/**\n * Declares a recipe definition with its variant types inferred.\n */\nexport function defineRecipe<const V extends VariantMap = {}>(\n def: RecipeDef<V>,\n): RecipeDef<V> {\n return def;\n}\n\n/**\n * Turns a recipe definition into a callable recipe using the given class merger.\n */\nexport function compileRecipe<V>(\n def: RecipeDef,\n merge: (...inputs: Classes[]) => string,\n): Recipe<V> {\n const recipe = ((props?: Record<string, unknown>) =>\n merge(...resolveRecipe(def, props))) as Recipe<V>;\n Object.defineProperty(recipe, \"def\", { value: def, enumerable: true });\n return recipe;\n}\n\nfunction appendClasses(value: Classes, out: string): string {\n if (!value) return out;\n if (typeof value === \"string\" || typeof value === \"number\") {\n return out ? `${out} ${value}` : String(value);\n }\n if (typeof value !== \"object\") return out;\n if (Array.isArray(value)) {\n return (value as readonly Classes[]).reduce<string>(\n (next, item) => appendClasses(item, next),\n out,\n );\n }\n const record = value as Readonly<Record<string, unknown>>;\n let next = out;\n for (const key of Object.keys(record)) {\n if (record[key]) next = next ? `${next} ${key}` : key;\n }\n return next;\n}\n\n/**\n * Joins class values without Tailwind conflict resolution.\n */\nexport const joinClasses = (...inputs: Classes[]): string =>\n appendClasses(inputs, \"\");\n","import { defineRecipe } from \"./recipe\";\n\nconst part = () => defineRecipe({});\n\nconst flag = { false: \"\", true: \"\" } as const;\n\nconst layout = { fill: \"\", intrinsic: \"\" } as const;\n\n/**\n * The built-in component parts and their variants that `defineUi` can restyle.\n */\nexport const ANATOMY = {\n button: {\n root: defineRecipe({ variants: { intent: {} } }),\n bare: part(),\n busy: part(),\n busyLabel: part(),\n busySpinner: part(),\n },\n input: { field: part(), area: part() },\n switch: { track: part(), thumb: part() },\n checkbox: {\n root: part(),\n box: defineRecipe({ variants: { checked: flag } }),\n glyph: defineRecipe({ variants: { checked: flag } }),\n },\n segmented: {\n root: part(),\n segment: defineRecipe({ variants: { active: flag } }),\n pill: part(),\n chosen: part(),\n icon: part(),\n count: part(),\n },\n select: {\n root: part(),\n trigger: part(),\n value: part(),\n label: part(),\n placeholder: part(),\n chevron: part(),\n menu: part(),\n option: part(),\n highlight: part(),\n optionBody: part(),\n text: part(),\n description: part(),\n icon: part(),\n check: part(),\n empty: part(),\n },\n carousel: {\n root: part(),\n track: part(),\n slide: part(),\n arrow: defineRecipe({\n variants: { side: { left: \"\", right: \"\" }, visible: flag },\n }),\n icon: part(),\n },\n tooltip: { content: part(), label: part() },\n loader: {\n root: defineRecipe({ variants: { over: flag } }),\n label: part(),\n overlay: part(),\n dots: part(),\n dot: part(),\n spinner: part(),\n icon: part(),\n },\n skeleton: { block: part(), lines: part(), line: part(), bar: part() },\n image: {\n frame: defineRecipe({ variants: { layout, loading: flag } }),\n picture: defineRecipe({ variants: { layout } }),\n fallback: part(),\n },\n avatar: { root: part(), image: part(), initials: part() },\n highlight: { fill: part() },\n} as const;\n\n/**\n * Type of `ANATOMY`.\n */\nexport type Anatomy = typeof ANATOMY;\n","import { extendTailwindMerge } from \"tailwind-merge\";\n\nimport { type Classes, joinClasses } from \"./recipe\";\n\n/**\n * Extra Tailwind theme values and class groups that `cn` should merge correctly.\n */\nexport interface MergeVocabulary {\n readonly theme?: Readonly<Record<string, readonly string[]>>;\n readonly classGroups?: Readonly<Record<string, readonly string[]>>;\n}\n\n/**\n * Creates a class-name joiner that also resolves Tailwind conflicts using the given vocabulary.\n */\nexport function createCn(\n vocabulary: MergeVocabulary = {},\n): (...inputs: Classes[]) => string {\n const merge = extendTailwindMerge({\n extend: {\n theme: vocabulary.theme ?? {},\n classGroups: Object.fromEntries(\n Object.entries(vocabulary.classGroups ?? {}).map(([group, names]) => [\n group,\n [...names],\n ]),\n ),\n },\n });\n return (...inputs) => merge(joinClasses(...inputs));\n}\n\n/**\n * Joins class values and resolves Tailwind conflicts (default vocabulary).\n */\nexport const cn = createCn();\n","import type { UiRegister } from \"@/foundation/recipes\";\n\nimport { ANATOMY, type Anatomy } from \"./anatomy\";\nimport { createCn, type MergeVocabulary } from \"./cn\";\nimport {\n type Classes,\n compileRecipe,\n extendRecipe,\n type MergedVariants,\n type Recipe,\n type RecipeDef,\n type RecipeOverride,\n type VariantsOf,\n} from \"./recipe\";\n\ntype Ease = readonly [number, number, number, number];\n\n/**\n * A motion transition object.\n */\nexport type UiTransition = Readonly<Record<string, unknown>>;\n\n/**\n * Named motion variants, each a transition or a function of a custom index.\n */\nexport type UiVariants = Readonly<\n Record<string, UiTransition | ((custom: number) => UiTransition)>\n>;\n\n/**\n * Motion settings that components read from the UI definition.\n */\nexport interface UiMotion {\n readonly follow?: UiTransition;\n readonly menu?: UiVariants;\n readonly option?: UiVariants;\n readonly glide?: { readonly duration: number; readonly ease: Ease };\n}\n\n/**\n * Icon names that components use for built-in glyphs.\n */\nexport interface UiIcons {\n readonly check?: string;\n readonly selected?: string;\n readonly chevron?: string;\n readonly previous?: string;\n readonly next?: string;\n readonly spinner?: string;\n}\n\n/**\n * Default texts used by components.\n */\nexport interface UiLabels {\n readonly loading: string;\n readonly placeholder: string;\n readonly empty: string;\n readonly previous: string;\n readonly next: string;\n}\n\n/**\n * The labels used when the UI definition does not override them.\n */\nexport const DEFAULT_LABELS: UiLabels = {\n loading: \"Loading\",\n placeholder: \"Select an option...\",\n empty: \"No options available\",\n previous: \"Scroll left\",\n next: \"Scroll right\",\n};\n\ntype Parts = Readonly<Record<string, unknown>>;\ntype Registry = Readonly<Record<string, Parts>>;\n\n/**\n * Per-component, per-part recipe overrides.\n */\nexport type UiPartOverrides<D extends Registry = Anatomy> = {\n readonly [C in keyof D]?: {\n readonly [P in keyof D[C]]?: RecipeOverride<VariantsOf<D[C][P]>>;\n };\n} & Readonly<\n Record<\n string,\n Readonly<Record<string, RecipeOverride | RecipeDef>> | undefined\n >\n>;\n\n/**\n * Input of `defineUi`: part overrides, merge vocabulary, motion, icons and labels.\n */\nexport interface UiConfig {\n readonly parts?: UiPartOverrides;\n readonly merge?: MergeVocabulary;\n readonly motion?: UiMotion;\n readonly icons?: UiIcons;\n readonly labels?: Partial<UiLabels>;\n}\n\ntype MergedParts<D extends Parts, O> = {\n readonly [P in keyof D | keyof O]: Recipe<\n P extends keyof D\n ? P extends keyof O\n ? MergedVariants<D[P], O[P]>\n : VariantsOf<D[P]>\n : P extends keyof O\n ? VariantsOf<O[P]>\n : {}\n >;\n};\n\ntype PartsOverride<O, C> = O extends { readonly parts?: infer X }\n ? C extends keyof X\n ? NonNullable<X[C]>\n : {}\n : {};\n\n/**\n * The compiled recipes of every component part, including app-defined ones.\n */\nexport type UiParts<O = {}> = {\n readonly [\n C in\n | keyof Anatomy\n | Exclude<\n keyof NonNullable<O extends { parts?: infer X } ? X : {}>,\n number | symbol\n >\n ]: C extends keyof Anatomy\n ? MergedParts<Anatomy[C], PartsOverride<O, C>>\n : MergedParts<{}, PartsOverride<O, C>>;\n};\n\n/**\n * A compiled UI definition: part recipes, class joiner, motion, icons and labels.\n */\nexport interface Ui<O = {}> {\n readonly parts: UiParts<O>;\n readonly cn: (...inputs: Classes[]) => string;\n readonly motion: UiMotion;\n readonly icons: UiIcons;\n readonly labels: UiLabels;\n readonly config: UiConfig;\n}\n\ntype CompiledParts = Record<string, Recipe>;\n\nfunction compileComponent(\n defaults: Parts,\n own: Record<string, RecipeOverride>,\n cn: (...inputs: Classes[]) => string,\n): CompiledParts {\n const parts: CompiledParts = {};\n for (const part of new Set([...Object.keys(defaults), ...Object.keys(own)])) {\n const def = defaults[part]\n ? extendRecipe(defaults[part], own[part])\n : (own[part] as RecipeDef);\n parts[part] = compileRecipe(def, cn);\n }\n return parts;\n}\n\nfunction compileParts(\n config: UiConfig,\n cn: (...inputs: Classes[]) => string,\n): Record<string, CompiledParts> {\n const out: Record<string, CompiledParts> = {};\n const overrides = (config.parts ?? {}) as Record<\n string,\n Record<string, RecipeOverride> | undefined\n >;\n const names = new Set([...Object.keys(ANATOMY), ...Object.keys(overrides)]);\n for (const component of names) {\n // ANATOMY is a literal table, indexed here by component name.\n const defaults = (ANATOMY as unknown as Registry)[component] ?? {};\n out[component] = compileComponent(defaults, overrides[component] ?? {}, cn);\n }\n return out;\n}\n\n/**\n * Compiles a UI definition from the built-in anatomy and the given overrides.\n */\nexport function defineUi<const O extends UiConfig = {}>(config?: O): Ui<O> {\n const own = (config ?? {}) as UiConfig;\n const cn = createCn(own.merge);\n return Object.freeze({\n // compileParts returns generic parts; the option type narrows them per component.\n parts: compileParts(own, cn) as unknown as UiParts<O>,\n cn,\n motion: Object.freeze({ ...own.motion }),\n icons: Object.freeze({ ...own.icons }),\n labels: Object.freeze({ ...DEFAULT_LABELS, ...own.labels }),\n config: own,\n });\n}\n\n/**\n * The UI definition used when the app does not provide one.\n */\nexport const defaultUi = defineUi();\n\n/**\n * The app's UI definition type, taken from the `UiRegister` augmentation.\n */\nexport type RegisteredUi = UiRegister extends { ui: infer U }\n ? U\n : typeof defaultUi;\n\ntype RegisteredParts = RegisteredUi extends { parts: infer P } ? P : never;\n\n/**\n * The variant props of one part of one component.\n */\nexport type PartProps<\n C extends keyof RegisteredParts,\n P extends keyof RegisteredParts[C],\n> =\n RegisteredParts[C][P] extends Recipe<infer V>\n ? {\n -readonly [K in keyof V]?: keyof V[K] & string extends infer Key\n ? Key extends \"true\" | \"false\"\n ? boolean\n : Key\n : never;\n }\n : never;\n\n/**\n * Extra class names keyed by part name for one component.\n */\nexport type PartClassNames<C extends keyof RegisteredParts> = {\n readonly [P in keyof RegisteredParts[C]]?: string;\n};\n\ntype Choices<T, K> = K extends keyof T ? NonNullable<T[K]> : never;\n\n/**\n * The combined variant props of several parts of one component.\n */\nexport type PartsProps<\n C extends keyof RegisteredParts,\n P extends keyof RegisteredParts[C],\n> = {\n -readonly [\n K in P extends unknown ? keyof PartProps<C, P> : never\n ]?: P extends unknown ? Choices<PartProps<C, P>, K> : never;\n};\n","import type { Recipe } from \"./recipe\";\n\nconst names = new WeakMap<object, readonly string[]>();\n\n/**\n * Lists the variant names a recipe accepts.\n */\nexport function variantNames(recipe: Recipe): readonly string[] {\n const def = recipe.def;\n let list = names.get(def);\n if (!list) {\n list = Object.keys(def.variants ?? {});\n names.set(def, list);\n }\n return list;\n}\n\n/**\n * Separates the variant props of the given recipes from the remaining props.\n */\nexport function splitVariants<P extends Record<string, unknown>>(\n props: P,\n ...recipes: Recipe[]\n): [variants: Record<string, unknown>, rest: P] {\n const variants: Record<string, unknown> = {};\n const rest: Record<string, unknown> = { ...props };\n for (const recipe of recipes) {\n for (const name of variantNames(recipe)) {\n if (name in rest) {\n variants[name] = rest[name];\n delete rest[name];\n }\n }\n }\n return [variants, rest as P];\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/foundation/recipes/recipe.ts","../../src/foundation/recipes/cn.ts","../../src/foundation/recipes/split.ts"],"names":["next","key","names"],"mappings":";;;AAwGA,IAAM,MAAM,CAAC,KAAA;AAAA;AAAA,EAEX,UAAU,IAAA,IAAQ,KAAA,KAAU,MAAA,GAAY,IAAA,GAAO,OAAO,KAAK;AAAA,CAAA;AAE7D,SAAS,OAAA,CACP,UACA,QAAA,EACS;AACT,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,MAAM,K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Y,EAAE,CAAA;AACrC,IAAA,KAAA,CAAM,GAAA,CAAI,KAAK,IAAI,CAAA;AAAA,EACrB;AACA,EAAA,OAAO,IAAA;AACT;AAKO,SAAS,aAAA,CACd,UACG,OAAA,EAC2C;AAC9C,EAAA,MAAM,WAAoC,EAAC;AAC3C,EAAA,MAAM,IAAA,GAAgC,EAAE,GAAG,KAAA,EAAM;AACjD,EAAA,KAAA,MAAW,UAAU,OAAA,EAAS;AAC5B,IAAA,KAAA,MAAW,IAAA,IAAQ,YAAA,CAAa,MAAM,CAAA,EAAG;AACvC,MAAA,IAAI,QAAQ,IAAA,EAAM;AAChB,QAAA,QAAA,CAAS,IAAI,CAAA,GAAI,IAAA,CAAK,IAAI,CAAA;AAC1B,QAAA,OAAO,KAAK,IAAI,CAAA;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,CAAC,UAAU,IAAS,CAAA;AAC7B","file":"index.js","sourcesContent":["/**\n * A class value: strings and numbers, nested arrays, and objects whose keys\n * apply when their value is truthy (the `clsx` contract).\n */\nexport type Classes =\n | string\n | number\n | bigint\n | boolean\n | null\n | undefined\n | readonly Classes[]\n | Readonly<Record<string, unknown>>;\n\n/**\n * Variant names mapped to their values and the classes each applies.\n */\nexport type VariantMap = Readonly<\n Record<string, Readonly<Record<string, Classes>>>\n>;\n\ntype ValueOf<K> = K extends \"true\" | \"false\" ? boolean | K : K;\n\n/**\n * The props a recipe accepts to pick a value for each variant.\n */\nexport type SelectionOf<V> = {\n -readonly [K in keyof V]?: ValueOf<keyof V[K] & string> | null;\n};\n\ntype CompoundMatch<V> = {\n -readonly [K in keyof V]?:\n ValueOf<keyof V[K] & string> | readonly ValueOf<keyof V[K] & string>[];\n};\n\n/**\n * Classes applied only when several variant values match together.\n */\nexport type CompoundVariant<V> = CompoundMatch<V> & {\n readonly class?: Classes;\n readonly className?: Classes;\n};\n\n/**\n * The declarative description of a recipe: base classes, variants, compounds and defaults.\n */\nexport interface RecipeDef<V extends VariantMap = VariantMap> {\n readonly base?: Classes;\n readonly variants?: V;\n readonly compoundVariants?: readonly CompoundVariant<V>[];\n readonly defaultVariants?: SelectionOf<V>;\n}\n\n/**\n * A partial recipe definition that extends, or with `reset` replaces, a default one.\n */\nexport interface RecipeOverride<V extends VariantMap = VariantMap> {\n readonly reset?: boolean;\n readonly base?: Classes;\n readonly variants?: {\n readonly [K in keyof V]?: {\n readonly [Value in keyof V[K]]?: Classes;\n } & Readonly<Record<string, Classes>>;\n } & Readonly<Record<string, Readonly<Record<string, Classes>>>>;\n readonly compoundVariants?: readonly ({\n readonly class?: Classes;\n readonly className?: Classes;\n } & Readonly<Record<string, unknown>>)[];\n readonly defaultVariants?: Readonly<Record<string, unknown>>;\n}\n\nexport type VariantsOf<R> = R extends { readonly variants?: infer V }\n ? V extends VariantMap\n ? V\n : {}\n : {};\n\ntype Union<A, B> = {\n readonly [K in keyof A | keyof B]: (K extends keyof A ? A[K] : {}) &\n (K extends keyof B ? B[K] : {});\n};\n\nexport type MergedVariants<D, O> = O extends { readonly reset: true }\n ? VariantsOf<O>\n : Union<VariantsOf<D>, VariantsOf<O>>;\n\n/**\n * A compiled recipe: call it with variant props to get a class string.\n */\nexport interface Recipe<V = VariantMap> {\n (\n props?: SelectionOf<V> & {\n readonly class?: Classes;\n readonly className?: Classes;\n },\n ): string;\n readonly def: RecipeDef;\n}\n\n/**\n * The variant props accepted by a recipe type.\n */\nexport type RecipeProps<R> = R extends Recipe<infer V> ? SelectionOf<V> : never;\n\nconst key = (value: unknown): string | null =>\n // eslint-disable-next-line @typescript-eslint/no-base-to-string -- any value is accepted; objects become \"[object Object]\"\n value === null || value === undefined ? null : String(value);\n\nfunction matches(\n selected: Record<string, string | null>,\n compound: Record<string, unknown>,\n): boolean {\n for (const [name, wanted] of Object.entries(compound)) {\n if (name === \"class\" || name === \"className\") continue;\n const actual = selected[name] ?? null;\n if (Array.isArray(wanted)) {\n if (!wanted.some((one) => key(one) === actual)) return false;\n } else if (key(wanted) !== actual) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Resolves a recipe definition and props to the ordered class list before merging.\n */\nexport function resolveRecipe(\n def: RecipeDef,\n props: Record<string, unknown> = {},\n): Classes[] {\n const out: Classes[] = [def.base];\n const variants = def.variants ?? {};\n const defaults = (def.defaultVariants ?? {}) as Record<string, unknown>;\n const selected: Record<string, string | null> = {};\n\n for (const name of Object.keys(variants)) {\n const value = props[name] === undefined ? defaults[name] : props[name];\n const chosen = key(value);\n selected[name] = chosen;\n if (chosen !== null) out.push(variants[name][chosen]);\n }\n for (const compound of def.compoundVariants ?? []) {\n if (matches(selected, compound)) {\n out.push(compound.class, compound.className);\n }\n }\n out.push(props.class as Classes, props.className as Classes);\n return out;\n}\n\n/**\n * Combines a default recipe definition with an override.\n */\nexport function extendRecipe(\n base: RecipeDef,\n override: RecipeOverride | undefined,\n): RecipeDef {\n if (!override) return base;\n const { reset, ...rest } = override;\n if (reset) return rest as RecipeDef;\n\n const variants: Record<string, Record<string, Classes>> = {};\n for (const [name, values] of Object.entries(base.variants ?? {})) {\n variants[name] = { ...values };\n }\n for (const [name, values] of Object.entries(rest.variants ?? {})) {\n const target = (variants[name] ??= {});\n for (const [value, classes] of Object.entries(values)) {\n target[value] =\n target[value] === undefined ? classes : [target[value], classes];\n }\n }\n\n return {\n base: rest.base === undefined ? base.base : [base.base, rest.base],\n variants,\n compoundVariants: [\n ...(base.compoundVariants ?? []),\n ...((rest.compoundVariants ?? []) as RecipeDef[\"compoundVariants\"] &\n object),\n ],\n defaultVariants: {\n ...base.defaultVariants,\n ...(rest.defaultVariants as RecipeDef[\"defaultVariants\"]),\n },\n };\n}\n\n/**\n * Declares a recipe definition with its variant types inferred.\n */\nexport function defineRecipe<const V extends VariantMap = {}>(\n def: RecipeDef<V>,\n): RecipeDef<V> {\n return def;\n}\n\n/**\n * Turns a recipe definition into a callable recipe using the given class merger.\n */\nexport function compileRecipe<V>(\n def: RecipeDef,\n merge: (...inputs: Classes[]) => string,\n): Recipe<V> {\n const recipe = ((props?: Record<string, unknown>) =>\n merge(...resolveRecipe(def, props))) as Recipe<V>;\n Object.defineProperty(recipe, \"def\", { value: def, enumerable: true });\n return recipe;\n}\n\nfunction appendClasses(value: Classes, out: string): string {\n if (!value) return out;\n if (typeof value === \"string\" || typeof value === \"number\") {\n return out ? `${out} ${value}` : String(value);\n }\n if (typeof value !== \"object\") return out;\n if (Array.isArray(value)) {\n return (value as readonly Classes[]).reduce<string>(\n (next, item) => appendClasses(item, next),\n out,\n );\n }\n const record = value as Readonly<Record<string, unknown>>;\n let next = out;\n for (const key of Object.keys(record)) {\n if (record[key]) next = next ? `${next} ${key}` : key;\n }\n return next;\n}\n\n/**\n * Joins class values without Tailwind conflict resolution.\n */\nexport const joinClasses = (...inputs: Classes[]): string =>\n appendClasses(inputs, \"\");\n","import { extendTailwindMerge } from \"tailwind-merge\";\n\nimport { type Classes, joinClasses } from \"./recipe\";\n\n/**\n * Extra Tailwind theme values and class groups that `cn` should merge correctly.\n */\nexport interface MergeVocabulary {\n readonly theme?: Readonly<Record<string, readonly string[]>>;\n readonly classGroups?: Readonly<Record<string, readonly string[]>>;\n}\n\n/**\n * Creates a class-name joiner that also resolves Tailwind conflicts using the given vocabulary.\n */\nexport function createCn(\n vocabulary: MergeVocabulary = {},\n): (...inputs: Classes[]) => string {\n const merge = extendTailwindMerge({\n extend: {\n theme: vocabulary.theme ?? {},\n classGroups: Object.fromEntries(\n Object.entries(vocabulary.classGroups ?? {}).map(([group, names]) => [\n group,\n [...names],\n ]),\n ),\n },\n });\n return (...inputs) => merge(joinClasses(...inputs));\n}\n\n/**\n * Joins class values and resolves Tailwind conflicts (default vocabulary).\n */\nexport const cn = createCn();\n","import type { Recipe } from \"./recipe\";\n\nconst names = new WeakMap<object, readonly string[]>();\n\n/**\n * Lists the variant names a recipe accepts.\n */\nexport function variantNames(recipe: Recipe): readonly string[] {\n const def = recipe.def;\n let list = names.get(def);\n if (!list) {\n list = Object.keys(def.variants ?? {});\n names.set(def, list);\n }\n return list;\n}\n\n/**\n * Separates the variant props of the given recipes from the remaining props.\n */\nexport function splitVariants<P extends Record<string, unknown>>(\n props: P,\n ...recipes: Recipe[]\n): [variants: Record<string, unknown>, rest: P] {\n const variants: Record<string, unknown> = {};\n const rest: Record<string, unknown> = { ...props };\n for (const recipe of recipes) {\n for (const name of variantNames(recipe)) {\n if (name in rest) {\n variants[name] = rest[name];\n delete rest[name];\n }\n }\n }\n return [variants, rest as P];\n}\n"]}
|
package/dist/theme/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { ModuleMotionConfig, ThemeProvider, defineTheme, defineThemeSpec, useModuleMotion, useMotionTokens, useOptionalModuleMotion, useTheme } from '../chunk-
|
|
2
|
+
export { ModuleMotionConfig, ThemeButton, ThemeIcon, ThemeProvider, ThemeSpinner, ThemeTooltip, defineTheme, defineThemeSpec, useIconName, useModuleMotion, useMotionTokens, useOptionalModuleMotion, useTheme, useThemeComponents } from '../chunk-AKPH5CEJ.js';
|
|
3
3
|
import '../chunk-J3VTDBC6.js';
|
|
4
4
|
import '../chunk-YHWA7FXX.js';
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/docs/README.md
CHANGED
|
@@ -35,8 +35,7 @@ Foundational Libraries & Primitives:
|
|
|
35
35
|
├─ @omerdlw/base-framework/theme (Theme engine: defineThemeSpec, defineTheme, ThemeProvider, useTheme)
|
|
36
36
|
├─ @omerdlw/base-framework/result (Functional Result<T, E> error handling: ok, err, createSafeAction)
|
|
37
37
|
├─ @omerdlw/base-framework/events (Cross-cutting decoupled event bus: globalEvents, EVENT_TYPES)
|
|
38
|
-
├─ @omerdlw/base-framework/
|
|
39
|
-
├─ @omerdlw/base-framework/recipes (Server-safe defineUi, recipes, cn, createCn, ANATOMY)
|
|
38
|
+
├─ @omerdlw/base-framework/recipes (Server-safe defineRecipe, splitVariants, cn, createCn)
|
|
40
39
|
├─ @omerdlw/base-framework/hooks (useStore, useGlobalEvent, useClickOutside, useRequiredContext)
|
|
41
40
|
├─ @omerdlw/base-framework/utils (clamp, debounce, throttle, createStore, createScheduler, report)
|
|
42
41
|
└─ @omerdlw/base-framework/error (GlobalError, ModuleError, UserError, toUserMessage)
|
|
@@ -50,16 +49,16 @@ Whether you are a software architect or an AI Pair Programmer (Antigravity, Curs
|
|
|
50
49
|
|
|
51
50
|
### 2.1 General Architecture Guides
|
|
52
51
|
|
|
53
|
-
| Document | Primary Audience | Scope & Contents
|
|
54
|
-
| :------------------------------------------------------------- | :--------------------- |
|
|
55
|
-
| **[`getting-started.md`](./getting-started.md)** | All Developers | Step-by-step Next.js 16 installation, Tailwind CSS v4 `@source` configuration, and root layout setup.
|
|
56
|
-
| **[`architecture-and-rules.md`](./architecture-and-rules.md)** | Architects & Agents | The package layer hierarchy, 10 inviolable rules, import boundaries, decision tree, anti-patterns.
|
|
57
|
-
| **[`design.md`](./design.md)** | Designers & Developers |
|
|
58
|
-
| **[`theming.md`](./theming.md)** | Designers & Developers | Visual customization guide: `defineThemeSpec()`, `defineTheme()`, `<ThemeProvider>`, and slot reference.
|
|
59
|
-
| **[`custom-modules.md`](./custom-modules.md)** | Advanced Developers | Authoring custom modules via `defineModule()`, topological dependencies, and `usePage()` augmentation.
|
|
60
|
-
| **[`core-engine.md`](./core-engine.md)** | Developers & Agents | `CoreProvider`, Theme engine, Event bus, Motion retiming, Pure utils, scheduler, and reactive stores.
|
|
61
|
-
| **[`testing.md`](./testing.md)** | Developers & QA | Running the test suite, `happy-dom` harness (`renderHook`, `Themed`), and downstream component testing.
|
|
62
|
-
| **[`templates/AGENTS.md`](../templates/AGENTS.md)** | AI Agents & Tech Leads | **Drop-in instructions** for AI coding assistants in projects using `@omerdlw/base-framework`.
|
|
52
|
+
| Document | Primary Audience | Scope & Contents |
|
|
53
|
+
| :------------------------------------------------------------- | :--------------------- | :--------------------------------------------------------------------------------------------------------------------------- |
|
|
54
|
+
| **[`getting-started.md`](./getting-started.md)** | All Developers | Step-by-step Next.js 16 installation, Tailwind CSS v4 `@source` configuration, and root layout setup. |
|
|
55
|
+
| **[`architecture-and-rules.md`](./architecture-and-rules.md)** | Architects & Agents | The package layer hierarchy, 10 inviolable rules, import boundaries, decision tree, anti-patterns. |
|
|
56
|
+
| **[`design.md`](./design.md)** | Designers & Developers | Why the framework ships no UI: the `components` and `icons` the app hands `ThemeProvider`, the framework icon keys, recipes. |
|
|
57
|
+
| **[`theming.md`](./theming.md)** | Designers & Developers | Visual customization guide: `defineThemeSpec()`, `defineTheme()`, `<ThemeProvider>`, and slot reference. |
|
|
58
|
+
| **[`custom-modules.md`](./custom-modules.md)** | Advanced Developers | Authoring custom modules via `defineModule()`, topological dependencies, and `usePage()` augmentation. |
|
|
59
|
+
| **[`core-engine.md`](./core-engine.md)** | Developers & Agents | `CoreProvider`, Theme engine, Event bus, Motion retiming, Pure utils, scheduler, and reactive stores. |
|
|
60
|
+
| **[`testing.md`](./testing.md)** | Developers & QA | Running the test suite, `happy-dom` harness (`renderHook`, `Themed`), and downstream component testing. |
|
|
61
|
+
| **[`templates/AGENTS.md`](../templates/AGENTS.md)** | AI Agents & Tech Leads | **Drop-in instructions** for AI coding assistants in projects using `@omerdlw/base-framework`. |
|
|
63
62
|
|
|
64
63
|
### 2.2 Module Reference — [`modules/`](./modules/README.md)
|
|
65
64
|
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
The source is split into four layers. A file's layer is its first folder under `src/`:
|
|
10
10
|
|
|
11
|
-
| Layer | Folder | Contents
|
|
12
|
-
| :---- | :--------------- |
|
|
13
|
-
| 0 | `src/foundation` | No React, server and edge safe: `result`, `events`, `utils`, `recipes`
|
|
14
|
-
| 1 | `src/react` | React primitives: `context`, `hooks`, `theme
|
|
15
|
-
| 2 | `src/core` | Orchestration: `kernel`, `error`, `provider`, `navigation` (the navigator machine)
|
|
16
|
-
| 3 | `src/modules` | The UI modules and `modules/index.ts` (`defaultModules`)
|
|
11
|
+
| Layer | Folder | Contents | Public subpaths |
|
|
12
|
+
| :---- | :--------------- | :------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------- |
|
|
13
|
+
| 0 | `src/foundation` | No React, server and edge safe: `result`, `events`, `utils`, `recipes` | `/result`, `/events`, `/utils`, `/recipes` |
|
|
14
|
+
| 1 | `src/react` | React primitives: `context`, `hooks`, `theme` (themes, the app's components and icons) | `/hooks`, `/theme` |
|
|
15
|
+
| 2 | `src/core` | Orchestration: `kernel`, `error`, `provider`, `navigation` (the navigator machine) | `/kernel`, `/error`, `/provider` |
|
|
16
|
+
| 3 | `src/modules` | The UI modules and `modules/index.ts` (`defaultModules`) | `/modules`, `/<module>` (`/dock`, `/modal`, …), `/ambient/server`, `/ambient/worker` |
|
|
17
17
|
|
|
18
18
|
`src/index.ts` and `src/modules/index.ts` are barrels and may import from any layer.
|
|
19
19
|
|
|
@@ -179,10 +179,10 @@ It runs `format:check`, `lint`, `type-check`, `check:architecture`, `test`, `bui
|
|
|
179
179
|
What are you adding?
|
|
180
180
|
├─ Pure helper, store or scheduler (clamp, createStore) -> src/foundation/utils/
|
|
181
181
|
├─ Result type or event bus addition -> src/foundation/result/, src/foundation/events/
|
|
182
|
-
├─ Recipe
|
|
182
|
+
├─ Recipe or class helper (defineRecipe, cn) -> src/foundation/recipes/
|
|
183
183
|
├─ Universal React hook (useStore, useClickOutside) -> src/react/hooks/
|
|
184
184
|
├─ Theme or motion plumbing (defineTheme, useModuleMotion) -> src/react/theme/
|
|
185
|
-
├─
|
|
185
|
+
├─ A piece a module draws (button, icon, spinner, tooltip) -> a slot in src/react/theme/parts.tsx; the app supplies it
|
|
186
186
|
├─ Orchestration (registry, page controller, provider) -> src/core/kernel/, src/core/provider/
|
|
187
187
|
├─ Error handling and reporting (boundary, listener) -> src/core/error/
|
|
188
188
|
├─ Navigation machine shared by modules -> src/core/navigation/
|