@uni-design-system/uni-react 1.0.0 → 2.0.0

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.
Files changed (81) hide show
  1. package/.storybook/main.ts +12 -12
  2. package/.storybook/manager.ts +13 -0
  3. package/.storybook/preview.ts +2 -2
  4. package/.turbo/turbo-build.log +4 -4
  5. package/CHANGELOG.md +11 -0
  6. package/dist/components/button/button.component.d.ts.map +1 -1
  7. package/dist/components/card/card.component.d.ts.map +1 -1
  8. package/dist/components/draggable/SortableList/components/SortableItem/sortableItem.component.d.ts.map +1 -1
  9. package/dist/components/draggable/SortableList/sortableList.stories.d.ts.map +1 -1
  10. package/dist/components/draggable/utilities/index.d.ts.map +1 -1
  11. package/dist/components/forms/utils/validations.d.ts.map +1 -1
  12. package/dist/components/grainy-gradient-background/grainy-gradient-background.component.stories.d.ts.map +1 -1
  13. package/dist/components/icon-text-row/icon-text-row.component.d.ts.map +1 -1
  14. package/dist/components/modal/modal.component.d.ts.map +1 -1
  15. package/dist/components/switch/switch.component.d.ts.map +1 -1
  16. package/dist/components/switch/switch.config.d.ts +2 -2
  17. package/dist/components/switch/switch.config.d.ts.map +1 -1
  18. package/dist/core/border/border.style.d.ts +2 -2
  19. package/dist/core/border/border.style.d.ts.map +1 -1
  20. package/dist/core/icon/icon.component.d.ts.map +1 -1
  21. package/dist/core/icon/icon.stories.d.ts.map +1 -1
  22. package/dist/core/icon/index.d.ts +1 -1
  23. package/dist/core/icon/index.d.ts.map +1 -1
  24. package/dist/core/image/image.component.d.ts.map +1 -1
  25. package/dist/core/layout/layout.provider.d.ts.map +1 -1
  26. package/dist/core/overlay/overlay.config.d.ts +2 -2
  27. package/dist/core/overlay/overlay.config.d.ts.map +1 -1
  28. package/dist/core/padding/padding.style.d.ts.map +1 -1
  29. package/dist/core/text/text.component.d.ts.map +1 -1
  30. package/dist/core/text/text.stories.d.ts.map +1 -1
  31. package/dist/core/theme/theming.d.ts +4 -4
  32. package/dist/core/theme/theming.d.ts.map +1 -1
  33. package/dist/core/transition/collapse/collapse.component.d.ts.map +1 -1
  34. package/dist/core/transition/fade/fade.component.d.ts.map +1 -1
  35. package/dist/core/transition/slide/slide.component.d.ts.map +1 -1
  36. package/dist/core/transition/transition.utils.d.ts.map +1 -1
  37. package/dist/index.js +2550 -2438
  38. package/dist/tools/color-picker/color-picker.component.d.ts +1 -1
  39. package/dist/tools/color-picker/color-picker.component.d.ts.map +1 -1
  40. package/dist/tools/color-picker/color-picker.stories.d.ts +1 -1
  41. package/dist/tools/color-swatch/color-swatch.component.d.ts +1 -1
  42. package/dist/tools/color-swatch/color-swatch.component.d.ts.map +1 -1
  43. package/dist/utils/storage-manager.d.ts.map +1 -1
  44. package/package.json +11 -11
  45. package/src/components/button/button.component.tsx +18 -5
  46. package/src/components/card/card.component.tsx +6 -1
  47. package/src/components/draggable/SortableList/components/SortableItem/sortableItem.component.tsx +10 -2
  48. package/src/components/draggable/SortableList/sortableList.component.tsx +1 -1
  49. package/src/components/draggable/SortableList/sortableList.stories.tsx +8 -4
  50. package/src/components/draggable/utilities/index.ts +1 -1
  51. package/src/components/forms/utils/validations.ts +2 -1
  52. package/src/components/grainy-gradient-background/grainy-gradient-background.component.stories.tsx +4 -1
  53. package/src/components/icon-text-row/icon-text-row.component.tsx +6 -1
  54. package/src/components/modal/modal.component.tsx +6 -1
  55. package/src/components/switch/switch.component.tsx +4 -1
  56. package/src/components/switch/switch.config.ts +1 -1
  57. package/src/core/border/border.style.ts +5 -4
  58. package/src/core/flex/flex.style.ts +17 -17
  59. package/src/core/hooks/use-media.ts +1 -1
  60. package/src/core/hooks/use-toggle.tsx +1 -1
  61. package/src/core/icon/icon.component.tsx +1 -1
  62. package/src/core/icon/icon.stories.tsx +4 -1
  63. package/src/core/icon/index.ts +5 -1
  64. package/src/core/image/image.component.tsx +12 -2
  65. package/src/core/layout/layout.provider.tsx +5 -10
  66. package/src/core/overlay/overlay.config.ts +10 -3
  67. package/src/core/padding/padding.style.ts +9 -10
  68. package/src/core/text/text.component.tsx +2 -1
  69. package/src/core/text/text.stories.tsx +12 -30
  70. package/src/core/theme/theming.tsx +8 -7
  71. package/src/core/transition/collapse/collapse.component.tsx +10 -2
  72. package/src/core/transition/fade/fade.component.tsx +16 -2
  73. package/src/core/transition/slide/slide.component.tsx +12 -2
  74. package/src/core/transition/transition.utils.ts +8 -2
  75. package/src/stories/Configure.mdx +31 -26
  76. package/src/tools/color-picker/color-picker.component.tsx +6 -1
  77. package/src/tools/color-swatch/color-swatch.component.tsx +8 -1
  78. package/src/utils/storage-manager.ts +4 -1
  79. package/tsconfig.json +4 -3
  80. package/vite.config.ts +7 -7
  81. package/vitest.shims.d.ts +1 -1
