@vaneui/ui 0.2.1-alpha.20250811191248.a18a87d → 0.2.1-alpha.20250813170000.4050860

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.
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom';
@@ -30,6 +30,7 @@ export interface ThemeProps {
30
30
  col: ComponentTheme<ColProps, ColTheme>;
31
31
  stack: ComponentTheme<StackProps, StackTheme>;
32
32
  section: ComponentTheme<SectionProps, SectionTheme>;
33
+ grid2: ComponentTheme<GridProps, GridTheme>;
33
34
  grid3: ComponentTheme<GridProps, GridTheme>;
34
35
  grid4: ComponentTheme<GridProps, GridTheme>;
35
36
  pageTitle: ComponentTheme<TypographyProps, TypographyTheme>;
@@ -77,6 +78,7 @@ export type ThemeDefaults = {
77
78
  col?: Partial<BooleanKeys<ColProps>>;
78
79
  stack?: Partial<BooleanKeys<StackProps>>;
79
80
  section?: Partial<BooleanKeys<SectionProps>>;
81
+ grid2?: Partial<BooleanKeys<GridProps>>;
80
82
  grid3?: Partial<BooleanKeys<GridProps>>;
81
83
  grid4?: Partial<BooleanKeys<GridProps>>;
82
84
  pageTitle?: Partial<BooleanKeys<TypographyProps>>;
@@ -106,6 +108,7 @@ export type ThemeExtraClasses = {
106
108
  col?: Partial<StringValueKeys<ColProps>>;
107
109
  stack?: Partial<StringValueKeys<StackProps>>;
108
110
  section?: Partial<StringValueKeys<SectionProps>>;
111
+ grid2?: Partial<StringValueKeys<GridProps>>;
109
112
  grid3?: Partial<StringValueKeys<GridProps>>;
110
113
  grid4?: Partial<StringValueKeys<GridProps>>;
111
114
  pageTitle?: Partial<StringValueKeys<TypographyProps>>;
@@ -123,13 +126,15 @@ export type ThemeExtraClasses = {
123
126
  label?: Partial<StringValueKeys<LabelProps>>;
124
127
  img?: Partial<StringValueKeys<ImgProps>>;
125
128
  };
129
+ export type MergeStrategy = 'merge' | 'replace';
126
130
  export interface ThemeProviderProps {
127
131
  children: React.ReactNode;
128
132
  theme?: PartialTheme;
129
133
  themeDefaults?: ThemeDefaults;
130
134
  extraClasses?: ThemeExtraClasses;
131
135
  themeOverride?: (theme: ThemeProps) => ThemeProps;
136
+ mergeStrategy?: MergeStrategy;
132
137
  }
133
- export declare function ThemeProvider({ children, theme: themeObject, themeDefaults, extraClasses, themeOverride }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
138
+ export declare function ThemeProvider({ children, theme: themeObject, themeDefaults, extraClasses, themeOverride, mergeStrategy }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
134
139
  export declare function useTheme(): ThemeProps;
135
140
  export {};
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
2
  import { GridProps } from './props/props';
3
+ export declare const Grid2: React.ForwardRefExoticComponent<GridProps & React.RefAttributes<HTMLDivElement>>;
3
4
  export declare const Grid3: React.ForwardRefExoticComponent<GridProps & React.RefAttributes<HTMLDivElement>>;
4
5
  export declare const Grid4: React.ForwardRefExoticComponent<GridProps & React.RefAttributes<HTMLDivElement>>;
@@ -2,6 +2,6 @@ export { Section } from './section';
2
2
  export { Container } from './container';
3
3
  export { Col } from './col';
4
4
  export { Row } from './row';
5
- export { Grid3, Grid4 } from './grid';
5
+ export { Grid2, Grid3, Grid4 } from './grid';
6
6
  export { Card } from './card';
7
7
  export { Stack } from './stack';
@@ -93,6 +93,6 @@ export declare const IMG_CATEGORIES: readonly ["size", "hide", "items", "justify
93
93
  export type CategoryProps = {
94
94
  [K in ComponentCategoryKey]?: (typeof ComponentKeys)[K][number];
95
95
  };
96
- export declare const COMPONENT: readonly ["button", "badge", "chip", "code", "card", "divider", "container", "row", "col", "stack", "section", "grid3", "grid4", "pageTitle", "sectionTitle", "title", "text", "link", "list", "listItem", "checkbox", "label", "img"];
96
+ export declare const COMPONENT: readonly ["button", "badge", "chip", "code", "card", "divider", "container", "row", "col", "stack", "section", "grid2", "grid3", "grid4", "pageTitle", "sectionTitle", "title", "text", "link", "list", "listItem", "checkbox", "label", "img"];
97
97
  export type ComponentKey = typeof COMPONENT[number];
98
98
  export declare const ComponentCategories: Record<ComponentKey, readonly string[]>;
@@ -16,5 +16,6 @@ export interface GridTheme extends BaseComponentTheme {
16
16
  flexDirection: DirectionTheme;
17
17
  };
18
18
  }
19
+ export declare const defaultGrid2Theme: ComponentTheme<GridProps, GridTheme>;
19
20
  export declare const defaultGrid3Theme: ComponentTheme<GridProps, GridTheme>;
20
21
  export declare const defaultGrid4Theme: ComponentTheme<GridProps, GridTheme>;
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export { Code } from "./components/ui/code";
6
6
  export { Checkbox } from "./components/ui/checkbox";
7
7
  export { Label } from "./components/ui/label";
8
8
  export { Img } from "./components/ui/img";
9
- export { Section, Container, Col, Row, Stack, Grid3, Grid4, Card } from "./components/ui/layout";
9
+ export { Section, Container, Col, Row, Stack, Grid2, Grid3, Grid4, Card } from "./components/ui/layout";
10
10
  export { Text, Title, Link, List, ListItem, SectionTitle, PageTitle } from "./components/ui/typography";
11
11
  export { COMPONENT, ComponentKeys, ComponentCategories, type ComponentKey, } from "./components/ui/props/keys";
12
12
  export { ThemeProvider, useTheme, defaultTheme, type ThemeProps, type ThemeDefaults, type ThemeExtraClasses, type ThemeProviderProps, type PartialTheme, } from './components/themeContext';
package/dist/index.esm.js CHANGED
@@ -92,7 +92,7 @@ const LABEL_CATEGORIES = [...TYPOGRAPHY_FULL, ...LAYOUT_FULL, ...VISUAL_CORE];
92
92
  // Media component categories
93
93
  const IMG_CATEGORIES = [...LAYOUT_CORE, ...VISUAL_CORE, ...VISUAL_DECORATION, ...SHAPE];
94
94
  const COMPONENT = ['button', 'badge', 'chip', 'code', 'card', 'divider', 'container', 'row', 'col', 'stack', 'section',
95
- 'grid3', 'grid4', 'pageTitle', 'sectionTitle', 'title', 'text', 'link', 'list', 'listItem', 'checkbox', 'label', 'img'];
95
+ 'grid2', 'grid3', 'grid4', 'pageTitle', 'sectionTitle', 'title', 'text', 'link', 'list', 'listItem', 'checkbox', 'label', 'img'];
96
96
  const ComponentCategories = {
97
97
  badge: BADGE_CATEGORIES,
98
98
  button: BUTTON_CATEGORIES,
@@ -103,6 +103,7 @@ const ComponentCategories = {
103
103
  col: COL_CATEGORIES,
104
104
  container: CONTAINER_CATEGORIES,
105
105
  divider: DIVIDER_CATEGORIES,
106
+ grid2: GRID_CATEGORIES,
106
107
  grid3: GRID_CATEGORIES,
107
108
  grid4: GRID_CATEGORIES,
108
109
  img: IMG_CATEGORIES,
@@ -4641,6 +4642,9 @@ const gridSubThemes = {
4641
4642
  flexDirection: new DirectionTheme(),
4642
4643
  },
4643
4644
  };
4645
+ const defaultGrid2Theme = new ComponentTheme("div", "grid-cols-1 md:grid-cols-2", gridSubThemes, gridDefaults, GRID_CATEGORIES, (props, defaults) => {
4646
+ return props.href ? "a" : "div";
4647
+ });
4644
4648
  const defaultGrid3Theme = new ComponentTheme("div", "grid-cols-1 md:grid-cols-3", gridSubThemes, gridDefaults, GRID_CATEGORIES, (props, defaults) => {
4645
4649
  return props.href ? "a" : "div";
4646
4650
  });
@@ -4771,6 +4775,7 @@ const defaultTheme = {
4771
4775
  col: defaultColTheme,
4772
4776
  stack: defaultStackTheme,
4773
4777
  section: defaultSectionTheme,
4778
+ grid2: defaultGrid2Theme,
4774
4779
  grid3: defaultGrid3Theme,
4775
4780
  grid4: defaultGrid4Theme,
4776
4781
  pageTitle: pageTitleTheme,
@@ -4850,12 +4855,17 @@ function applyExtraClassesRecursively(themeObject, extraClassesObject) {
4850
4855
  }
4851
4856
  }
4852
4857
  const ThemeContext = createContext(defaultTheme);
4853
- function ThemeProvider({ children, theme: themeObject = {}, themeDefaults, extraClasses, themeOverride }) {
4858
+ function ThemeProvider({ children, theme: themeObject = {}, themeDefaults, extraClasses, themeOverride, mergeStrategy = 'merge' }) {
4859
+ const parentTheme = useContext(ThemeContext);
4854
4860
  const mergedTheme = useMemo(() => {
4861
+ // Determine the base theme based on merge strategy
4862
+ const baseTheme = mergeStrategy === 'replace'
4863
+ ? defaultTheme
4864
+ : parentTheme;
4855
4865
  // Always start with a deep clone to ensure isolation
4856
4866
  let finalTheme = themeObject
4857
- ? deepMerge(deepClone(defaultTheme), themeObject)
4858
- : deepClone(defaultTheme);
4867
+ ? deepMerge(deepClone(baseTheme), themeObject)
4868
+ : deepClone(baseTheme);
4859
4869
  if (typeof themeOverride === 'function') {
4860
4870
  const themeToModify = deepClone(finalTheme);
4861
4871
  finalTheme = themeOverride(themeToModify);
@@ -4873,7 +4883,7 @@ function ThemeProvider({ children, theme: themeObject = {}, themeDefaults, extra
4873
4883
  applyExtraClassesRecursively(finalTheme, extraClasses);
4874
4884
  }
4875
4885
  return finalTheme;
4876
- }, [themeObject, themeDefaults, extraClasses, themeOverride]);
4886
+ }, [themeObject, themeDefaults, extraClasses, themeOverride, mergeStrategy, parentTheme]);
4877
4887
  return (jsx(ThemeContext.Provider, { value: mergedTheme, children: children }));
4878
4888
  }
4879
4889
  function useTheme() {
@@ -4967,6 +4977,10 @@ const Row = forwardRef(function Row(props, ref) {
4967
4977
  return jsx(ThemedComponent, { theme: theme.row, ref: ref, ...props });
4968
4978
  });
4969
4979
 
4980
+ const Grid2 = forwardRef(function Grid2(props, ref) {
4981
+ const theme = useTheme();
4982
+ return jsx(ThemedComponent, { theme: theme.grid2, ref: ref, ...props });
4983
+ });
4970
4984
  const Grid3 = forwardRef(function Grid3(props, ref) {
4971
4985
  const theme = useTheme();
4972
4986
  return jsx(ThemedComponent, { theme: theme.grid3, ref: ref, ...props });
@@ -5016,5 +5030,5 @@ const List = forwardRef(function List(props, ref) {
5016
5030
  return jsx(ThemedComponent, { ref: ref, theme: theme.list, ...props });
5017
5031
  });
5018
5032
 
5019
- export { BADGE_CATEGORIES, BREAKPOINT, BUTTON_CATEGORIES, Badge, Button, CARD_CATEGORIES, CHECKBOX_CATEGORIES, CHIP_CATEGORIES, CODE_CATEGORIES, COL_CATEGORIES, COMPONENT, COMPONENT_PROPS_CATEGORY, CONTAINER_CATEGORIES, Card, Checkbox, Chip, Code, Col, ComponentCategories, ComponentKeys, Container, DIVIDER_CATEGORIES, Divider, GRID_CATEGORIES, Grid3, Grid4, IMG_CATEGORIES, INTERACTIVE_CATEGORIES, Img, LABEL_CATEGORIES, LAYOUT_CORE, LAYOUT_FLEX, LAYOUT_FULL, LINK, LIST_CATEGORIES, LIST_STYLE, Label, Link, List, ListItem, PADDING, PageTitle, ROW_CATEGORIES, Row, SECTION_CATEGORIES, SHAPE, STACK_CATEGORIES, Section, SectionTitle, Stack, TYPOGRAPHY_CATEGORIES, TYPOGRAPHY_FULL, TYPOGRAPHY_STYLE, Text, ThemeProvider, Title, VARIANT, VISUAL_CORE, VISUAL_DECORATION, VISUAL_FULL, defaultTheme, useTheme };
5033
+ export { BADGE_CATEGORIES, BREAKPOINT, BUTTON_CATEGORIES, Badge, Button, CARD_CATEGORIES, CHECKBOX_CATEGORIES, CHIP_CATEGORIES, CODE_CATEGORIES, COL_CATEGORIES, COMPONENT, COMPONENT_PROPS_CATEGORY, CONTAINER_CATEGORIES, Card, Checkbox, Chip, Code, Col, ComponentCategories, ComponentKeys, Container, DIVIDER_CATEGORIES, Divider, GRID_CATEGORIES, Grid2, Grid3, Grid4, IMG_CATEGORIES, INTERACTIVE_CATEGORIES, Img, LABEL_CATEGORIES, LAYOUT_CORE, LAYOUT_FLEX, LAYOUT_FULL, LINK, LIST_CATEGORIES, LIST_STYLE, Label, Link, List, ListItem, PADDING, PageTitle, ROW_CATEGORIES, Row, SECTION_CATEGORIES, SHAPE, STACK_CATEGORIES, Section, SectionTitle, Stack, TYPOGRAPHY_CATEGORIES, TYPOGRAPHY_FULL, TYPOGRAPHY_STYLE, Text, ThemeProvider, Title, VARIANT, VISUAL_CORE, VISUAL_DECORATION, VISUAL_FULL, defaultTheme, useTheme };
5020
5034
  //# sourceMappingURL=index.esm.js.map