jattac.libs.web.zest-button 1.2.6 → 1.2.7
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/ZestButtonConfigContext.d.ts +9 -0
- package/dist/ZestButtonConfigProvider.d.ts +8 -0
- package/dist/index.cjs.js +12 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.esm.js +11 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/semanticTypeButtonConfigDefaults.d.ts +4 -0
- package/docs/api.md +1 -1
- package/docs/breaking-changes.md +40 -0
- package/docs/configuration.md +18 -18
- package/docs/examples.md +8 -8
- package/docs/features.md +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ZestCustomProps } from './ZestButton';
|
|
3
|
+
export interface ZestGlobalConfig {
|
|
4
|
+
defaultProps?: ZestCustomProps;
|
|
5
|
+
semanticTypeDefaults?: Partial<Record<string, Partial<ZestCustomProps>>>;
|
|
6
|
+
}
|
|
7
|
+
declare const ZestButtonConfigContext: React.Context<ZestGlobalConfig | undefined>;
|
|
8
|
+
export declare const useZestButtonConfig: () => ZestGlobalConfig | undefined;
|
|
9
|
+
export default ZestButtonConfigContext;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ZestGlobalConfig } from './ZestButtonConfigContext';
|
|
3
|
+
interface ZestButtonConfigProviderProps {
|
|
4
|
+
config: ZestGlobalConfig;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
declare const ZestButtonConfigProvider: React.FC<ZestButtonConfigProviderProps>;
|
|
8
|
+
export default ZestButtonConfigProvider;
|
package/dist/index.cjs.js
CHANGED
|
@@ -1391,18 +1391,18 @@ var styles = {"force-light":"ZestButton-module_force-light__zZTIZ","force-dark":
|
|
|
1391
1391
|
styleInject(css_248z);
|
|
1392
1392
|
|
|
1393
1393
|
// Create the Zest Context with a default empty configuration
|
|
1394
|
-
const
|
|
1394
|
+
const ZestButtonConfigContext = require$$0.createContext(undefined);
|
|
1395
1395
|
// Custom hook to use the Zest Context
|
|
1396
|
-
const
|
|
1397
|
-
const context = require$$0.useContext(
|
|
1396
|
+
const useZestButtonConfig = () => {
|
|
1397
|
+
const context = require$$0.useContext(ZestButtonConfigContext);
|
|
1398
1398
|
// Optional: Add a check here if context is undefined, meaning provider is not used
|
|
1399
1399
|
// if (context === undefined) {
|
|
1400
|
-
// console.warn("
|
|
1400
|
+
// console.warn("useZestButtonConfig must be used within a ZestButtonConfigProvider. Falling back to default ZestButton props.");
|
|
1401
1401
|
// }
|
|
1402
1402
|
return context;
|
|
1403
1403
|
};
|
|
1404
1404
|
|
|
1405
|
-
const
|
|
1405
|
+
const semanticTypeButtonConfigDefaults = {
|
|
1406
1406
|
// Creation / Add
|
|
1407
1407
|
'add': {
|
|
1408
1408
|
visualOptions: {
|
|
@@ -1573,7 +1573,7 @@ const deepMerge = (target, source) => {
|
|
|
1573
1573
|
return output;
|
|
1574
1574
|
};
|
|
1575
1575
|
const useZestConfig = (localZestProps) => {
|
|
1576
|
-
const globalConfig =
|
|
1576
|
+
const globalConfig = useZestButtonConfig();
|
|
1577
1577
|
const globalDefaultProps = globalConfig?.defaultProps;
|
|
1578
1578
|
const customSemanticDefaults = globalConfig?.semanticTypeDefaults;
|
|
1579
1579
|
// 1. Start with global defaults (lowest precedence)
|
|
@@ -1582,8 +1582,8 @@ const useZestConfig = (localZestProps) => {
|
|
|
1582
1582
|
const semanticType = localZestProps?.semanticType || effectiveZestConfig.semanticType;
|
|
1583
1583
|
if (semanticType) {
|
|
1584
1584
|
// 2. Apply built-in semantic defaults
|
|
1585
|
-
if (
|
|
1586
|
-
effectiveZestConfig = deepMerge(effectiveZestConfig,
|
|
1585
|
+
if (semanticTypeButtonConfigDefaults[semanticType]) {
|
|
1586
|
+
effectiveZestConfig = deepMerge(effectiveZestConfig, semanticTypeButtonConfigDefaults[semanticType]);
|
|
1587
1587
|
}
|
|
1588
1588
|
// 3. Apply custom semantic defaults from provider (overrides built-in ones)
|
|
1589
1589
|
if (customSemanticDefaults && customSemanticDefaults[semanticType]) {
|
|
@@ -1851,11 +1851,11 @@ const ZestButton = ({ className = "", disabled, children, onClick, zest: localZe
|
|
|
1851
1851
|
].join(" "), disabled: isDisabled, "aria-busy": effectiveBusy, onClick: handleConfirmClick, ...props, children: jsxRuntimeExports.jsxs("span", { className: styles.inner, children: [renderLeftIcon(), jsxRuntimeExports.jsxs("span", { className: styles.content, children: [currentChildren, iconRight && jsxRuntimeExports.jsx("span", { className: styles.icon, children: iconRight })] })] }) }));
|
|
1852
1852
|
};
|
|
1853
1853
|
|
|
1854
|
-
const
|
|
1855
|
-
return (jsxRuntimeExports.jsx(
|
|
1854
|
+
const ZestButtonConfigProvider = ({ config, children }) => {
|
|
1855
|
+
return (jsxRuntimeExports.jsx(ZestButtonConfigContext.Provider, { value: config, children: children }));
|
|
1856
1856
|
};
|
|
1857
1857
|
|
|
1858
1858
|
exports.ZestButton = ZestButton;
|
|
1859
|
-
exports.
|
|
1860
|
-
exports.
|
|
1859
|
+
exports.ZestButtonConfigProvider = ZestButtonConfigProvider;
|
|
1860
|
+
exports.useZestButtonConfig = useZestButtonConfig;
|
|
1861
1861
|
//# sourceMappingURL=index.cjs.js.map
|