@@ -3,82 +3,64 @@ import { Text, TextProps } from './text.component';
3
3
 
4
4
  export default {
5
5
  title: 'Typography/Text',
6
- component: Text
6
+ component: Text,
7
7
  };
8
8
 
9
9
  const baseArgs: Partial<TextProps> = {
10
10
  text: 'UNI Design System',
11
- colorToken: 'on-background'
12
- }
11
+ colorToken: 'on-background',
12
+ };
13
13
 
14
14
  export const DisplayLarge = (args: TextProps) => <Text {...args} />;
15
- DisplayLarge.args = { ...baseArgs,
16
- role: 'display-large'
17
- }
15
+ DisplayLarge.args = { ...baseArgs, role: 'display-large' };
18
16
  DisplayLarge.story = {
19
17
  name: 'Display (large)',
20
18
  };
21
19
 
22
20
  export const DisplayMedium = (args: TextProps) => <Text {...args} />;
23
- DisplayMedium.args = { ...baseArgs,
24
- role: 'display-medium'
25
- }
21
+ DisplayMedium.args = { ...baseArgs, role: 'display-medium' };
26
22
  DisplayMedium.story = {
27
23
  name: 'Display (medium)',
28
24
  };
29
25
 
30
26
  export const DisplaySmall = (args: TextProps) => <Text {...args} />;
31
- DisplaySmall.args = { ...baseArgs,
32
- role: 'display-small'
33
- }
27
+ DisplaySmall.args = { ...baseArgs, role: 'display-small' };
34
28
  DisplaySmall.story = {
35
29
  name: 'Display (small)',
36
30
  };
37
31
 
38
32
  export const HeadlineLarge = (args: TextProps) => <Text {...args} />;
39
- HeadlineLarge.args = { ...baseArgs,
40
- role: 'headline-large'
41
- }
33
+ HeadlineLarge.args = { ...baseArgs, role: 'headline-large' };
42
34
  HeadlineLarge.story = {
43
35
  name: 'Headline (large)',
44
36
  };
45
37
 
46
38
  export const HeadlineMedium = (args: TextProps) => <Text {...args} />;
47
- HeadlineMedium.args = { ...baseArgs,
48
- role: 'headline-medium'
49
- }
39
+ HeadlineMedium.args = { ...baseArgs, role: 'headline-medium' };
50
40
  HeadlineMedium.story = {
51
41
  name: 'Headline (medium)',
52
42
  };
