@prizmui/components 0.0.1 → 0.0.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"useButton.d.ts","sourceRoot":"","sources":["../../../src/components/Button/useButton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE/D,eAAO,MAAM,SAAS,GAAI,OAAO,WAAW,KAAG,WAiB9C,CAAC"}
1
+ {"version":3,"file":"useButton.d.ts","sourceRoot":"","sources":["../../../src/components/Button/useButton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE/D,eAAO,MAAM,SAAS,GAAI,OAAO,WAAW,KAAG,WAkB9C,CAAC"}
@@ -1,14 +1,15 @@
1
1
  export const useButton = (props) => {
2
- const { appearance, disabled, shape, size } = props;
2
+ const { appearance, disabled, shape, size, as: asProp, ...rootProps } = props;
3
3
  const state = {
4
4
  appearance: appearance ?? 'secondary',
5
5
  disabled: disabled ?? false,
6
6
  shape: shape ?? 'rounded',
7
7
  size: size ?? 'medium',
8
- components: { root: 'button' },
8
+ components: { root: asProp ?? 'button' },
9
9
  root: {
10
- type: props.as !== 'a' ? 'button' : undefined
11
- }
10
+ ...rootProps,
11
+ ...(!asProp || asProp === 'button' ? { type: 'button' } : {}),
12
+ },
12
13
  };
13
14
  return state;
14
15
  };
@@ -1 +1 @@
1
- {"version":3,"file":"assertSlots.d.ts","sourceRoot":"","sources":["../../src/utilities/assertSlots.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAgB,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,WAAW,CAAC,MAAM,SAAS,eAAe,EACtD,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,GAC9B,OAAO,CAAC,KAAK,IAAI,cAAc,CAAC,MAAM,CAAC,GAAG;KAAG,CAAC,IAAI,MAAM,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAAE,CA6BhG"}
1
+ {"version":3,"file":"assertSlots.d.ts","sourceRoot":"","sources":["../../src/utilities/assertSlots.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAgB,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,WAAW,CAAC,MAAM,SAAS,eAAe,EACtD,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,GAC9B,OAAO,CAAC,KAAK,IAAI,cAAc,CAAC,MAAM,CAAC,GAAG;KAAG,CAAC,IAAI,MAAM,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAAE,CAkChG"}
@@ -39,14 +39,17 @@ export function assertSlots(state) {
39
39
  // Explicit JSX children (extraProps.children) only override baked-in
40
40
  // children when they are not undefined, so callers can safely write
41
41
  // <state.root>{someVar}</state.root> even when someVar is undefined.
42
- state[slotName] =
43
- (extraProps = {}) => {
44
- const { children: explicitChildren, ...otherExtra } = extraProps;
45
- return jsx(Component, {
46
- ...slotProps,
47
- ...otherExtra,
48
- ...(explicitChildren !== undefined && { children: explicitChildren }),
49
- });
50
- };
42
+ const fn = (extraProps = {}) => {
43
+ const { children: explicitChildren, ...otherExtra } = extraProps;
44
+ return jsx(Component, {
45
+ ...slotProps,
46
+ ...otherExtra,
47
+ ...(explicitChildren !== undefined && { children: explicitChildren }),
48
+ });
49
+ };
50
+ // Attach original props onto the function so callers can still
51
+ // read slot props after assertSlots, e.g. state.root.children.
52
+ Object.assign(fn, slotProps);
53
+ state[slotName] = fn;
51
54
  }
52
55
  }
package/package.json CHANGED
@@ -1,32 +1,32 @@
1
1
  {
2
- "name": "@prizmui/components",
3
- "version": "0.0.1",
4
- "type": "module",
5
- "main": "./dist/index.js",
6
- "types": "./dist/index.d.ts",
7
- "exports": {
8
- ".": {
9
- "import": "./dist/index.js",
10
- "types": "./dist/index.d.ts"
11
- }
12
- },
13
- "files": [
14
- "dist"
15
- ],
16
- "scripts": {
17
- "build": "tsc",
18
- "dev": "tsc --watch",
19
- "typecheck": "tsc --noEmit"
20
- },
21
- "dependencies": {
22
- "calame": "workspace:*",
23
- "@prizmui/tokens": "workspace:*"
24
- },
25
- "peerDependencies": {
26
- "jsx-framework-test-pb": "*"
27
- },
28
- "devDependencies": {
29
- "jsx-framework-test-pb": "latest",
30
- "typescript": "^5.9.3"
2
+ "name": "@prizmui/components",
3
+ "version": "0.0.4",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "types": "./dist/index.d.ts"
31
11
  }
32
- }
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "dependencies": {
17
+ "calame": "0.0.6",
18
+ "@prizmui/tokens": "0.0.1"
19
+ },
20
+ "peerDependencies": {
21
+ "jsx-framework-test-pb": "*"
22
+ },
23
+ "devDependencies": {
24
+ "jsx-framework-test-pb": "latest",
25
+ "typescript": "^5.9.3"
26
+ },
27
+ "scripts": {
28
+ "build": "tsc",
29
+ "dev": "tsc --watch",
30
+ "typecheck": "tsc --noEmit"
31
+ }
32
+ }