@akinon/ui-theme 1.0.1 → 1.0.2

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.
@@ -20,6 +20,14 @@ export type DefaultThemeConfig = ThemeConfig & {
20
20
  * to learn about properties and their effects.
21
21
  */
22
22
  export declare const theme: DefaultThemeConfig;
23
+ /**
24
+ * Safely retrieves CustomTokens from theme with fallback to default values.
25
+ * This prevents undefined access errors when theme is not properly initialized.
26
+ *
27
+ * @param theme - The theme object from ConfigProvider context
28
+ * @returns CustomTokens with guaranteed defined values
29
+ */
30
+ export declare function getSafeCustomTokens(theme: any): CustomTokens;
23
31
  /**
24
32
  * Used to access antd's token values from react components.
25
33
  * For detailed usage see,
@@ -1 +1 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAevD,OAAO,EAML,YAAY,EAUZ,YAAY,EAWb,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,QAAQ,KAAK,CAAC;AAE3B,KAAK,SAAS,GACV,QAAQ,GACR,OAAO,GACP,MAAM,GACN,QAAQ,GACR,KAAK,GACL,OAAO,GACP,MAAM,GACN,QAAQ,GACR,MAAM,GACN,WAAW,GACX,SAAS,CAAC;AAEd,KAAK,KAAK,GAAG;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,KAAK,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AAevC,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,YAAY,CAAC;IAC5B,YAAY,EAAE,YAAY,CAAC;CAC5B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,EAAE,kBAgmBnB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,OAAO,SAAS,CAAC,QAA6B,CAAC;AAEtE;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;CA2B3B,CAAC"}
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAevD,OAAO,EAML,YAAY,EAWZ,YAAY,EAWb,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,QAAQ,KAAK,CAAC;AAE3B,KAAK,SAAS,GACV,QAAQ,GACR,OAAO,GACP,MAAM,GACN,QAAQ,GACR,KAAK,GACL,OAAO,GACP,MAAM,GACN,QAAQ,GACR,MAAM,GACN,WAAW,GACX,SAAS,CAAC;AAEd,KAAK,KAAK,GAAG;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,KAAK,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AAevC,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,YAAY,CAAC;IAC5B,YAAY,EAAE,YAAY,CAAC;CAC5B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,EAAE,kBAgmBnB,CAAC;AAyFF;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,GAAG,GAAG,YAAY,CAmB5D;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,OAAO,SAAS,CAAC,QAA6B,CAAC;AAEtE;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;CA2B3B,CAAC"}
package/dist/cjs/theme.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCssVariables = exports.useToken = exports.theme = exports.fontSize = void 0;
4
+ exports.getSafeCustomTokens = getSafeCustomTokens;
4
5
  const antd_1 = require("antd");
5
6
  const colors_1 = require("./colors");
6
7
  // antd works with numbers. use this to convert px to rem.
@@ -630,6 +631,114 @@ exports.theme = {
630
631
  }
631
632
  }
632
633
  };
634
+ /**
635
+ * Default CustomTokens fallback values to prevent undefined access errors.
636
+ * This provides a complete fallback structure matching the CustomTokens interface.
637
+ */
638
+ const defaultCustomTokens = {
639
+ layout: {
640
+ displayFlex: 'flex',
641
+ displayGrid: 'grid',
642
+ displayBlock: 'block',
643
+ displayInline: 'inline',
644
+ displayInlineBlock: 'inline-block',
645
+ displayNone: 'none',
646
+ displayContents: 'contents',
647
+ positionAbsolute: 'absolute',
648
+ positionRelative: 'relative',
649
+ positionFixed: 'fixed',
650
+ positionSticky: 'sticky',
651
+ positionStatic: 'static',
652
+ flexStart: 'start',
653
+ flexCenter: 'center',
654
+ flexDirectionRow: 'row',
655
+ flexDirectionRowReverse: 'row-reverse',
656
+ flexDirectionColumn: 'column',
657
+ flexDirectionColumnReverse: 'column-reverse'
658
+ },
659
+ typography: {
660
+ textTransformUppercase: 'uppercase',
661
+ textTransformLowercase: 'lowercase',
662
+ textTransformCapitalize: 'capitalize',
663
+ textAlignLeft: 'left',
664
+ textAlignCenter: 'center',
665
+ textAlignRight: 'right',
666
+ textAlignJustify: 'justify',
667
+ whiteSpaceNormal: 'normal',
668
+ whiteSpaceNoWrap: 'nowrap',
669
+ whiteSpacePre: 'pre',
670
+ whiteSpacePreLine: 'pre-line',
671
+ whiteSpacePreWrap: 'pre-wrap',
672
+ whiteSpaceBreakSpaces: 'break-spaces',
673
+ wordBreak: 'break-word',
674
+ textDecorationUnderline: 'underline',
675
+ textDecorationOverline: 'overline',
676
+ textDecorationLineThrough: 'line-through',
677
+ fontWeightBold: '600',
678
+ fontWeightMedium: '500'
679
+ },
680
+ sizing: {
681
+ sizeMaxContent: 'max-content',
682
+ sizeMinContent: 'min-content',
683
+ sizeFitContent: 'fit-content',
684
+ valueFull: '100%',
685
+ valueThreeQuarter: '75%',
686
+ valueHalf: '50%',
687
+ valueQuarter: '25%',
688
+ valueZero: '0',
689
+ valueAuto: 'auto',
690
+ valueInherit: 'inherit'
691
+ },
692
+ others: {
693
+ colorTransparent: 'transparent',
694
+ valueHidden: 'hidden',
695
+ valueUnset: 'unset',
696
+ emptyContent: '""',
697
+ lineHeightShort: '1',
698
+ lineHeightTall: '2',
699
+ cursorNotAllowed: 'not-allowed',
700
+ cursorPointer: 'pointer',
701
+ verticalAlignMiddle: 'middle',
702
+ opacityFull: '1',
703
+ opacityNone: '0'
704
+ },
705
+ border: {
706
+ borderNone: 'none',
707
+ borderSolid: 'solid',
708
+ borderDashed: 'dashed',
709
+ borderDotted: 'dotted',
710
+ borderWidthThin: '1px',
711
+ borderWidthThick: '2px',
712
+ borderRadiusSm: '0.125rem'
713
+ },
714
+ overflow: {
715
+ overflowVisible: 'visible',
716
+ overflowHidden: 'hidden',
717
+ overflowScroll: 'scroll'
718
+ }
719
+ };
720
+ /**
721
+ * Safely retrieves CustomTokens from theme with fallback to default values.
722
+ * This prevents undefined access errors when theme is not properly initialized.
723
+ *
724
+ * @param theme - The theme object from ConfigProvider context
725
+ * @returns CustomTokens with guaranteed defined values
726
+ */
727
+ function getSafeCustomTokens(theme) {
728
+ const themeCustomTokens = theme === null || theme === void 0 ? void 0 : theme.CustomTokens;
729
+ if (!themeCustomTokens) {
730
+ return defaultCustomTokens;
731
+ }
732
+ // Deep merge to ensure all nested properties are available
733
+ return {
734
+ layout: Object.assign(Object.assign({}, defaultCustomTokens.layout), themeCustomTokens.layout),
735
+ typography: Object.assign(Object.assign({}, defaultCustomTokens.typography), themeCustomTokens.typography),
736
+ sizing: Object.assign(Object.assign({}, defaultCustomTokens.sizing), themeCustomTokens.sizing),
737
+ others: Object.assign(Object.assign({}, defaultCustomTokens.others), themeCustomTokens.others),
738
+ border: Object.assign(Object.assign({}, defaultCustomTokens.border), themeCustomTokens.border),
739
+ overflow: Object.assign(Object.assign({}, defaultCustomTokens.overflow), themeCustomTokens.overflow)
740
+ };
741
+ }
633
742
  /**
634
743
  * Used to access antd's token values from react components.
635
744
  * For detailed usage see,
@@ -20,6 +20,14 @@ export type DefaultThemeConfig = ThemeConfig & {
20
20
  * to learn about properties and their effects.
21
21
  */
22
22
  export declare const theme: DefaultThemeConfig;
23
+ /**
24
+ * Safely retrieves CustomTokens from theme with fallback to default values.
25
+ * This prevents undefined access errors when theme is not properly initialized.
26
+ *
27
+ * @param theme - The theme object from ConfigProvider context
28
+ * @returns CustomTokens with guaranteed defined values
29
+ */
30
+ export declare function getSafeCustomTokens(theme: any): CustomTokens;
23
31
  /**
24
32
  * Used to access antd's token values from react components.
25
33
  * For detailed usage see,
@@ -1 +1 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAevD,OAAO,EAML,YAAY,EAUZ,YAAY,EAWb,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,QAAQ,KAAK,CAAC;AAE3B,KAAK,SAAS,GACV,QAAQ,GACR,OAAO,GACP,MAAM,GACN,QAAQ,GACR,KAAK,GACL,OAAO,GACP,MAAM,GACN,QAAQ,GACR,MAAM,GACN,WAAW,GACX,SAAS,CAAC;AAEd,KAAK,KAAK,GAAG;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,KAAK,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AAevC,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,YAAY,CAAC;IAC5B,YAAY,EAAE,YAAY,CAAC;CAC5B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,EAAE,kBAgmBnB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,OAAO,SAAS,CAAC,QAA6B,CAAC;AAEtE;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;CA2B3B,CAAC"}
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAevD,OAAO,EAML,YAAY,EAWZ,YAAY,EAWb,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,QAAQ,KAAK,CAAC;AAE3B,KAAK,SAAS,GACV,QAAQ,GACR,OAAO,GACP,MAAM,GACN,QAAQ,GACR,KAAK,GACL,OAAO,GACP,MAAM,GACN,QAAQ,GACR,MAAM,GACN,WAAW,GACX,SAAS,CAAC;AAEd,KAAK,KAAK,GAAG;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,KAAK,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AAevC,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,YAAY,CAAC;IAC5B,YAAY,EAAE,YAAY,CAAC;CAC5B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,EAAE,kBAgmBnB,CAAC;AAyFF;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,GAAG,GAAG,YAAY,CAmB5D;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,OAAO,SAAS,CAAC,QAA6B,CAAC;AAEtE;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;CA2B3B,CAAC"}
package/dist/esm/theme.js CHANGED
@@ -627,6 +627,114 @@ export const theme = {
627
627
  }
628
628
  }
629
629
  };
630
+ /**
631
+ * Default CustomTokens fallback values to prevent undefined access errors.
632
+ * This provides a complete fallback structure matching the CustomTokens interface.
633
+ */
634
+ const defaultCustomTokens = {
635
+ layout: {
636
+ displayFlex: 'flex',
637
+ displayGrid: 'grid',
638
+ displayBlock: 'block',
639
+ displayInline: 'inline',
640
+ displayInlineBlock: 'inline-block',
641
+ displayNone: 'none',
642
+ displayContents: 'contents',
643
+ positionAbsolute: 'absolute',
644
+ positionRelative: 'relative',
645
+ positionFixed: 'fixed',
646
+ positionSticky: 'sticky',
647
+ positionStatic: 'static',
648
+ flexStart: 'start',
649
+ flexCenter: 'center',
650
+ flexDirectionRow: 'row',
651
+ flexDirectionRowReverse: 'row-reverse',
652
+ flexDirectionColumn: 'column',
653
+ flexDirectionColumnReverse: 'column-reverse'
654
+ },
655
+ typography: {
656
+ textTransformUppercase: 'uppercase',
657
+ textTransformLowercase: 'lowercase',
658
+ textTransformCapitalize: 'capitalize',
659
+ textAlignLeft: 'left',
660
+ textAlignCenter: 'center',
661
+ textAlignRight: 'right',
662
+ textAlignJustify: 'justify',
663
+ whiteSpaceNormal: 'normal',
664
+ whiteSpaceNoWrap: 'nowrap',
665
+ whiteSpacePre: 'pre',
666
+ whiteSpacePreLine: 'pre-line',
667
+ whiteSpacePreWrap: 'pre-wrap',
668
+ whiteSpaceBreakSpaces: 'break-spaces',
669
+ wordBreak: 'break-word',
670
+ textDecorationUnderline: 'underline',
671
+ textDecorationOverline: 'overline',
672
+ textDecorationLineThrough: 'line-through',
673
+ fontWeightBold: '600',
674
+ fontWeightMedium: '500'
675
+ },
676
+ sizing: {
677
+ sizeMaxContent: 'max-content',
678
+ sizeMinContent: 'min-content',
679
+ sizeFitContent: 'fit-content',
680
+ valueFull: '100%',
681
+ valueThreeQuarter: '75%',
682
+ valueHalf: '50%',
683
+ valueQuarter: '25%',
684
+ valueZero: '0',
685
+ valueAuto: 'auto',
686
+ valueInherit: 'inherit'
687
+ },
688
+ others: {
689
+ colorTransparent: 'transparent',
690
+ valueHidden: 'hidden',
691
+ valueUnset: 'unset',
692
+ emptyContent: '""',
693
+ lineHeightShort: '1',
694
+ lineHeightTall: '2',
695
+ cursorNotAllowed: 'not-allowed',
696
+ cursorPointer: 'pointer',
697
+ verticalAlignMiddle: 'middle',
698
+ opacityFull: '1',
699
+ opacityNone: '0'
700
+ },
701
+ border: {
702
+ borderNone: 'none',
703
+ borderSolid: 'solid',
704
+ borderDashed: 'dashed',
705
+ borderDotted: 'dotted',
706
+ borderWidthThin: '1px',
707
+ borderWidthThick: '2px',
708
+ borderRadiusSm: '0.125rem'
709
+ },
710
+ overflow: {
711
+ overflowVisible: 'visible',
712
+ overflowHidden: 'hidden',
713
+ overflowScroll: 'scroll'
714
+ }
715
+ };
716
+ /**
717
+ * Safely retrieves CustomTokens from theme with fallback to default values.
718
+ * This prevents undefined access errors when theme is not properly initialized.
719
+ *
720
+ * @param theme - The theme object from ConfigProvider context
721
+ * @returns CustomTokens with guaranteed defined values
722
+ */
723
+ export function getSafeCustomTokens(theme) {
724
+ const themeCustomTokens = theme === null || theme === void 0 ? void 0 : theme.CustomTokens;
725
+ if (!themeCustomTokens) {
726
+ return defaultCustomTokens;
727
+ }
728
+ // Deep merge to ensure all nested properties are available
729
+ return {
730
+ layout: Object.assign(Object.assign({}, defaultCustomTokens.layout), themeCustomTokens.layout),
731
+ typography: Object.assign(Object.assign({}, defaultCustomTokens.typography), themeCustomTokens.typography),
732
+ sizing: Object.assign(Object.assign({}, defaultCustomTokens.sizing), themeCustomTokens.sizing),
733
+ others: Object.assign(Object.assign({}, defaultCustomTokens.others), themeCustomTokens.others),
734
+ border: Object.assign(Object.assign({}, defaultCustomTokens.border), themeCustomTokens.border),
735
+ overflow: Object.assign(Object.assign({}, defaultCustomTokens.overflow), themeCustomTokens.overflow)
736
+ };
737
+ }
630
738
  /**
631
739
  * Used to access antd's token values from react components.
632
740
  * For detailed usage see,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/ui-theme",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "private": false,
5
5
  "description": "Akinon UI's default theme values.",
6
6
  "type": "module",