53
43
 
54
44
  export const HeadlineSmall = (args: TextProps) => <Text {...args} />;
55
- HeadlineSmall.args = { ...baseArgs,
56
- role: 'headline-small'
57
- }
45
+ HeadlineSmall.args = { ...baseArgs, role: 'headline-small' };
58
46
  HeadlineSmall.story = {
59
47
  name: 'Headline (small)',
60
48
  };
61
49
 
62
50
  export const TitleLarge = (args: TextProps) => <Text {...args} />;
63
- TitleLarge.args = { ...baseArgs,
64
- role: 'title-large'
65
- }
51
+ TitleLarge.args = { ...baseArgs, role: 'title-large' };
66
52
  TitleLarge.story = {
67
53
  name: 'Title (large)',
68
54
  };
69
55
 
70
56
  export const TitleMedium = (args: TextProps) => <Text {...args} />;
71
- TitleMedium.args = { ...baseArgs,
72
- role: 'title-medium'
73
- }
57
+ TitleMedium.args = { ...baseArgs, role: 'title-medium' };
74
58
  TitleMedium.story = {
75
59
  name: 'Title (medium)',
76
60
  };
77
61
 
78
62
  export const TitleSmall = (args: TextProps) => <Text {...args} />;
79
- TitleSmall.args = { ...baseArgs,
80
- role: 'title-small'
81
- }
63
+ TitleSmall.args = { ...baseArgs, role: 'title-small' };
82
64
  TitleSmall.story = {
83
65
  name: 'Title (small)',
84
66
  };
@@ -1,25 +1,26 @@
1
1
  import React, { createContext, useContext, useMemo } from 'react';
2
- import {LightTheme, type Theme} from "@uni-design-system/uni-core";
2
+ import { LightTheme, type UniTheme } from '@uni-design-system/uni-core';
3
3
 
4
4
  const defaultTheme = LightTheme;
5
5
 
6
- const ThemeContext = createContext<Theme>(defaultTheme);
6
+ const ThemeContext = createContext<UniTheme>(defaultTheme);
7
7
 
