@kalink-ui/seedly 0.1.1 → 0.2.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/.storybook/main.mts +16 -0
- package/.storybook/preview.ts +27 -0
- package/.storybook/theme/ref.css.ts +63 -0
- package/.storybook/theme/sprinkles.css.ts +40 -0
- package/.storybook/theme/theme.css.ts +293 -0
- package/.turbo/turbo-lint.log +82 -0
- package/.turbo/turbo-tsc.log +227 -0
- package/CHANGELOG.md +25 -0
- package/dist/utils.types.d.mts +9 -0
- package/dist/utils.types.d.ts +9 -0
- package/dist/utils.types.js +19 -0
- package/dist/utils.types.js.map +1 -0
- package/dist/utils.types.mjs +1 -0
- package/dist/utils.types.mjs.map +1 -0
- package/eslint.config.mts +3 -0
- package/package.json +14 -17
- package/tsconfig.json +14 -0
- package/tsup.config.ts +18 -0
- package/turbo/generators/config.ts +35 -0
- package/turbo/generators/templates/component.hbs +21 -0
- package/turbo/generators/templates/export.hbs +5 -0
- package/turbo/generators/templates/style.hbs +3 -0
- package/vite.config.mts +9 -0
- package/src/components/.DS_Store +0 -0
- package/src/components/box/box.stories.tsx +0 -29
- package/src/components/button/button.stories.tsx +0 -31
- package/src/components/center/.DS_Store +0 -0
- package/src/components/center/center.stories.tsx +0 -31
- package/src/components/cluster/.DS_Store +0 -0
- package/src/components/cluster/cluster.stories.tsx +0 -37
- package/src/components/cover/.DS_Store +0 -0
- package/src/components/cover/cover.stories.tsx +0 -45
- package/src/components/frame/.DS_Store +0 -0
- package/src/components/frame/frame.stories.tsx +0 -39
- package/src/components/grid/.DS_Store +0 -0
- package/src/components/grid/grid.stories.tsx +0 -50
- package/src/components/layout.mdx +0 -206
- package/src/components/sidebar/.DS_Store +0 -0
- package/src/components/sidebar/sidebar.stories.tsx +0 -60
- package/src/components/stack/.DS_Store +0 -0
- package/src/components/stack/stack.stories.tsx +0 -72
- package/src/components/switcher/.DS_Store +0 -0
- package/src/components/switcher/switcher.stories.tsx +0 -66
- package/src/styles/seed/.DS_Store +0 -0
- package/src/styles/seed/seed.stories.tsx +0 -52
- package/src/styles/styles.mdx +0 -98
- package/src/utils/__tests__/extract-sprinkles-props.test.ts +0 -101
- package/src/utils/__tests__/is-object.test.ts +0 -24
- package/src/utils/__tests__/map-contract-vars.test.ts +0 -34
- package/src/utils/arg-types/.DS_Store +0 -0
- package/src/utils/arg-types/arg-types-from-recipe.ts +0 -37
- package/src/utils/arg-types/arg-types-from-sprinkles.ts +0 -43
- package/src/utils/arg-types/common/composable.ts +0 -13
- package/src/utils/arg-types/common/index.ts +0 -4
- package/src/utils/arg-types/common/polymorphic.ts +0 -14
- package/src/utils/arg-types/common/referable.ts +0 -10
- package/src/utils/arg-types/common/stylable.ts +0 -14
- package/src/utils/arg-types/common-args.ts +0 -26
- package/src/utils/arg-types/index.ts +0 -3
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { describe, test } from '@std/testing/bdd';
|
|
2
|
-
import { spy } from '@std/testing/mock';
|
|
3
|
-
import { expect } from '@std/expect';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
extractSprinklesProps,
|
|
7
|
-
type SprinklesFnBase,
|
|
8
|
-
} from '@/utils/extract-sprinkles-props';
|
|
9
|
-
|
|
10
|
-
describe('extractSprinklesProps', () => {
|
|
11
|
-
const mockSprinkles: SprinklesFnBase = {
|
|
12
|
-
properties: new Set(['color', 'fontSize', 'padding']),
|
|
13
|
-
} as SprinklesFnBase;
|
|
14
|
-
|
|
15
|
-
test('should correctly separate sprinkles props from component props', () => {
|
|
16
|
-
const props = {
|
|
17
|
-
color: 'red',
|
|
18
|
-
fontSize: '16px',
|
|
19
|
-
padding: '10px',
|
|
20
|
-
onClick: spy(),
|
|
21
|
-
className: 'custom-class',
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const [sprinkleProps, componentProps] = extractSprinklesProps(
|
|
25
|
-
props,
|
|
26
|
-
mockSprinkles,
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
expect(sprinkleProps).toEqual({
|
|
30
|
-
color: 'red',
|
|
31
|
-
fontSize: '16px',
|
|
32
|
-
padding: '10px',
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
expect(componentProps).toEqual({
|
|
36
|
-
onClick: expect.any(Function),
|
|
37
|
-
className: 'custom-class',
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test('should handle props with no sprinkles properties', () => {
|
|
42
|
-
const props = {
|
|
43
|
-
onClick: spy(),
|
|
44
|
-
className: 'custom-class',
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const [sprinkleProps, componentProps] = extractSprinklesProps(
|
|
48
|
-
props,
|
|
49
|
-
mockSprinkles,
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
expect(sprinkleProps).toEqual({});
|
|
53
|
-
expect(componentProps).toEqual(props);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test('should handle props with only sprinkles properties', () => {
|
|
57
|
-
const props = {
|
|
58
|
-
color: 'blue',
|
|
59
|
-
fontSize: '14px',
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const [sprinkleProps, componentProps] = extractSprinklesProps(
|
|
63
|
-
props,
|
|
64
|
-
mockSprinkles,
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
expect(sprinkleProps).toEqual(props);
|
|
68
|
-
expect(componentProps).toEqual({});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test('should handle empty props object', () => {
|
|
72
|
-
const props = {};
|
|
73
|
-
|
|
74
|
-
const [sprinkleProps, componentProps] = extractSprinklesProps(
|
|
75
|
-
props,
|
|
76
|
-
mockSprinkles,
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
expect(sprinkleProps).toEqual({});
|
|
80
|
-
expect(componentProps).toEqual({});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test('should handle sprinkles function with empty properties set', () => {
|
|
84
|
-
const emptySprinkles: SprinklesFnBase = {
|
|
85
|
-
properties: new Set(),
|
|
86
|
-
} as SprinklesFnBase;
|
|
87
|
-
|
|
88
|
-
const props = {
|
|
89
|
-
color: 'green',
|
|
90
|
-
onClick: spy(),
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const [sprinkleProps, componentProps] = extractSprinklesProps(
|
|
94
|
-
props,
|
|
95
|
-
emptySprinkles,
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
expect(sprinkleProps).toEqual({});
|
|
99
|
-
expect(componentProps).toEqual(props);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { isObject } from "@/utils/is-object.ts";
|
|
2
|
-
import { describe, it } from "@std/testing/bdd";
|
|
3
|
-
import { expect } from "@std/expect";
|
|
4
|
-
|
|
5
|
-
describe("isObject", () => {
|
|
6
|
-
it("should return true if value is an object", () => {
|
|
7
|
-
expect(isObject({})).toEqual(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it("should return false if value is an array", () => {
|
|
11
|
-
expect(isObject([])).toEqual(false);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("should return false if value is null or undefined", () => {
|
|
15
|
-
expect(isObject(null)).toEqual(false);
|
|
16
|
-
expect(isObject(undefined)).toEqual(false);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("should return false if value is any scalar", () => {
|
|
20
|
-
expect(isObject(1)).toEqual(false);
|
|
21
|
-
expect(isObject("foo")).toEqual(false);
|
|
22
|
-
expect(isObject(true)).toEqual(false);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { mapContractVars } from "@/utils/map-contract-vars.ts";
|
|
2
|
-
import { describe, test } from "@std/testing/bdd";
|
|
3
|
-
import { expect } from "@std/expect";
|
|
4
|
-
|
|
5
|
-
describe("mapContractVars", () => {
|
|
6
|
-
test("should map contract vars", () => {
|
|
7
|
-
const contract = {
|
|
8
|
-
foo: "foo",
|
|
9
|
-
bar: "bar",
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const result = mapContractVars(contract, (key) => ({
|
|
13
|
-
padding: `var(--${key})`,
|
|
14
|
-
vars: {
|
|
15
|
-
[`--${key}`]: contract[key],
|
|
16
|
-
},
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
expect(result).toEqual({
|
|
20
|
-
foo: {
|
|
21
|
-
padding: "var(--foo)",
|
|
22
|
-
vars: {
|
|
23
|
-
"--foo": "foo",
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
bar: {
|
|
27
|
-
padding: "var(--bar)",
|
|
28
|
-
vars: {
|
|
29
|
-
"--bar": "bar",
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
});
|
|
Binary file
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { type ComplexStyleRule } from '@vanilla-extract/css';
|
|
2
|
-
import { type RuntimeFn } from '@vanilla-extract/recipes';
|
|
3
|
-
|
|
4
|
-
type RecipeStyleRule = ComplexStyleRule | string;
|
|
5
|
-
type VariantDefinitions = Record<string, RecipeStyleRule>;
|
|
6
|
-
type VariantGroups = Record<string, VariantDefinitions>;
|
|
7
|
-
|
|
8
|
-
export function argTypesFromRecipe(
|
|
9
|
-
recipe: RuntimeFn<VariantGroups>,
|
|
10
|
-
excludes: string[] = [],
|
|
11
|
-
) {
|
|
12
|
-
return Object.entries(recipe.classNames.variants).reduce(
|
|
13
|
-
(acc, [name, variant]) => {
|
|
14
|
-
if (excludes.includes(name)) {
|
|
15
|
-
return acc;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const options = Object.keys(variant);
|
|
19
|
-
let control = options.length > 5 ? 'select' : 'radio';
|
|
20
|
-
|
|
21
|
-
if (options.length === 1 && options[0] === 'true') {
|
|
22
|
-
options.push('false');
|
|
23
|
-
control = 'boolean';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
...acc,
|
|
28
|
-
[name]: {
|
|
29
|
-
control,
|
|
30
|
-
options,
|
|
31
|
-
table: { category: 'Styling props' },
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
},
|
|
35
|
-
{},
|
|
36
|
-
);
|
|
37
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { isObject } from '@kalink/ui/utils';
|
|
2
|
-
|
|
3
|
-
type ArgTypesFromSprinklesProps = {
|
|
4
|
-
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
5
|
-
props: Record<string, any>;
|
|
6
|
-
excludes?: string[];
|
|
7
|
-
category?: string;
|
|
8
|
-
} & {};
|
|
9
|
-
|
|
10
|
-
export function argTypesFromSprinkles({
|
|
11
|
-
props,
|
|
12
|
-
excludes = [],
|
|
13
|
-
category = 'Sprinkles props',
|
|
14
|
-
}: ArgTypesFromSprinklesProps) {
|
|
15
|
-
return Object.entries(props).reduce((acc, [name]) => {
|
|
16
|
-
if (Array.isArray(excludes) && excludes.includes(name)) {
|
|
17
|
-
return acc;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let options = props[name] || [];
|
|
21
|
-
let control = 'select';
|
|
22
|
-
|
|
23
|
-
if (options.length === 1 && options[0] === 'true') {
|
|
24
|
-
options.push('false');
|
|
25
|
-
control = 'boolean';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (isObject(options)) {
|
|
29
|
-
options = Object.fromEntries(
|
|
30
|
-
Object.keys(options).map((key) => [key, key]),
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
...acc,
|
|
36
|
-
[name]: {
|
|
37
|
-
control,
|
|
38
|
-
options,
|
|
39
|
-
table: { category },
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
}, {});
|
|
43
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export const polymorphic = {
|
|
2
|
-
use: {
|
|
3
|
-
control: false,
|
|
4
|
-
description:
|
|
5
|
-
'The component used to render the root node of the component. Either a string to use an `JSX.IntrinsicElements` or a component reference to use a `React.ComponentType`',
|
|
6
|
-
defaultValue: '',
|
|
7
|
-
table: {
|
|
8
|
-
category: 'Intrinsic props',
|
|
9
|
-
type: {
|
|
10
|
-
summary: 'ElementType',
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export const stylable = {
|
|
2
|
-
className: {
|
|
3
|
-
control: false,
|
|
4
|
-
description:
|
|
5
|
-
'A class name string passed to the component. Merged with the inner class names.',
|
|
6
|
-
defaultValue: '',
|
|
7
|
-
table: {
|
|
8
|
-
category: 'Intrinsic props',
|
|
9
|
-
type: {
|
|
10
|
-
summary: 'string',
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/namespace */
|
|
2
|
-
import * as CommonArgDefs from './common';
|
|
3
|
-
|
|
4
|
-
export enum CommonArgs {
|
|
5
|
-
COMPOSABLE = 'composable',
|
|
6
|
-
POLYMORPHIC = 'polymorphic',
|
|
7
|
-
STYLABLE = 'stylable',
|
|
8
|
-
REFERABLE = 'referable',
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function commonArgs(args: CommonArgs[]) {
|
|
12
|
-
const argTypes: Partial<Record<string, object>> = {};
|
|
13
|
-
const knownArgs = Object.values(CommonArgs);
|
|
14
|
-
|
|
15
|
-
for (const arg of args) {
|
|
16
|
-
if (!knownArgs.includes(arg)) {
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
for (const argDef in CommonArgDefs[arg]) {
|
|
21
|
-
argTypes[argDef] = (CommonArgDefs[arg] as Record<string, object>)[argDef];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return argTypes;
|
|
26
|
-
}
|