@xanui/core 1.1.2 → 1.1.3

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 (174) hide show
  1. package/ServerStyleTags.d.ts +3 -0
  2. package/ServerStyleTags.js +2 -0
  3. package/ServerStyleTags.js.map +7 -0
  4. package/Tag/cssPropList.d.ts +2 -0
  5. package/Tag/cssPropList.js +2 -0
  6. package/Tag/cssPropList.js.map +7 -0
  7. package/Tag/index.d.ts +4 -0
  8. package/Tag/index.js +2 -0
  9. package/Tag/index.js.map +7 -0
  10. package/{src/Tag/types.ts → Tag/types.d.ts} +9 -13
  11. package/Tag/types.js +1 -0
  12. package/Tag/types.js.map +7 -0
  13. package/Tag/useTagProps.d.ts +3 -0
  14. package/Tag/useTagProps.js +2 -0
  15. package/Tag/useTagProps.js.map +7 -0
  16. package/Transition/index.d.ts +31 -0
  17. package/Transition/index.js +2 -0
  18. package/Transition/index.js.map +7 -0
  19. package/Transition/variants.d.ts +131 -0
  20. package/Transition/variants.js +2 -0
  21. package/Transition/variants.js.map +7 -0
  22. package/breakpoint/index.d.ts +6 -0
  23. package/breakpoint/index.js +2 -0
  24. package/breakpoint/index.js.map +7 -0
  25. package/breakpoint/useBreakpoint.d.ts +10 -0
  26. package/breakpoint/useBreakpoint.js +2 -0
  27. package/breakpoint/useBreakpoint.js.map +7 -0
  28. package/breakpoint/useBreakpointProps.d.ts +6 -0
  29. package/breakpoint/useBreakpointProps.js +2 -0
  30. package/breakpoint/useBreakpointProps.js.map +7 -0
  31. package/cjs/ServerStyleTags.js +2 -0
  32. package/cjs/ServerStyleTags.js.map +7 -0
  33. package/cjs/Tag/cssPropList.js +2 -0
  34. package/cjs/Tag/cssPropList.js.map +7 -0
  35. package/cjs/Tag/index.js +2 -0
  36. package/cjs/Tag/index.js.map +7 -0
  37. package/cjs/Tag/types.js +2 -0
  38. package/cjs/Tag/types.js.map +7 -0
  39. package/cjs/Tag/useTagProps.js +2 -0
  40. package/cjs/Tag/useTagProps.js.map +7 -0
  41. package/cjs/Transition/index.js +2 -0
  42. package/cjs/Transition/index.js.map +7 -0
  43. package/cjs/Transition/variants.js +2 -0
  44. package/cjs/Transition/variants.js.map +7 -0
  45. package/cjs/breakpoint/index.js +2 -0
  46. package/cjs/breakpoint/index.js.map +7 -0
  47. package/cjs/breakpoint/useBreakpoint.js +2 -0
  48. package/cjs/breakpoint/useBreakpoint.js.map +7 -0
  49. package/cjs/breakpoint/useBreakpointProps.js +2 -0
  50. package/cjs/breakpoint/useBreakpointProps.js.map +7 -0
  51. package/cjs/css/aliases.js +2 -0
  52. package/cjs/css/aliases.js.map +7 -0
  53. package/cjs/css/getProps.js +2 -0
  54. package/cjs/css/getProps.js.map +7 -0
  55. package/cjs/css/getValue.js +2 -0
  56. package/cjs/css/getValue.js.map +7 -0
  57. package/cjs/css/index.js +2 -0
  58. package/cjs/css/index.js.map +7 -0
  59. package/cjs/css/types.js +2 -0
  60. package/cjs/css/types.js.map +7 -0
  61. package/cjs/index.js +2 -0
  62. package/cjs/index.js.map +7 -0
  63. package/cjs/isWindow.js +2 -0
  64. package/cjs/isWindow.js.map +7 -0
  65. package/cjs/theme/ThemeCssVars.js +2 -0
  66. package/cjs/theme/ThemeCssVars.js.map +7 -0
  67. package/cjs/theme/ThemeDefaultOptions.js +2 -0
  68. package/cjs/theme/ThemeDefaultOptions.js.map +7 -0
  69. package/cjs/theme/ThemeProvider.js +2 -0
  70. package/cjs/theme/ThemeProvider.js.map +7 -0
  71. package/cjs/theme/core.js +2 -0
  72. package/cjs/theme/core.js.map +7 -0
  73. package/cjs/theme/createColor.js +2 -0
  74. package/cjs/theme/createColor.js.map +7 -0
  75. package/cjs/theme/createTheme.js +2 -0
  76. package/cjs/theme/createTheme.js.map +7 -0
  77. package/cjs/theme/createThemeSwitcher.js +2 -0
  78. package/cjs/theme/createThemeSwitcher.js.map +7 -0
  79. package/cjs/theme/index.js +2 -0
  80. package/cjs/theme/index.js.map +7 -0
  81. package/cjs/theme/types.js +2 -0
  82. package/cjs/theme/types.js.map +7 -0
  83. package/cjs/useAnimation.js +2 -0
  84. package/cjs/useAnimation.js.map +7 -0
  85. package/cjs/useColorTemplate.js +2 -0
  86. package/cjs/useColorTemplate.js.map +7 -0
  87. package/cjs/useInterface.js +2 -0
  88. package/cjs/useInterface.js.map +7 -0
  89. package/css/aliases.d.ts +4 -0
  90. package/css/aliases.js +2 -0
  91. package/css/aliases.js.map +7 -0
  92. package/css/getProps.d.ts +3 -0
  93. package/css/getProps.js +2 -0
  94. package/css/getProps.js.map +7 -0
  95. package/css/getValue.d.ts +3 -0
  96. package/css/getValue.js +2 -0
  97. package/css/getValue.js.map +7 -0
  98. package/css/index.d.ts +15 -0
  99. package/css/index.js +2 -0
  100. package/css/index.js.map +7 -0
  101. package/{src/css/types.ts → css/types.d.ts} +16 -22
  102. package/css/types.js +1 -0
  103. package/css/types.js.map +7 -0
  104. package/index.d.ts +21 -0
  105. package/index.js +2 -0
  106. package/index.js.map +7 -0
  107. package/isWindow.d.ts +2 -0
  108. package/isWindow.js +2 -0
  109. package/isWindow.js.map +7 -0
  110. package/package.json +43 -49
  111. package/theme/ThemeCssVars.d.ts +3 -0
  112. package/theme/ThemeCssVars.js +2 -0
  113. package/theme/ThemeCssVars.js.map +7 -0
  114. package/theme/ThemeDefaultOptions.d.ts +68 -0
  115. package/theme/ThemeDefaultOptions.js +2 -0
  116. package/theme/ThemeDefaultOptions.js.map +7 -0
  117. package/theme/ThemeProvider.d.ts +11 -0
  118. package/theme/ThemeProvider.js +2 -0
  119. package/theme/ThemeProvider.js.map +7 -0
  120. package/theme/core.d.ts +7 -0
  121. package/theme/core.js +2 -0
  122. package/theme/core.js.map +7 -0
  123. package/theme/createColor.d.ts +41 -0
  124. package/theme/createColor.js +2 -0
  125. package/theme/createColor.js.map +7 -0
  126. package/theme/createTheme.d.ts +2 -0
  127. package/theme/createTheme.js +2 -0
  128. package/theme/createTheme.js.map +7 -0
  129. package/theme/createThemeSwitcher.d.ts +6 -0
  130. package/theme/createThemeSwitcher.js +2 -0
  131. package/theme/createThemeSwitcher.js.map +7 -0
  132. package/theme/index.d.ts +5 -0
  133. package/theme/index.js +2 -0
  134. package/theme/index.js.map +7 -0
  135. package/{src/theme/types.ts → theme/types.d.ts} +46 -103
  136. package/theme/types.js +1 -0
  137. package/theme/types.js.map +7 -0
  138. package/useAnimation.d.ts +18 -0
  139. package/useAnimation.js +2 -0
  140. package/useAnimation.js.map +7 -0
  141. package/useColorTemplate.d.ts +4 -0
  142. package/useColorTemplate.js +2 -0
  143. package/useColorTemplate.js.map +7 -0
  144. package/useInterface.d.ts +2 -0
  145. package/useInterface.js +2 -0
  146. package/useInterface.js.map +7 -0
  147. package/main.tsx +0 -97
  148. package/src/ServerStyleTags.tsx +0 -12
  149. package/src/Tag/cssPropList.ts +0 -191
  150. package/src/Tag/index.tsx +0 -11
  151. package/src/Tag/useTagProps.ts +0 -28
  152. package/src/Transition/index.tsx +0 -148
  153. package/src/Transition/variants.ts +0 -178
  154. package/src/breakpoint/index.tsx +0 -52
  155. package/src/breakpoint/useBreakpoint.ts +0 -31
  156. package/src/breakpoint/useBreakpointProps.ts +0 -57
  157. package/src/css/aliases.ts +0 -35
  158. package/src/css/getProps.ts +0 -38
  159. package/src/css/getValue.ts +0 -117
  160. package/src/css/index.ts +0 -78
  161. package/src/index.ts +0 -34
  162. package/src/isWindow.ts +0 -3
  163. package/src/theme/ThemeCssVars.ts +0 -107
  164. package/src/theme/ThemeDefaultOptions.ts +0 -146
  165. package/src/theme/ThemeProvider.tsx +0 -140
  166. package/src/theme/core.ts +0 -21
  167. package/src/theme/createColor.ts +0 -53
  168. package/src/theme/createTheme.ts +0 -33
  169. package/src/theme/createThemeSwitcher.ts +0 -18
  170. package/src/theme/index.tsx +0 -17
  171. package/src/useAnimation.ts +0 -40
  172. package/src/useColorTemplate.ts +0 -11
  173. package/src/useInterface.ts +0 -13
  174. package/tsconfig.json +0 -28