8
- export const ThemeProvider: React.FC<{ theme?: Theme; children: React.ReactNode }> = ({ theme, children }) => {
8
+ export const ThemeProvider: React.FC<{ theme?: UniTheme; children: React.ReactNode }> = ({
9
+ theme,
10
+ children,
11
+ }) => {
9
12
  // Use useMemo to prevent unnecessary re-renders when the parent re-renders
10
13
  const value = useMemo(() => theme || defaultTheme, [theme]);
11
14
  return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;
12
15
  };
13
16
 
14
-
15
17
  export const useTheme = () => {
16
18
  const context = useContext(ThemeContext);
17
- if (!context) throw new Error("useTheme must be used within ThemeProvider");
19
+ if (!context) throw new Error('useTheme must be used within ThemeProvider');
18
20
  return context;
19
21
  };
20
22
 
21
-
22
- export function withTheme<P extends { theme: Theme }>(
23
+ export function withTheme<P extends { theme: UniTheme }>(
23
24
  Component: React.ComponentType<P>
24
25
  ): React.ComponentType<Omit<P, 'theme'>> {
25
26
  return function WrappedComponent(props: any) {
@@ -1,7 +1,14 @@
1
1
  import React from 'react';
2
2
  import { AnimatePresence, HTMLMotionProps, motion, Variants as _Variants } from 'framer-motion';
3
3
  import { forwardRef, useEffect, useState } from 'react';
4
- import { TRANSITION_EASINGS, Variants, withDelay, WithTransitionConfig, cx, warn } from '../transition.utils';
4
+ import {
5
+ TRANSITION_EASINGS,
6
+ Variants,
7
+ withDelay,
8
+ WithTransitionConfig,
9
+ cx,
10
+ warn,
11
+ } from '../transition.utils';
5
12
 
6
13
  const isNumeric = (value?: string | number) => value != null && parseInt(value.toString(), 10) > 0;
7
14
 
@@ -51,7 +58,8 @@ const variants: Variants<CollapseOptions> = {
51
58
 
52
59
  export type ICollapse = CollapseProps;
53
60
 
54
- export interface CollapseProps extends WithTransitionConfig<HTMLMotionProps<'div'>>, CollapseOptions {}
61
+ export interface CollapseProps
62
+ extends WithTransitionConfig<HTMLMotionProps<'div'>>, CollapseOptions {}
55
63
 
56
64
  export const Collapse = forwardRef<HTMLDivElement, CollapseProps>((props, ref) => {
57
65
  const {
@@ -3,7 +3,12 @@ import React from 'react';
3
3
  import { AnimatePresence, HTMLMotionProps, motion, Variants as _Variants } from 'framer-motion';
4
4
 
5
5
  import { forwardRef } from 'react';
6
- import { TRANSITION_DEFAULTS, Variants, withDelay, WithTransitionConfig } from '../transition.utils';
6
+ import {
7
+ TRANSITION_DEFAULTS,
8
+ Variants,
9
+ withDelay,
10
+ WithTransitionConfig,
11
+ } from '../transition.utils';
7
12
 
8
13
  export interface FadeProps extends WithTransitionConfig<HTMLMotionProps<'div'>> {}
9
14
 
@@ -37,7 +42,16 @@ export const Fade = forwardRef<HTMLDivElement, FadeProps>(function Fade(props, r
37
42
 
38
43
  return (
39
44
  <AnimatePresence custom={custom}>
40
- {show && <motion.div ref={ref} className={'fade'} custom={custom} {...fadeConfig} animate={animate} {...rest} />}
45
+ {show && (
46
+ <motion.div
47
+ ref={ref}
48
+ className={'fade'}
49
+ custom={custom}
50
+ {...fadeConfig}
51
+ animate={animate}
52
+ {...rest}
53
+ />
54
+ )}
41
55
  </AnimatePresence>
42
56
  );
43
57
  });
@@ -1,5 +1,11 @@
1
1
  import React from 'react';
2
- import { AnimatePresence, HTMLMotionProps, motion, MotionStyle, Variants as TVariants } from 'framer-motion';
2
+ import {
3
+ AnimatePresence,
4
+ HTMLMotionProps,
5
+ motion,
6
+ MotionStyle,
7
+ Variants as TVariants,
8
+ } from 'framer-motion';
3
9
  import { forwardRef } from 'react';
4
10
  import {
5
11
  SlideDirection,
@@ -71,7 +77,11 @@ export const Slide = forwardRef<HTMLDivElement, SlideProps>(function Slide(props
71
77
  } = props;
72
78
 
73
79
  const transitionStyles = getSlideTransition({ direction });
74
- const computedStyle: MotionStyle = Object.assign({ position: 'fixed' }, transitionStyles.position, style);
80
+ const computedStyle: MotionStyle = Object.assign(
81
+ { position: 'fixed' },
82
+ transitionStyles.position,
83
+ style
84
+ );
75
85
 
76
86
  const show = unmountOnExit ? isOpen && unmountOnExit : true;
77
87
  const animate = isOpen || unmountOnExit ? 'enter' : 'exit';
@@ -129,11 +129,17 @@ export type WithTransitionConfig<P extends object> = Omit<P, 'transition'> &
129
129
  };
130
130
 
131
131
  export const withDelay = {
132
- enter: (transition: Transition, delay?: number | DelayConfig): Transition & { delay: number | undefined } => ({
132
+ enter: (
133
+ transition: Transition,
134
+ delay?: number | DelayConfig
135
+ ): Transition & { delay: number | undefined } => ({
133
136
  ...transition,
134
137
  delay: typeof delay === 'number' ? delay : delay?.['enter'],
135
138
  }),
136
- exit: (transition: Transition, delay?: number | DelayConfig): Transition & { delay: number | undefined } => ({
139
+ exit: (
140
+ transition: Transition,
141
+ delay?: number | DelayConfig
142
+ ): Transition & { delay: number | undefined } => ({
137
143
  ...transition,
138
144
  delay: typeof delay === 'number' ? delay : delay?.['exit'],
139
145
  }),
@@ -1,35 +1,37 @@
1
- import { Meta } from "@storybook/addon-docs/blocks";
2
-
3
- import Github from "./assets/github.svg";
4
- import Discord from "./assets/discord.svg";
5
- import Youtube from "./assets/youtube.svg";
6
- import Tutorials from "./assets/tutorials.svg";
7
- import Styling from "./assets/styling.png";
8
- import Context from "./assets/context.png";
9
- import Assets from "./assets/assets.png";
10
- import Docs from "./assets/docs.png";
11
- import Share from "./assets/share.png";
12
- import FigmaPlugin from "./assets/figma-plugin.png";
13
- import Testing from "./assets/testing.png";
14
- import Accessibility from "./assets/accessibility.png";
15
- import Theming from "./assets/theming.png";
16
- import AddonLibrary from "./assets/addon-library.png";
17
-
18
- export const RightArrow = () => <svg
19
- viewBox="0 0 14 14"
20
- width="8px"
21
- height="14px"
22
- style={{
1
+ import { Meta } from '@storybook/addon-docs/blocks';
2
+
3
+ import Github from './assets/github.svg';
4
+ import Discord from './assets/discord.svg';
5
+ import Youtube from './assets/youtube.svg';
6
+ import Tutorials from './assets/tutorials.svg';
7
+ import Styling from './assets/styling.png';
8
+ import Context from './assets/context.png';
9
+ import Assets from './assets/assets.png';
10
+ import Docs from './assets/docs.png';
11
+ import Share from './assets/share.png';
12
+ import FigmaPlugin from './assets/figma-plugin.png';
13
+ import Testing from './assets/testing.png';
14
+ import Accessibility from './assets/accessibility.png';
15
+ import Theming from './assets/theming.png';
16
+ import AddonLibrary from './assets/addon-library.png';
17
+
18
+ export const RightArrow = () => (
19
+ <svg
20
+ viewBox="0 0 14 14"
21
+ width="8px"
22
+ height="14px"
23
+ style={{
23
24
  marginLeft: '4px',
24
25
  display: 'inline-block',
25
26
  shapeRendering: 'inherit',
26
27
  verticalAlign: 'middle',
27
28
  fill: 'currentColor',
28
- 'path fill': 'currentColor'
29
+ 'path fill': 'currentColor',
29
30
  }}
30
- >
31
- <path d="m11.1 7.35-5.5 5.5a.5.5 0 0 1-.7-.7L10.04 7 4.9 1.85a.5.5 0 1 1 .7-.7l5.5 5.5c.2.2.2.5 0 .7Z" />
32
- </svg>
31
+ >
32
+ <path d="m11.1 7.35-5.5 5.5a.5.5 0 0 1-.7-.7L10.04 7 4.9 1.85a.5.5 0 1 1 .7-.7l5.5 5.5c.2.2.2.5 0 .7Z" />
33
+ </svg>
34
+ );
33
35
 
34
36
  <Meta title="Configure your project" />
35
37
 
@@ -38,6 +40,7 @@ export const RightArrow = () => <svg
38
40
  # Configure your project
39
41
 
40
42
  Because Storybook works separately from your app, you'll need to configure it for your specific stack and setup. Below, explore guides for configuring Storybook with popular frameworks and tools. If you get stuck, learn how you can ask for help from our community.
43
+
41
44
  </div>
42
45
  <div className="sb-section">
43
46
  <div className="sb-section-item">
@@ -87,6 +90,7 @@ export const RightArrow = () => <svg
87
90
  # Do more with Storybook
88
91
 
89
92
  Now that you know the basics, let's explore other parts of Storybook that will improve your experience. This list is just to get you started. You can customise Storybook in many ways to fit your needs.
93
+
90
94
  </div>
91
95
 
92
96
  <div className="sb-section">
@@ -217,6 +221,7 @@ export const RightArrow = () => <svg
217
221
  target="_blank"
218
222
  >Discover tutorials<RightArrow /></a>
219
223
  </div>
224
+
220
225
  </div>
221
226
 
222
227
  <style>
@@ -9,7 +9,12 @@ export interface ColorPickerProps {
9
9
  sampleSize: number;
10
10
  }
11
11
 
12
- export const ColorPicker = ({ imageUrl, imageWidth, imageHeight, sampleSize = 41 }: ColorPickerProps): JSX.Element => {
12
+ export const ColorPicker = ({
13
+ imageUrl,
14
+ imageWidth,
15
+ imageHeight,
16
+ sampleSize = 41,
17
+ }: ColorPickerProps): JSX.Element => {
13
18
  const canvasRef = useRef<HTMLCanvasElement>(null);
14
19
 
15
20
  const [pixelColor, setPixelColor] = useState<RGBA>({ red: 0, green: 0, blue: 0, alpha: 1 });
@@ -13,7 +13,14 @@ export interface ColorSwatchProps {
13
13
  height?: string | number;
14
14
  }
15
15
 
16
- export function ColorSwatch({ rgba, children, cardType = 'elevated', elevation, width, height }: ColorSwatchProps) {
16
+ export function ColorSwatch({
17
+ rgba,
18
+ children,
19
+ cardType = 'elevated',
20
+ elevation,
21
+ width,
22
+ height,
23
+ }: ColorSwatchProps) {
17
24
  const theme = useTheme();
18
25
 
19
26
  const { borderRadii } = theme.containers.card;
@@ -35,7 +35,10 @@ const parseCookie = (cookie: string, key: string): string | undefined => {
35
35
 
36
36
  // Usage
37
37
  // export const cookieStorageManager = createCookieStorageManager(STORAGE_KEY);
38
- export const createCookieStorageManager = (key: string, cookie?: string): StorageManager<string> => ({
38
+ export const createCookieStorageManager = (
39
+ key: string,
40
+ cookie?: string
41
+ ): StorageManager<string> => ({
39
42
  type: 'cookie',
40
43
  get(init?): string | undefined {
41
44
  if (cookie) return parseCookie(cookie, key);
package/tsconfig.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "extends": "@uni-design-system/tsconfig/base.json",
3
3
  "compilerOptions": {
4
+ "moduleResolution": "bundler",
4
5
  "jsx": "react-jsx",
5
6
  "lib": ["DOM", "DOM.Iterable", "ESNext"],
6
- "noEmit": true, // Ensures 'tsc' only checks types and doesn't write files
7
- "outDir": "dist", // If you DO emit, they go here
7
+ "noEmit": true, // Ensures 'tsc' only checks types and doesn't write files
8
+ "outDir": "dist", // If you DO emit, they go here
8
9
  "rootDir": "src"
9
10
  },
10
11
  "include": ["src"],
11
- "exclude": ["dist", "node_modules"]
12
+ "exclude": ["dist", "node_modules", ".storybook"]
12
13
  }
package/vite.config.ts CHANGED
@@ -6,14 +6,14 @@ import { resolve } from 'path';
6
6
  export default defineConfig({
7
7
  plugins: [
8
8
  react(),
9
- dts({ insertTypesEntry: true }) // Automatically generates .d.ts files
9
+ dts({ insertTypesEntry: true }), // Automatically generates .d.ts files
10
10
  ],
11
11
  build: {
12
12
  lib: {
13
13
  entry: resolve(__dirname, 'src/index.ts'),
14
14
  name: 'UniReact',
15
15
  formats: ['es'], // Modern libraries typically only need ES modules
16
- fileName: 'index'
16
+ fileName: 'index',
17
17
  },
18
18
  rollupOptions: {
19
19
  // CRITICAL: Do not bundle React or Core into your library
@@ -21,9 +21,9 @@ export default defineConfig({
21
21
  output: {
22
22
  globals: {
23
23
  react: 'React',
24
- 'react-dom': 'ReactDOM'
25
- }
26
- }
27
- }
28
- }
24
+ 'react-dom': 'ReactDOM',
25
+ },
26
+ },
27
+ },
28
+ },
29
29
  });
package/vitest.shims.d.ts CHANGED
@@ -1 +1 @@
1
- /// <reference types="@vitest/browser-playwright" />
1
+ /// <reference types="@vitest/browser-playwright" />