@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,191 +0,0 @@
1
-
2
- const CSS_PROP_LIST: any = {
3
- typography: 1,
4
- bgcolor: 1,
5
- bgimage: 1,
6
- bg: 1,
7
- p: 1,
8
- pt: 1,
9
- pr: 1,
10
- pb: 1,
11
- pl: 1,
12
- px: 1,
13
- py: 1,
14
- m: 1,
15
- mt: 1,
16
- mr: 1,
17
- mb: 1,
18
- ml: 1,
19
- mx: 1,
20
- my: 1,
21
- radius: 1,
22
- shadow: 1,
23
- flexBox: 1,
24
- flexRow: 1,
25
- flexColumn: 1,
26
- flexWraped: 1,
27
- disabled: 1,
28
- spacing: 1,
29
-
30
- gradient: 1,
31
-
32
- // CSS Props
33
- alignContent: 1,
34
- alignItems: 1,
35
- alignSelf: 1,
36
- animation: 1,
37
- animationComposition: 1,
38
- animationDelay: 1,
39
- animationDirection: 1,
40
- animationDuration: 1,
41
- animationFillMode: 1,
42
- animationIterationCount: 1,
43
- animationName: 1,
44
- animationTimingFunction: 1,
45
- backdropFilter: 1,
46
- background: 1,
47
- backgroundAttachment: 1,
48
- backgroundColor: 1,
49
- backgroundImage: 1,
50
- backgroundOrigin: 1,
51
- backgroundPosition: 1,
52
- backgroundRepeat: 1,
53
- backgroundSize: 1,
54
- border: 1,
55
- borderBottom: 1,
56
- borderBottomColor: 1,
57
- borderBottomStyle: 1,
58
- borderBottomWidth: 1,
59
- borderColor: 1,
60
- borderImage: 1,
61
- borderLeft: 1,
62
- borderLeftColor: 1,
63
- borderLeftStyle: 1,
64
- borderLeftWidth: 1,
65
- borderRadius: 1,
66
- borderRight: 1,
67
- borderRightColor: 1,
68
- borderRightStyle: 1,
69
- borderRightWidth: 1,
70
- borderStyle: 1,
71
- borderTop: 1,
72
- borderTopColor: 1,
73
- borderTopLeftRadius: 1,
74
- borderTopRightRadius: 1,
75
- borderTopStyle: 1,
76
- borderTopWidth: 1,
77
- borderWidth: 1,
78
- bottom: 1,
79
- boxShadow: 1,
80
- boxSizing: 1,
81
- cursor: 1,
82
- color: 1,
83
- display: 1,
84
- direction: 1,
85
- filter: 1,
86
- flex: 1,
87
- flexBasis: 1,
88
- flexDirection: 1,
89
- flexFlow: 1,
90
- flexGrow: 1,
91
- flexShrink: 1,
92
- flexWrap: 1,
93
- float: 1,
94
- fontFamily: 1,
95
- fontSize: 1,
96
- fontStyle: 1,
97
- fontWeight: 1,
98
- font: 1,
99
- gap: 1,
100
- grid: 1,
101
- gridArea: 1,
102
- gridAutoColumns: 1,
103
- gridAutoFlow: 1,
104
- gridAutoRows: 1,
105
- gridColumn: 1,
106
- gridColumnEnd: 1,
107
- gridColumnGap: 1,
108
- gridColumnStart: 1,
109
- gridGap: 1,
110
- gridRow: 1,
111
- gridRowEnd: 1,
112
- gridRowGap: 1,
113
- gridRowStart: 1,
114
- gridTemplate: 1,
115
- gridTemplateAreas: 1,
116
- gridTemplateColumns: 1,
117
- gridTemplateRows: 1,
118
- height: 1,
119
- justifyContent: 1,
120
- justifyItems: 1,
121
- justifySelf: 1,
122
- left: 1,
123
- letterSpacing: 1,
124
- lineBreak: 1,
125
- lineHeight: 1,
126
- listStyle: 1,
127
- margin: 1,
128
- marginBlock: 1,
129
- marginBlockEnd: 1,
130
- marginBlockStart: 1,
131
- marginBottom: 1,
132
- marginInline: 1,
133
- marginInlineEnd: 1,
134
- marginInlineStart: 1,
135
- marginLeft: 1,
136
- marginRight: 1,
137
- marginTop: 1,
138
- maxHeight: 1,
139
- maxWidth: 1,
140
- minHeight: 1,
141
- minWidth: 1,
142
- objectFit: 1,
143
- objectPosition: 1,
144
- opacity: 1,
145
- order: 1,
146
- outline: 1,
147
- overflow: 1,
148
- overflowX: 1,
149
- overflowY: 1,
150
- padding: 1,
151
- paddingBlock: 1,
152
- paddingBlockEnd: 1,
153
- paddingBlockStart: 1,
154
- paddingBottom: 1,
155
- paddingInline: 1,
156
- paddingInlineEnd: 1,
157
- paddingInlineStart: 1,
158
- paddingLeft: 1,
159
- paddingRight: 1,
160
- paddingTop: 1,
161
- perspective: 1,
162
- perspectiveOrigin: 1,
163
- pointerEvents: 1,
164
- position: 1,
165
- resize: 1,
166
- right: 1,
167
- textAlign: 1,
168
- textDecoration: 1,
169
- textShadow: 1,
170
- textTransform: 1,
171
- top: 1,
172
- transform: 1,
173
- transformOrigin: 1,
174
- transformStyle: 1,
175
- transition: 1,
176
- transitionDelay: 1,
177
- transitionDuration: 1,
178
- transitionProperty: 1,
179
- transitionTimingFunction: 1,
180
- userSelect: 1,
181
- verticalAlign: 1,
182
- visibility: 1,
183
- whiteSpace: 1,
184
- width: 1,
185
- wordBreak: 1,
186
- wordSpacing: 1,
187
- wordWrap: 1,
188
- zIndex: 1,
189
- }
190
-
191
- export default CSS_PROP_LIST
package/src/Tag/index.tsx DELETED
@@ -1,11 +0,0 @@
1
- import * as React from 'react'
2
- import { TagComponentType, TagPropsRoot } from './types';
3
- import useTagProps from './useTagProps';
4
-
5
- const Tag = React.forwardRef(<T extends TagComponentType = 'div'>({ component, children, ...rest }: TagPropsRoot<T>, ref: React.Ref<any>) => {
6
- const props: any = useTagProps(rest)
7
- props.ref = ref
8
- return React.createElement(component || "div", props, children)
9
- })
10
-
11
- export default Tag
@@ -1,28 +0,0 @@
1
- import { TagComponentType, TagProps, TagPropsRoot } from './types';
2
- import cssPropList from './cssPropList';
3
- import { css } from '../css';
4
- import { classNames } from 'pretty-class';
5
-
6
- const useTagProps = <T extends TagComponentType = "div">({ sxr, sx, baseClass, classNames: clses, hover, ...props }: TagPropsRoot<T>): TagProps<T> => {
7
- let _css: any = { ...sxr, ...sx, ...props }
8
- if (hover) _css['&:hover'] = hover
9
- const style = css(_css, {
10
- skipProps: (prop, _val, dept): any => dept === 1 && !cssPropList[prop]
11
- })
12
-
13
- let skipProps = style.skiped[style.classname as any] || []
14
- const _props: any = {};
15
- for (let prop of skipProps) {
16
- _props[prop] = (props as any)[prop]
17
- }
18
- _props.className = classNames([
19
- baseClass ? "xui-" + baseClass : "",
20
- style.classname,
21
- props.className,
22
- ...(clses as any || []),
23
- ])
24
- return _props
25
- }
26
-
27
-
28
- export default useTagProps
@@ -1,148 +0,0 @@
1
- 'use client'
2
- import React, { ReactElement, cloneElement, Children, useState, useEffect, useId } from 'react';
3
- import Tag from '../Tag';
4
- import { animationEases } from '../useAnimation';
5
- import { css } from '../css';
6
- import { formatCSSProp } from 'oncss';
7
- import { CSSProps } from '../css/types';
8
- import * as variants from './variants'
9
- export type TransitionVariantTypes = keyof typeof variants
10
-
11
- export type TransitionElementProps = {
12
- height: number;
13
- width: number;
14
- rect: DOMRect | null
15
- }
16
-
17
- export type TransitionState = "open" | "opened" | "close" | "closed"
18
-
19
- export type TransitionProps = {
20
- children: ReactElement;
21
- open: boolean;
22
- variant: {
23
- from: CSSProps;
24
- to: CSSProps;
25
- } | TransitionVariantTypes;
26
- ease?: string;
27
- easing?: keyof typeof animationEases;
28
- duration?: number;
29
- delay?: number;
30
- disableInitialTransition?: boolean;
31
- onOpen?: () => void;
32
- onOpened?: () => void;
33
- onClose?: () => void;
34
- onClosed?: () => void;
35
- onState?: (state: TransitionState) => void;
36
- }
37
-
38
- const Transition = ({ children, open, ...props }: TransitionProps) => {
39
- let { disableInitialTransition, variant, duration, delay, ease, easing, onOpen, onOpened, onClose, onClosed, onState } = props as TransitionProps
40
- let _ease = ease || (animationEases as any)[easing as any] || animationEases.easeBounceOut
41
- disableInitialTransition ??= false
42
- duration ??= 400
43
- variant ??= "fade"
44
-
45
- const id = useId().replace(/:/g, "")
46
- const [rendered, setRendered] = useState(false)
47
- const [initial, setInitial] = useState(false)
48
- const [transitionState, setTransitionState] = useState<TransitionState>(open ? (disableInitialTransition ? "opened" : "open") : "closed")
49
- const [element, setElement] = useState<TransitionElementProps>({
50
- height: 0,
51
- width: 0,
52
- rect: null
53
- });
54
-
55
- if (typeof variant === 'string') {
56
- variant = (variants as any)[variant](element)
57
- }
58
-
59
- let from = (variant as any).from
60
- let to = (variant as any).to
61
-
62
- const [_css, setCss] = useState(open ? to : from)
63
-
64
- useEffect(() => {
65
- const ele: HTMLElement = document.querySelector(`.trans-${id}`) as any
66
- if (ele) {
67
- setRendered(true)
68
- setElement({
69
- height: ele.clientHeight,
70
- width: ele.clientWidth,
71
- rect: ele.getBoundingClientRect()
72
- })
73
- if (!disableInitialTransition && open) {
74
- setCss(from)
75
- }
76
- }
77
- }, [])
78
-
79
- useEffect(() => {
80
- const ele: HTMLElement = document.querySelector(`.trans-${id}`) as any
81
- if (rendered && ele) {
82
- let stimer: any = null
83
- let etimer: any = null
84
- ele.ontransitionstart = () => {
85
- clearTimeout(stimer)
86
- stimer = setTimeout(() => {
87
- const isOpen = Array.from(ele.classList).includes("trans-open");
88
- (onOpen && isOpen) && onOpen();
89
- (onClose && !isOpen) && onClose()
90
- onState && onState(isOpen ? "open" : "close")
91
- setTransitionState(isOpen ? "open" : "close")
92
- }, 1)
93
- }
94
- ele.ontransitionend = () => {
95
- clearTimeout(etimer)
96
- etimer = setTimeout(() => {
97
- const isOpen = Array.from(ele.classList).includes("trans-open");
98
- (onOpened && isOpen) && onOpened();
99
- (onClosed && !isOpen) && onClosed();
100
- onState && onState(isOpen ? "opened" : "closed")
101
- setTransitionState(isOpen ? "opened" : "closed")
102
- }, 1)
103
- }
104
- }
105
- }, [rendered])
106
-
107
- useEffect(() => {
108
- if (rendered) {
109
- if (!initial) {
110
- setInitial(true)
111
- setTimeout(() => {
112
- setCss(open ? to : from)
113
- }, 50);
114
- } else {
115
- setCss(open ? to : from)
116
- }
117
- }
118
- }, [rendered, open, JSON.stringify(from), JSON.stringify(to)])
119
-
120
- let _: any = {}
121
- if (rendered) {
122
- let trans = ` ${duration}ms ${_ease} ${delay || 0}ms`
123
- _ = {
124
- ..._css,
125
- transition: Object.keys(_css || {}).map(k => formatCSSProp(k)).join(trans + ", ") + trans,
126
- }
127
- }
128
-
129
- const cls = css(_)
130
- if (!children || Array.isArray(children)) throw new Error("Invalid children in Transition")
131
- const first: any = Children.toArray(children).shift();
132
- let classname = `${cls.classname} trans-${id} trans-${(open ? "open" : "close")} trans-state-${transitionState}`
133
- const child = cloneElement(first, { classNames: [classname] })
134
- if (rendered) return child
135
- if (!rendered && disableInitialTransition && open) return child
136
-
137
- return (
138
- <Tag
139
- height={0}
140
- overflow="hidden"
141
- >
142
- {child}
143
- </Tag>
144
- )
145
- }
146
-
147
-
148
- export default Transition
@@ -1,178 +0,0 @@
1
- import { TransitionElementProps } from "."
2
-
3
- export const slideDown = (_arg: TransitionElementProps) => {
4
- return {
5
- from: {
6
- transform: `translateY(-${_arg.height}px)!important`,
7
- },
8
- to: {
9
- transform: `translateY(0)!important`,
10
- }
11
- }
12
- }
13
-
14
- export const slideUp = (_arg: TransitionElementProps) => {
15
- return {
16
- from: {
17
- transform: `translateY(${_arg.height}px)!important`,
18
- },
19
- to: {
20
- transform: `translateY(0)!important`,
21
- }
22
- }
23
- }
24
-
25
- export const slideRight = (_arg: TransitionElementProps) => {
26
- return {
27
- from: {
28
- transform: `translateX(-${_arg.width}px)!important`,
29
- },
30
- to: {
31
- transform: `translateX(0)!important`,
32
- }
33
- }
34
- }
35
-
36
- export const slideLeft = (_arg: TransitionElementProps) => {
37
- return {
38
- from: {
39
- transform: `translateX(${_arg.width}px)!important`,
40
- },
41
- to: {
42
- transform: `translateX(0)!important`,
43
- }
44
- }
45
- }
46
-
47
- export const fade = (_arg: TransitionElementProps) => {
48
- return {
49
- from: {
50
- opacity: 0
51
- },
52
- to: {
53
- opacity: 1
54
- }
55
- }
56
- }
57
-
58
- export const fadeDown = (_arg: TransitionElementProps) => {
59
- return {
60
- from: {
61
- transform: `translateY(-30px)!important`,
62
- opacity: 0
63
- },
64
- to: {
65
- transform: `translateY(0)!important`,
66
- opacity: 1
67
- }
68
- }
69
- }
70
-
71
- export const fadeUp = (_arg: TransitionElementProps) => {
72
- return {
73
- from: {
74
- transform: `translateY(30px)!important`,
75
- opacity: 0
76
- },
77
- to: {
78
- transform: `translateY(0)!important`,
79
- opacity: 1
80
- }
81
- }
82
- }
83
-
84
- export const fadeRight = (_arg: TransitionElementProps) => {
85
- return {
86
- from: {
87
- transform: `translateX(-30px)!important`,
88
- opacity: 0
89
- },
90
- to: {
91
- transform: `translateX(0)!important`,
92
- opacity: 1
93
- }
94
- }
95
- }
96
-
97
- export const fadeLeft = (_arg: TransitionElementProps) => {
98
- return {
99
- from: {
100
- transform: `translateX(30px)!important`,
101
- opacity: 0
102
- },
103
- to: {
104
- transform: `translateX(0)!important`,
105
- opacity: 1
106
- }
107
- }
108
- }
109
-
110
- export const grow = (_arg: TransitionElementProps) => {
111
- return {
112
- from: {
113
- transform: "scale(.8, .6)!important",
114
- opacity: 0
115
- },
116
- to: {
117
- transform: "scale(1)!important",
118
- opacity: 1
119
- }
120
- }
121
- }
122
-
123
- export const zoom = (_arg: TransitionElementProps) => {
124
- return {
125
- from: {
126
- transform: "scale(.8)!important",
127
- opacity: 0
128
- },
129
- to: {
130
- transform: "scale(1)!important",
131
- opacity: 1
132
- }
133
- }
134
- }
135
-
136
- export const zoomOver = (_arg: TransitionElementProps) => {
137
- return {
138
- from: {
139
- transform: "scale(1.2)!important",
140
- opacity: 0
141
- },
142
- to: {
143
- transform: "scale(1)!important",
144
- opacity: 1
145
- }
146
- }
147
- }
148
-
149
- export const collapsVerticle = (_arg: TransitionElementProps) => {
150
- return {
151
- from: {
152
- height: 0 + "px!important",
153
- overflow: "hidden"
154
- },
155
- to: {
156
- height: _arg?.height ? _arg?.height + "px!important" : "auto",
157
- overflow: "hidden"
158
- }
159
- }
160
- }
161
-
162
-
163
- export const collapsHorizental = (_arg: TransitionElementProps) => {
164
- return {
165
- from: {
166
- width: 0 + "px!important",
167
- overflow: "hidden"
168
- },
169
- to: {
170
- width: _arg?.width ? _arg?.width + "px!important" : "auto",
171
- overflow: "hidden"
172
- }
173
- }
174
- }
175
-
176
-
177
-
178
-
@@ -1,52 +0,0 @@
1
- import React, { ReactNode, useState } from "react";
2
- import isWindow from "../isWindow";
3
- import { breakpoints } from "../css";
4
- import { BreakpointKeys } from "../css/types";
5
-
6
- export const BreakpointCtx = React.createContext<BreakpointKeys>("xl")
7
-
8
- const getKey = (): BreakpointKeys => {
9
- const isWin = isWindow()
10
- if (isWin) {
11
- const width = window.innerWidth
12
- if (width < breakpoints.sm) {
13
- return 'xs'
14
- } else if (width > breakpoints.xs && width < breakpoints.md) {
15
- return 'sm'
16
- } else if (width > breakpoints.sm && width < breakpoints.lg) {
17
- return 'md'
18
- } else if (width > breakpoints.md && width < breakpoints.xl) {
19
- return 'lg'
20
- } else {
21
- return 'xl'
22
- }
23
- } else {
24
- return 'xl'
25
- }
26
- }
27
-
28
- export const BreakpointProvider = ({ children }: { children?: ReactNode }) => {
29
- const [current, setCurrent] = useState<BreakpointKeys>(getKey)
30
-
31
- const handler = () => {
32
- let c = getKey()
33
- if (current !== c) {
34
- setCurrent(c)
35
- }
36
- }
37
-
38
- React.useEffect(() => {
39
- window.removeEventListener("resize", handler)
40
- window.addEventListener("resize", handler)
41
- handler()
42
- return () => {
43
- window.removeEventListener("resize", handler)
44
- }
45
- }, [current])
46
-
47
- return (
48
- <BreakpointCtx.Provider value={current}>
49
- {children}
50
- </BreakpointCtx.Provider>
51
- )
52
- }
@@ -1,31 +0,0 @@
1
- import { useContext } from "react"
2
- import { BreakpointCtx } from "."
3
- import isWindow from "../isWindow"
4
- import { breakpoints } from "../css"
5
- import { BreakpointKeys } from "../css/types"
6
-
7
- const useBreakpoint = () => {
8
- const val = useContext(BreakpointCtx)
9
- const isWin = isWindow()
10
- const o = {
11
- value: val,
12
- is: (key: BreakpointKeys) => val === key,
13
- isDown: (key: BreakpointKeys) => {
14
- if (isWin) {
15
- return window.innerWidth > breakpoints[key]
16
- }
17
- return false
18
- },
19
- isUp: (key: BreakpointKeys) => {
20
- if (isWin) {
21
- return window.innerWidth < breakpoints[key]
22
- }
23
- return false
24
- },
25
- isOrDown: (key: BreakpointKeys) => o.is(key) || o.isDown(key),
26
- isOrUp: (key: BreakpointKeys) => o.is(key) || o.isUp(key)
27
- }
28
- return o
29
- }
30
-
31
- export default useBreakpoint
@@ -1,57 +0,0 @@
1
- import React, { isValidElement } from "react"
2
- import useBreakpoint from "./useBreakpoint"
3
- import { BreakpointKeys } from "../css/types"
4
-
5
- export type useBreakpointPropsType<P> = P | {
6
- [key in BreakpointKeys]?: P
7
- }
8
-
9
- const useBreakpoinProps = <P extends object>(props: useBreakpointPropsType<P>): useBreakpointPropsType<P> => {
10
- const bpoint = useBreakpoint()
11
- const stringifiedElement = JSON.stringify(props, (key, value) => {
12
- if (key === '_owner' || key === '_store') {
13
- return undefined; // Skip circular references
14
- }
15
- return value;
16
- }, 2);
17
-
18
- let format: any = React.useMemo(() => {
19
-
20
- const _format: any = {
21
- xs: {},
22
- sm: {},
23
- md: {},
24
- lg: {},
25
- xl: {}
26
- }
27
- for (let prop in props) {
28
- let val = (props as any)[prop]
29
- if (!isValidElement(val) && typeof val === 'object') {
30
- for (let breakpoin in val) {
31
- _format[breakpoin][prop] = (props as any)[prop][breakpoin]
32
- }
33
- } else {
34
- _format.xs[prop] = (props as any)[prop]
35
- }
36
- }
37
-
38
- return _format
39
- }, [stringifiedElement, bpoint.value])
40
-
41
- return React.useMemo(() => {
42
- let _props = format.xs || {};
43
- for (let key of ['sm', 'md', 'lg', 'xl']) {
44
- if (bpoint.isOrDown(key as any)) {
45
- _props = { ..._props, ...format[key] };
46
- }
47
- if (bpoint.is(key as any)) {
48
- break;
49
- }
50
- }
51
- return _props;
52
- }, [format, bpoint.value]);
53
- }
54
-
55
-
56
-
57
- export default useBreakpoinProps