@@ -1,140 +0,0 @@
1
- import * as React from "react"
2
- import { ThemeOptions } from "./types"
3
- import Tag from "../Tag"
4
- import { TagComponentType, TagProps } from "../Tag/types"
5
- import { BreakpointProvider } from "../breakpoint"
6
- import { ThemeContex, ThemeFactory } from "./core"
7
- import ThemeCssVars from "./ThemeCssVars"
8
- import { css } from "../css"
9
-
10
- export type ThemeProviderProps<T extends TagComponentType = 'div'> = TagProps<T> & {
11
- theme: string;
12
- resetCss?: boolean;
13
- scrollbarCss?: boolean;
14
- isRootProvider?: boolean;
15
- renderIsRoot?: React.ReactElement;
16
- }
17
-
18
- const ThemeProvider = ({ children, theme, resetCss, scrollbarCss, isRootProvider, renderIsRoot, ...props }: ThemeProviderProps) => {
19
- const THEME = ThemeFactory.get(theme) as ThemeOptions
20
- if (!THEME) throw new Error(`Invalid theme name provided: ${theme}`)
21
- resetCss ??= true
22
- scrollbarCss ??= true
23
-
24
- React.useMemo(() => {
25
- if (!!Object.keys(THEME.globalStyle).length) {
26
- css({
27
- "@global": THEME.globalStyle
28
- })
29
- }
30
-
31
- css({
32
- "@global": {
33
- [`.xui-${theme}-theme-root`]: ThemeCssVars(THEME)
34
- }
35
- })
36
-
37
- if (scrollbarCss && typeof document !== 'undefined') {
38
- let thumbSize = 10
39
- let thumbColor = THEME.colors.divider
40
- let trackColor = THEME.colors.background.secondary
41
- css({
42
- "@global": {
43
- "*": {
44
- scrollbarWidth: "thin",
45
- scrollbarColor: `${thumbColor} ${trackColor}`,
46
- },
47
- "::-webkit-scrollbar": {
48
- width: thumbSize,
49
- height: thumbSize,
50
- },
51
- "::-webkit-scrollbar-thumb": {
52
- backgroundColor: thumbColor,
53
- borderRadius: "5px",
54
- border: "2px solid #f4f4f4",
55
- },
56
- "::-webkit-scrollbar-thumb:hover": {
57
- backgroundColor: thumbColor,
58
- },
59
- "::-webkit-scrollbar-track": {
60
- backgroundColor: trackColor,
61
- borderRadius: "5px",
62
- },
63
- }
64
- })
65
- }
66
-
67
- resetCss && css({
68
- "@global": {
69
- "*": {
70
- m: 0,
71
- p: 0,
72
- outline: "none",
73
- boxSizing: "border-box",
74
- verticalAlign: "baseline",
75
- },
76
- "html, body": {
77
- minHeight: "100%",
78
- "-webkit-font-smoothing": "antialiased"
79
- } as any,
80
- "img, picture, video, canvas, svg": {
81
- maxWidth: "100%",
82
- display: "block"
83
- },
84
- "input, button, textarea, select": {
85
- font: "inherit"
86
- },
87
- "table": {
88
- borderCollapse: "collapse",
89
- borderSpacing: 0
90
- },
91
- "ol, ul": {
92
- listStyle: "none"
93
- },
94
- "a": {
95
- display: "inline-block"
96
- },
97
- "p, h1, h2, h3, h4, h5, h6": {
98
- overflowWrap: "break-word",
99
- }
100
- }
101
- })
102
- }, [theme])
103
-
104
- return (
105
- <ThemeContex.Provider value={theme}>
106
- {
107
- isRootProvider ? <BreakpointProvider>
108
- <Tag
109
- minHeight="100%"
110
- bgcolor={THEME.colors.background.primary}
111
- fontFamily={THEME.typography.fontFamily}
112
- fontSize={THEME.typography.text.fontSize}
113
- fontWeight={THEME.typography.text.fontWeight}
114
- lineHeight={THEME.typography.text.lineHeight}
115
- {...props}
116
- baseClass={`${theme}-theme-root`}
117
- direction={THEME.rtl ? "rtl" : "ltr"}
118
- >
119
- {children}
120
- {renderIsRoot}
121
- </Tag>
122
- </BreakpointProvider> : <Tag
123
- minHeight="100%"
124
- bgcolor={THEME.colors.background.primary}
125
- fontFamily={THEME.typography.fontFamily}
126
- fontSize={THEME.typography.text.fontSize}
127
- fontWeight={THEME.typography.text.fontWeight}
128
- lineHeight={THEME.typography.text.lineHeight}
129
- {...props}
130
- baseClass={`${theme}-theme-root`}
131
- direction={THEME.rtl ? "rtl" : "ltr"}
132
- >
133
- {children}
134
- </Tag>
135
- }
136
- </ThemeContex.Provider>
137
- )
138
- }
139
-
140
- export default ThemeProvider
package/src/theme/core.ts DELETED
@@ -1,21 +0,0 @@
1
- import React from "react"
2
- import { ObjectType, ThemeOptions } from "./types"
3
-
4
- export const ThemeFactory = new Map<string, ThemeOptions>()
5
- export const ThemeContex = React.createContext("light")
6
- export const getTheme = (theme: string) => ThemeFactory.get(theme)
7
- export const useTheme = (): ThemeOptions => ThemeFactory.get(React.useContext(ThemeContex)) as any
8
-
9
- export const mergeObject = (a: ObjectType, b: ObjectType) => {
10
- a = { ...a }
11
- b = { ...b }
12
- for (const key in b) {
13
- const v = (b as any)[key]
14
- if (typeof v === 'object' && !Array.isArray(v) && !React.isValidElement(v)) {
15
- a[key] = mergeObject(a[key], b[key])
16
- } else {
17
- a[key] = v
18
- }
19
- }
20
- return a
21
- }
@@ -1,53 +0,0 @@
1
- import { ThemeOptions, ThemeColor } from "./types"
2
- import { alpha } from "../css"
3
-
4
- const createColor = (theme: ThemeOptions, name: keyof ThemeColor) => {
5
- let color = theme.colors[name]
6
- let { primary, secondary } = color as any
7
- let text = (color as any).text || theme.colors.text.primary
8
- let _alpha = alpha(primary, .1)
9
-
10
- const isBag = (a: any, b: any) => name === "background" ? a : b
11
-
12
- return {
13
- alpha: _alpha,
14
- template: {
15
- outline: {
16
- bgcolor: "transparent",
17
- color: isBag(text, primary),
18
- border: 1,
19
- borderColor: isBag("divider", alpha(primary, .4)),
20
- hover: {
21
- color: isBag(text, primary),
22
- borderColor: isBag("divider", alpha(primary, .8)),
23
- }
24
- },
25
- fill: {
26
- bgcolor: isBag(secondary, primary),
27
- color: text,
28
- hover: {
29
- bgcolor: isBag(alpha(secondary, .6), secondary),
30
- color: text,
31
- }
32
- },
33
- text: {
34
- bgcolor: "transparent",
35
- color: isBag(text, primary),
36
- hover: {
37
- bgcolor: isBag(alpha(secondary, .6), alpha(primary, .1)),
38
- color: isBag(text, primary),
39
- }
40
- },
41
- alpha: {
42
- bgcolor: isBag(alpha(secondary, .5), alpha(primary, .1)),
43
- color: isBag(text, primary),
44
- hover: {
45
- bgcolor: isBag(alpha(secondary, .8), alpha(primary, .15)),
46
- color: isBag(text, primary),
47
- }
48
- }
49
- }
50
- }
51
- }
52
-
53
- export default createColor
@@ -1,33 +0,0 @@
1
- import { ThemeOptions, ThemeOptionInput } from "./types"
2
- import defaultThemeOption, { darkColorPallete } from './ThemeDefaultOptions'
3
- import { mergeObject, ThemeFactory } from "./core"
4
- import createColor from "./createColor"
5
- import { breakpoints } from "../css"
6
-
7
- export const createTheme = (name: string, options: ThemeOptionInput, darkMode?: boolean): ThemeOptions => {
8
- if (!ThemeFactory.has(name)) {
9
- let theme: any = mergeObject(defaultThemeOption, {
10
- ...(darkMode ? darkColorPallete : {}),
11
- ...options,
12
- name,
13
- breakpoints: breakpoints
14
- })
15
-
16
- theme = mergeObject(theme, {
17
- colors: {
18
- background: createColor(theme, "background"),
19
- brand: createColor(theme, "brand"),
20
- accent: createColor(theme, "accent"),
21
- info: createColor(theme, "info"),
22
- success: createColor(theme, "success"),
23
- warning: createColor(theme, "warning"),
24
- danger: createColor(theme, "danger")
25
- }
26
- })
27
- ThemeFactory.set(name, theme)
28
- } else {
29
- throw new Error(`theme "${name}" already exists!`);
30
- }
31
-
32
- return ThemeFactory.get(name) as ThemeOptions
33
- }
@@ -1,18 +0,0 @@
1
- import { createBucket } from "react-state-bucket"
2
- import { getTheme } from "./core"
3
-
4
- const createThemeSwitcher = (defaultTheme: string, store?: "session" | "local") => {
5
- const useThemeState = createBucket({ name: defaultTheme }, { store })
6
- const useThemeSwitcher = () => {
7
- const state = useThemeState()
8
- return {
9
- name: state.get("name"),
10
- theme: getTheme(state.get("name")),
11
- change: (theme: string) => state.set("name", theme)
12
- }
13
- }
14
- return useThemeSwitcher
15
- }
16
-
17
-
18
- export default createThemeSwitcher
@@ -1,17 +0,0 @@
1
- import { lightColorPallete, darkColorPallete } from './ThemeDefaultOptions'
2
- import { createTheme } from "./createTheme"
3
- import ThemeProvider from './ThemeProvider'
4
- import createThemeSwitcher from './createThemeSwitcher'
5
- import { getTheme, useTheme } from './core'
6
- export type { ThemeProviderProps } from './ThemeProvider'
7
-
8
- export {
9
- ThemeProvider,
10
- createThemeSwitcher,
11
- getTheme,
12
- useTheme
13
- }
14
-
15
- createTheme("light", { colors: lightColorPallete })
16
- createTheme("dark", { colors: darkColorPallete })
17
-
@@ -1,40 +0,0 @@
1
- import { css } from './css'
2
- import { useId } from 'react'
3
- import { CSSProps } from './css/types'
4
-
5
- export const animationEases = {
6
- easeInOut: "cubic-bezier(0.4, 0, 0.2, 1)",
7
- easeOut: "cubic-bezier(0.0, 0, 0.2, 1)",
8
- easeIn: "cubic-bezier(0.4, 0, 1, 1)",
9
- sharp: "cubic-bezier(0.4, 0, 0.6, 1)",
10
- linear: "cubic-bezier(0, 0, 1, 1)",
11
- easeBounceOut: "cubic-bezier(0.68, -0.55, 0.265, 1.55)"
12
- }
13
-
14
- export interface UseAnimationProps {
15
- delay?: number;
16
- duration?: number;
17
- from: CSSProps;
18
- to: CSSProps;
19
- ease?: keyof typeof animationEases;
20
- }
21
-
22
- const useAnimation = ({ from, to, delay, ease, duration }: UseAnimationProps) => {
23
- let _delay = delay || 0;
24
- let _duration = duration || 600;
25
- let _ease = ease || "easeBounceOut"
26
- const id = "anim" + useId().replace(/:/g, "")
27
- const anim = css({
28
- animationName: id,
29
- animationDelay: _delay + "ms",
30
- animationDuration: _duration + "ms",
31
- animationTimingFunction: animationEases[_ease] || animationEases.easeBounceOut,
32
- [`@keyframes ${id}`]: {
33
- from: from as any,
34
- to: to as any
35
- }
36
- })
37
- return anim.classname
38
- }
39
-
40
- export default useAnimation
@@ -1,11 +0,0 @@
1
- import { useTheme } from "./theme"
2
- export type ColorTemplateColors = "default" | "brand" | "accent" | "info" | "success" | "warning" | "danger"
3
- export type ColorTemplateType = "fill" | "outline" | "text" | "alpha"
4
-
5
- const useColorTemplate = (color: ColorTemplateColors, type: ColorTemplateType) => {
6
- const theme: any = useTheme()
7
- let _color = color === 'default' ? "background" : color as any
8
- return theme.colors[_color]?.template[type]
9
- }
10
-
11
- export default useColorTemplate
@@ -1,13 +0,0 @@
1
- import { useTheme } from "./theme"
2
-
3
- const useInterface = <P extends object>(name: string, userPorps: P, defaultProps: P) => {
4
- const theme = useTheme()
5
- const _interface = theme.interfaces[name]
6
-
7
- if (_interface) {
8
- defaultProps = _interface<P>({ ...defaultProps, ...userPorps }, theme)
9
- }
10
- return [{ ...defaultProps, ...userPorps }, theme]
11
- }
12
-
13
- export default useInterface
package/tsconfig.json DELETED
@@ -1,28 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2015", // <-- Change from "es5" to "es2015"
4
- "lib": [
5
- "dom",
6
- "dom.iterable",
7
- "esnext"
8
- ],
9
- "allowJs": true,
10
- "skipLibCheck": true,
11
- "esModuleInterop": true,
12
- "allowSyntheticDefaultImports": true,
13
- "strict": true,
14
- "forceConsistentCasingInFileNames": true,
15
- "module": "esnext",
16
- "moduleResolution": "node",
17
- "resolveJsonModule": true,
18
- "isolatedModules": true,
19
- "noEmit": true,
20
- "jsx": "react"
21
- },
22
- "include": [
23
- "src"
24
- ],
25
- "exclude": [
26
- "node_modules"
27
- ]
28
- }