@kosdev-code/base-ui-components 2.0.0 → 2.0.1
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/components/atoms/alternating-status/alternating-status.d.ts +8 -0
- package/components/atoms/alternating-status/alternating-status.d.ts.map +1 -0
- package/components/atoms/alternating-status/index.d.ts +2 -0
- package/components/atoms/alternating-status/index.d.ts.map +1 -0
- package/components/atoms/icon/common/types.d.ts +1 -1
- package/components/atoms/icon/common/types.d.ts.map +1 -1
- package/components/atoms/index.d.ts +2 -0
- package/components/atoms/index.d.ts.map +1 -1
- package/components/atoms/kos-logo/index.d.ts +2 -0
- package/components/atoms/kos-logo/index.d.ts.map +1 -0
- package/components/atoms/kos-logo/kos-logo.d.ts +7 -0
- package/components/atoms/kos-logo/kos-logo.d.ts.map +1 -0
- package/components/layouts/list-with-details-layout/list-with-details-layout.d.ts +5 -2
- package/components/layouts/list-with-details-layout/list-with-details-layout.d.ts.map +1 -1
- package/components/molecules/form/components/form-submit.d.ts.map +1 -1
- package/components/molecules/modal/form-modal/form-modal.d.ts +2 -2
- package/components/molecules/modal/form-modal/form-modal.d.ts.map +1 -1
- package/components/molecules/table/common/types.d.ts +3 -2
- package/components/molecules/table/common/types.d.ts.map +1 -1
- package/components/molecules/table/helpers/create-column-helper.d.ts +4 -1
- package/components/molecules/table/helpers/create-column-helper.d.ts.map +1 -1
- package/components/molecules/table/table.d.ts.map +1 -1
- package/index.cjs +423 -373
- package/index.cjs.map +1 -1
- package/index.js +2834 -2633
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/styles/tokens/common/local-token-helpers.d.ts +166 -0
- package/styles/tokens/common/local-token-helpers.d.ts.map +1 -0
- package/styles/tokens/index.d.ts +2 -0
- package/styles/tokens/index.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kosdev-code/base-ui-components",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"main": "./index.cjs",
|
|
5
5
|
"module": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"kos": {
|
|
37
37
|
"build": {
|
|
38
|
-
"gitHash": "
|
|
38
|
+
"gitHash": "ca09b5f1aeb43f3bbc8cfc0e9553e6a5d856718c"
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for creating local component tokens in consuming applications.
|
|
3
|
+
*
|
|
4
|
+
* These helpers allow applications to extend the design token system with their own
|
|
5
|
+
* component tokens while maintaining consistency with the base library's patterns.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // my-app/src/styles/tokens/local-components/custom-card.ts
|
|
10
|
+
* import { getSemanticToken as st } from '@kosdev-code/base-ui-components/styles';
|
|
11
|
+
*
|
|
12
|
+
* export const CUSTOM_CARD_TOKENS = {
|
|
13
|
+
* 'custom-card': {
|
|
14
|
+
* padding: st('spacing-16'),
|
|
15
|
+
* 'background-color': st('color-white'),
|
|
16
|
+
* 'border-color': st('color-grey20'),
|
|
17
|
+
* },
|
|
18
|
+
* } as const;
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // my-app/src/styles/tokens/index.ts
|
|
24
|
+
* import { createLocalTokenSystem } from '@kosdev-code/base-ui-components/styles';
|
|
25
|
+
* import { CUSTOM_CARD_TOKENS } from './local-components/custom-card';
|
|
26
|
+
*
|
|
27
|
+
* const LOCAL_TOKENS = {
|
|
28
|
+
* ...CUSTOM_CARD_TOKENS,
|
|
29
|
+
* } as const;
|
|
30
|
+
*
|
|
31
|
+
* export const {
|
|
32
|
+
* getLocalComponentTokenHelpers,
|
|
33
|
+
* localComponentTokenCss,
|
|
34
|
+
* } = createLocalTokenSystem(LOCAL_TOKENS);
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* // my-app/src/components/custom-card/custom-card.tsx
|
|
40
|
+
* import { getLocalComponentTokenHelpers } from '../../styles/tokens';
|
|
41
|
+
*
|
|
42
|
+
* const [ct] = getLocalComponentTokenHelpers(['custom-card']);
|
|
43
|
+
*
|
|
44
|
+
* const StyledCard = styled.div`
|
|
45
|
+
* padding: ${ct('padding')};
|
|
46
|
+
* background-color: ${ct('background-color')};
|
|
47
|
+
* `;
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
/**
|
|
51
|
+
* Type utility to extract token string keys from a token definition object.
|
|
52
|
+
*/
|
|
53
|
+
export type ExtractLocalTokenString<T> = T extends Record<string, infer U> ? U extends string ? U : never : never;
|
|
54
|
+
/**
|
|
55
|
+
* Transforms a token object into CSS custom property declarations.
|
|
56
|
+
*
|
|
57
|
+
* @param tokens - Object mapping namespaces to token definitions
|
|
58
|
+
* @param prefix - CSS custom property prefix (default: 'studio-c')
|
|
59
|
+
* @returns Array of CSS custom property declarations
|
|
60
|
+
*
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
export declare const transformLocalTokenObject: (tokens: Record<string, Record<string, string>>, prefix?: string) => string[];
|
|
64
|
+
/**
|
|
65
|
+
* Creates a complete local token system with typed helpers and CSS injection.
|
|
66
|
+
*
|
|
67
|
+
* This function generates the same API as the base library's component token system,
|
|
68
|
+
* allowing consuming applications to create their own component tokens that integrate
|
|
69
|
+
* seamlessly with the base design tokens.
|
|
70
|
+
*
|
|
71
|
+
* @param tokens - Local component token definitions
|
|
72
|
+
* @param options - Configuration options
|
|
73
|
+
* @param options.prefix - CSS custom property prefix (default: 'studio-c')
|
|
74
|
+
* @param options.cssRootSelector - CSS selector for token injection (default: ':root')
|
|
75
|
+
*
|
|
76
|
+
* @returns Object containing token helpers and CSS injection
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const LOCAL_TOKENS = {
|
|
81
|
+
* 'custom-card': {
|
|
82
|
+
* padding: 'var(--studio-s-spacing-16)',
|
|
83
|
+
* bg: 'var(--studio-s-color-white)',
|
|
84
|
+
* },
|
|
85
|
+
* 'custom-panel': {
|
|
86
|
+
* width: '300px',
|
|
87
|
+
* bg: 'var(--studio-s-color-grey10)',
|
|
88
|
+
* },
|
|
89
|
+
* } as const;
|
|
90
|
+
*
|
|
91
|
+
* const {
|
|
92
|
+
* getLocalComponentTokenHelpers,
|
|
93
|
+
* localComponentTokenCss,
|
|
94
|
+
* } = createLocalTokenSystem(LOCAL_TOKENS);
|
|
95
|
+
*
|
|
96
|
+
* // Use in application root
|
|
97
|
+
* <Global styles={[
|
|
98
|
+
* globalStudioTokenCss,
|
|
99
|
+
* semanticStudioTokenCss,
|
|
100
|
+
* componentStudioTokenCss,
|
|
101
|
+
* localComponentTokenCss, // ← Your local tokens
|
|
102
|
+
* ]} />
|
|
103
|
+
*
|
|
104
|
+
* // Use in components
|
|
105
|
+
* const [ct] = getLocalComponentTokenHelpers(['custom-card']);
|
|
106
|
+
* const StyledCard = styled.div`
|
|
107
|
+
* padding: ${ct('padding')};
|
|
108
|
+
* `;
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export declare const createLocalTokenSystem: <T extends Record<string, Record<string, string>>>(tokens: T, options?: {
|
|
112
|
+
prefix?: string;
|
|
113
|
+
cssRootSelector?: string;
|
|
114
|
+
}) => {
|
|
115
|
+
getLocalComponentTokenHelpers: <N extends readonly (keyof T)[]>(namespaces: [...N]) => { [Key in keyof N]: (key: ExtractLocalTokenString<T[N[Key]]>, asKey?: boolean) => string; };
|
|
116
|
+
localComponentTokenCss: import('@emotion/react').SerializedStyles;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Creates a typed token getter function for a single component namespace.
|
|
120
|
+
*
|
|
121
|
+
* Useful for quick components or when you don't need the full token system setup.
|
|
122
|
+
*
|
|
123
|
+
* @param namespace - Component namespace
|
|
124
|
+
* @param prefix - CSS custom property prefix (default: 'studio-c')
|
|
125
|
+
* @returns Typed token getter function
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* // Quick helper for a single component
|
|
130
|
+
* const ct = createLocalComponentHelper<'padding' | 'bg' | 'color'>('quick-widget');
|
|
131
|
+
*
|
|
132
|
+
* const StyledWidget = styled.div`
|
|
133
|
+
* padding: ${ct('padding')};
|
|
134
|
+
* background: ${ct('bg')};
|
|
135
|
+
* color: ${ct('color')};
|
|
136
|
+
* `;
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export declare const createLocalComponentHelper: <TKeys extends string>(namespace: string, prefix?: string) => (key: TKeys, asKey?: boolean) => string;
|
|
140
|
+
/**
|
|
141
|
+
* Creates CSS for injecting local component tokens inline or in specific scopes.
|
|
142
|
+
*
|
|
143
|
+
* Use this when you want to define tokens programmatically or scope them
|
|
144
|
+
* to specific parts of your application.
|
|
145
|
+
*
|
|
146
|
+
* @param tokens - Token definitions
|
|
147
|
+
* @param options - Configuration options
|
|
148
|
+
* @returns Emotion CSS object
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* // Scoped tokens for a specific section
|
|
153
|
+
* const ThemedSection = styled.div`
|
|
154
|
+
* ${createLocalComponentTokenCss({
|
|
155
|
+
* 'custom-card': {
|
|
156
|
+
* 'background-color': 'var(--studio-s-color-grey10)',
|
|
157
|
+
* 'border-color': 'var(--studio-s-color-grey30)',
|
|
158
|
+
* },
|
|
159
|
+
* })}
|
|
160
|
+
* `;
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export declare const createLocalComponentTokenCss: (tokens: Record<string, Record<string, string>>, options?: {
|
|
164
|
+
prefix?: string;
|
|
165
|
+
}) => import('@emotion/react').SerializedStyles;
|
|
166
|
+
//# sourceMappingURL=local-token-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-token-helpers.d.ts","sourceRoot":"","sources":["../../../../../../../packages/libraries/base-ui-components/src/styles/tokens/common/local-token-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAKH;;GAEG;AACH,MAAM,MAAM,uBAAuB,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACtE,CAAC,SAAS,MAAM,GACd,CAAC,GACD,KAAK,GACP,KAAK,CAAC;AAEV;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,WAC5B,OAAO,MAAM,EAAE,OAAO,MAAM,EAAE,MAAM,CAAC,CAAC,sBAE7C,MAAM,EAKN,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,eAAO,MAAM,sBAAsB,6DAGzB,CAAC,YACA;IACP,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;gFA6Ba,CAAC,GAAG,CAAC,CAAC,2EAIR,OAAO,KACZ,MAAM;;CAoCd,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,0BAA0B,oCACH,MAAM,4BAClC,KAAK,UAAU,OAAO,WAC2B,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,4BAA4B,WAC/B,OAAO,MAAM,EAAE,OAAO,MAAM,EAAE,MAAM,CAAC,CAAC,YACrC;IACP,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,8CAOF,CAAC"}
|
package/styles/tokens/index.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { ExtractTokenString } from './common/types';
|
|
|
3
3
|
import { getGlobalToken, getSemanticToken } from './common/token-getters';
|
|
4
4
|
|
|
5
5
|
export { getGlobalToken, getSemanticToken };
|
|
6
|
+
export { createLocalTokenSystem, createLocalComponentHelper, createLocalComponentTokenCss, transformLocalTokenObject, } from './common/local-token-helpers';
|
|
7
|
+
export type { ExtractLocalTokenString } from './common/local-token-helpers';
|
|
6
8
|
export { TagColor };
|
|
7
9
|
export declare const getComponentTokenHelpers: <T extends readonly ("link" | "multi-select" | "shell-icon-button" | "file-picker" | "resizable-panels" | "table" | "artifact-store-settings" | "branded-header" | "ingredient-card" | "error-list-item" | "named-list-item" | "shell-menu" | "select-view-list" | "badge" | "radio-button" | "combobox" | "version-list-container" | "version-list-header" | "toggle-container" | "toggle-track" | "toggle-thumb" | "textarea" | "tag" | "tab" | "text" | "label" | "label-with-action" | "label-with-content-link" | "button" | "select" | "option" | "segmented" | "named-section" | "named-section-header" | "modal" | "input" | "image-config-page-header" | "icon" | "icon-button" | "horizontal-rule" | "form" | "drawer" | "collapsible-list-container" | "collapsible-list-header-container" | "collapsible-list-toggled-container" | "collapsible-artifact" | "collapsible-artifact-version" | "checkbox" | "artifact-drawer" | "app-shell" | "actionable-blurb")[]>(namespaces: [...T]) => { [Key in keyof T]: (key: ExtractTokenString<{
|
|
8
10
|
readonly "multi-select": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/libraries/base-ui-components/src/styles/tokens/index.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,gBAAgB,EAEjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sour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