@prizmui/components 0.0.2 → 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,
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
}
|