musae 0.1.8 → 0.1.10

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 (84) hide show
  1. package/dist/button/span.js +4 -4
  2. package/dist/button/styled.js +4 -4
  3. package/dist/checkbox/styled.js +7 -6
  4. package/dist/{input → components/input}/types.d.ts +1 -1
  5. package/dist/{theme → components/theme}/hooks.d.ts +8 -1
  6. package/dist/icons/hooks.js +1 -3
  7. package/dist/input/label.js +5 -5
  8. package/dist/input/styled.js +4 -4
  9. package/dist/message/styled.js +4 -4
  10. package/dist/radio/styled.js +4 -4
  11. package/dist/switch/styled.js +5 -5
  12. package/dist/theme/hooks.js +10 -15
  13. package/dist/utils/object.d.ts +6 -0
  14. package/dist/utils/object.js +12 -0
  15. package/package.json +1 -1
  16. /package/dist/{avatar → components/avatar}/avatar.d.ts +0 -0
  17. /package/dist/{avatar → components/avatar}/fallback.d.ts +0 -0
  18. /package/dist/{avatar → components/avatar}/image.d.ts +0 -0
  19. /package/dist/{avatar → components/avatar}/index.d.ts +0 -0
  20. /package/dist/{button → components/button}/button.d.ts +0 -0
  21. /package/dist/{button → components/button}/index.d.ts +0 -0
  22. /package/dist/{button → components/button}/span.d.ts +0 -0
  23. /package/dist/{button → components/button}/styled.d.ts +0 -0
  24. /package/dist/{button → components/button}/types.d.ts +0 -0
  25. /package/dist/{checkbox → components/checkbox}/checkbox.d.ts +0 -0
  26. /package/dist/{checkbox → components/checkbox}/context.d.ts +0 -0
  27. /package/dist/{checkbox → components/checkbox}/group.d.ts +0 -0
  28. /package/dist/{checkbox → components/checkbox}/index.d.ts +0 -0
  29. /package/dist/{checkbox → components/checkbox}/styled.d.ts +0 -0
  30. /package/dist/{checkbox → components/checkbox}/types.d.ts +0 -0
  31. /package/dist/{divider → components/divider}/divider.d.ts +0 -0
  32. /package/dist/{divider → components/divider}/index.d.ts +0 -0
  33. /package/dist/{divider → components/divider}/styled.d.ts +0 -0
  34. /package/dist/{divider → components/divider}/types.d.ts +0 -0
  35. /package/dist/{icons → components/icons}/hooks.d.ts +0 -0
  36. /package/dist/{icons → components/icons}/navigate-before.d.ts +0 -0
  37. /package/dist/{icons → components/icons}/types.d.ts +0 -0
  38. /package/dist/{index.d.ts → components/index.d.ts} +0 -0
  39. /package/dist/{input → components/input}/hooks.d.ts +0 -0
  40. /package/dist/{input → components/input}/index.d.ts +0 -0
  41. /package/dist/{input → components/input}/input.d.ts +0 -0
  42. /package/dist/{input → components/input}/label.d.ts +0 -0
  43. /package/dist/{input → components/input}/styled.d.ts +0 -0
  44. /package/dist/{loading → components/loading}/circle.d.ts +0 -0
  45. /package/dist/{loading → components/loading}/index.d.ts +0 -0
  46. /package/dist/{loading → components/loading}/loading.d.ts +0 -0
  47. /package/dist/{loading → components/loading}/styled.d.ts +0 -0
  48. /package/dist/{loading → components/loading}/types.d.ts +0 -0
  49. /package/dist/{menu → components/menu}/context.d.ts +0 -0
  50. /package/dist/{menu → components/menu}/group.d.ts +0 -0
  51. /package/dist/{menu → components/menu}/index.d.ts +0 -0
  52. /package/dist/{menu → components/menu}/menu.d.ts +0 -0
  53. /package/dist/{menu → components/menu}/styled.d.ts +0 -0
  54. /package/dist/{menu → components/menu}/types.d.ts +0 -0
  55. /package/dist/{message → components/message}/holder.d.ts +0 -0
  56. /package/dist/{message → components/message}/hooks.d.ts +0 -0
  57. /package/dist/{message → components/message}/index.d.ts +0 -0
  58. /package/dist/{message → components/message}/message.d.ts +0 -0
  59. /package/dist/{message → components/message}/styled.d.ts +0 -0
  60. /package/dist/{message → components/message}/types.d.ts +0 -0
  61. /package/dist/{popper → components/popper}/index.d.ts +0 -0
  62. /package/dist/{popper → components/popper}/popper.d.ts +0 -0
  63. /package/dist/{popper → components/popper}/styled.d.ts +0 -0
  64. /package/dist/{popper → components/popper}/types.d.ts +0 -0
  65. /package/dist/{radio → components/radio}/context.d.ts +0 -0
  66. /package/dist/{radio → components/radio}/group.d.ts +0 -0
  67. /package/dist/{radio → components/radio}/index.d.ts +0 -0
  68. /package/dist/{radio → components/radio}/radio.d.ts +0 -0
  69. /package/dist/{radio → components/radio}/styled.d.ts +0 -0
  70. /package/dist/{radio → components/radio}/types.d.ts +0 -0
  71. /package/dist/{row → components/row}/index.d.ts +0 -0
  72. /package/dist/{row → components/row}/row.d.ts +0 -0
  73. /package/dist/{row → components/row}/styled.d.ts +0 -0
  74. /package/dist/{row → components/row}/types.d.ts +0 -0
  75. /package/dist/{select → components/select}/hooks.d.ts +0 -0
  76. /package/dist/{select → components/select}/index.d.ts +0 -0
  77. /package/dist/{select → components/select}/select.d.ts +0 -0
  78. /package/dist/{select → components/select}/types.d.ts +0 -0
  79. /package/dist/{switch → components/switch}/index.d.ts +0 -0
  80. /package/dist/{switch → components/switch}/styled.d.ts +0 -0
  81. /package/dist/{switch → components/switch}/switch.d.ts +0 -0
  82. /package/dist/{switch → components/switch}/types.d.ts +0 -0
  83. /package/dist/{theme → components/theme}/theme-provider.d.ts +0 -0
  84. /package/dist/{theme → components/theme}/types.d.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  import styled from '@emotion/styled';
2
- import { useTheme } from '../theme/hooks.js';
2
+ import { useValidTheme } from '../theme/hooks.js';
3
3
 
4
4
  /**
5
5
  * @author murukal
@@ -7,10 +7,10 @@ import { useTheme } from '../theme/hooks.js';
7
7
  * @description
8
8
  * content
9
9
  */
10
- const Span = styled.span(() => {
10
+ const Span = styled.span(({ theme }) => {
11
11
  var _a, _b;
12
- const theme = useTheme();
13
- return Object.assign({ marginLeft: 8, marginRight: 8, color: "#fff" }, (_b = (_a = theme.typography) === null || _a === void 0 ? void 0 : _a.label) === null || _b === void 0 ? void 0 : _b.large);
12
+ const validTheme = useValidTheme(theme);
13
+ return Object.assign({ marginLeft: 8, marginRight: 8, color: "#fff" }, (_b = (_a = validTheme.typography) === null || _a === void 0 ? void 0 : _a.label) === null || _b === void 0 ? void 0 : _b.large);
14
14
  });
15
15
 
16
16
  export { Span as default };
@@ -1,13 +1,13 @@
1
1
  import styled from '@emotion/styled';
2
- import { useTheme } from '../theme/hooks.js';
2
+ import { useValidTheme } from '../theme/hooks.js';
3
3
 
4
- const Wrapper = styled.button(() => {
4
+ const Wrapper = styled.button(({ theme }) => {
5
5
  var _a;
6
- const theme = useTheme();
6
+ const validTheme = useValidTheme(theme);
7
7
  return {
8
8
  borderRadius: 999,
9
9
  padding: "10px 16px",
10
- backgroundColor: (_a = theme.colors) === null || _a === void 0 ? void 0 : _a.primary,
10
+ backgroundColor: (_a = validTheme.colors) === null || _a === void 0 ? void 0 : _a.primary,
11
11
  border: "none",
12
12
  };
13
13
  });
@@ -1,9 +1,10 @@
1
1
  import styled from '@emotion/styled';
2
- import { useTheme } from '../theme/hooks.js';
2
+ import { useValidTheme } from '../theme/hooks.js';
3
3
 
4
- const Wrapper = styled.input(() => {
5
- var _a, _b;
6
- const theme = useTheme();
4
+ const Wrapper = styled.input(({ theme }) => {
5
+ var _a;
6
+ const validTheme = useValidTheme(theme);
7
+ const primaryColor = (_a = validTheme.colors) === null || _a === void 0 ? void 0 : _a.primary;
7
8
  return {
8
9
  margin: 0,
9
10
  visibility: "hidden",
@@ -24,8 +25,8 @@ const Wrapper = styled.input(() => {
24
25
  },
25
26
  "&[aria-checked=true]": {
26
27
  "::before": {
27
- backgroundColor: (_a = theme.colors) === null || _a === void 0 ? void 0 : _a.primary,
28
- borderColor: (_b = theme.colors) === null || _b === void 0 ? void 0 : _b.primary,
28
+ backgroundColor: primaryColor,
29
+ borderColor: primaryColor,
29
30
  },
30
31
  "::after": {
31
32
  content: "''",
@@ -12,7 +12,7 @@ export interface InputProps {
12
12
  variant?: Variant;
13
13
  prefix?: ReactNode;
14
14
  suffix?: ReactNode;
15
- type: "password" | "text";
15
+ type?: "password" | "text";
16
16
  value?: string;
17
17
  className?: string;
18
18
  onChange?: VoidFunction;
@@ -6,7 +6,14 @@ import type { Theme } from "./types";
6
6
  * we set some presets theme
7
7
  * let ui components display well
8
8
  */
9
- export declare const presets: Theme;
9
+ export declare const DEFAULT_THEME: Theme;
10
+ /**
11
+ * @author murukal
12
+ *
13
+ * @description
14
+ * use valid theme for components
15
+ */
16
+ export declare const useValidTheme: (usedTheme: Theme) => Theme;
10
17
  /**
11
18
  * @author murukal
12
19
  *
@@ -1,9 +1,7 @@
1
1
  import { useMemo } from 'react';
2
- import { useTheme } from '../theme/hooks.js';
3
2
 
4
3
  const useIconProps = (props) => {
5
- const theme = useTheme();
6
- const size = useMemo(() => props.size || 24, [props.size, theme]);
4
+ const size = useMemo(() => props.size || 24, [props.size]);
7
5
  const color = useMemo(() => props.color || "white", [props.color]);
8
6
  return { size, color };
9
7
  };
@@ -1,13 +1,13 @@
1
1
  import styled from '@emotion/styled';
2
- import { useTheme } from '../theme/hooks.js';
2
+ import { useValidTheme } from '../theme/hooks.js';
3
3
 
4
- const Label = styled.legend(({ isFocused }) => {
4
+ const Label = styled.legend(({ isFocused, theme }) => {
5
5
  var _a, _b, _c;
6
- const theme = useTheme();
7
- return Object.assign(Object.assign(Object.assign({}, (_b = (_a = theme.typography) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.small), {
6
+ const validTheme = useValidTheme(theme);
7
+ return Object.assign(Object.assign(Object.assign({}, (_b = (_a = validTheme.typography) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.small), {
8
8
  // layout
9
9
  paddingInlineStart: 4, paddingInlineEnd: 4 }), (isFocused && {
10
- color: (_c = theme.colors) === null || _c === void 0 ? void 0 : _c.primary,
10
+ color: (_c = validTheme.colors) === null || _c === void 0 ? void 0 : _c.primary,
11
11
  }));
12
12
  });
13
13
 
@@ -1,11 +1,11 @@
1
1
  import styled from '@emotion/styled';
2
- import { useTheme } from '../theme/hooks.js';
2
+ import { useValidTheme } from '../theme/hooks.js';
3
3
 
4
- const Wrapper = styled.fieldset(({ isFocused }) => {
4
+ const Wrapper = styled.fieldset(({ isFocused, theme }) => {
5
5
  var _a;
6
- const theme = useTheme();
6
+ const validTheme = useValidTheme(theme);
7
7
  return Object.assign({ textAlign: "start", height: 56, margin: 0, paddingTop: 0, paddingBottom: 0, display: "flex", alignItems: "center", borderColor: "#79747e", borderWidth: 1, borderStyle: "solid", borderRadius: 4, boxSizing: "border-box" }, (isFocused && {
8
- borderColor: (_a = theme.colors) === null || _a === void 0 ? void 0 : _a.primary,
8
+ borderColor: (_a = validTheme.colors) === null || _a === void 0 ? void 0 : _a.primary,
9
9
  borderWidth: 2,
10
10
  }));
11
11
  });
@@ -1,5 +1,5 @@
1
1
  import styled from '@emotion/styled';
2
- import { useTheme } from '../theme/hooks.js';
2
+ import { useValidTheme } from '../theme/hooks.js';
3
3
 
4
4
  /**
5
5
  * @author murukal
@@ -24,10 +24,10 @@ const HolderWrapper = styled.div(() => {
24
24
  * @description
25
25
  * wrapper of message
26
26
  */
27
- const MessageWrapper = styled.div(() => {
27
+ const MessageWrapper = styled.div(({ theme }) => {
28
28
  var _a;
29
- const theme = useTheme();
30
- return Object.assign({ marginTop: 8, marginBottom: 8, padding: "8px 12px", borderRadius: 6, backgroundColor: "#ffffff" }, (_a = theme.elevations) === null || _a === void 0 ? void 0 : _a[1]);
29
+ const validTheme = useValidTheme(theme);
30
+ return Object.assign({ marginTop: 8, marginBottom: 8, padding: "8px 12px", borderRadius: 6, backgroundColor: "#ffffff" }, (_a = validTheme.elevations) === null || _a === void 0 ? void 0 : _a[1]);
31
31
  });
32
32
 
33
33
  export { HolderWrapper, MessageWrapper };
@@ -1,9 +1,9 @@
1
1
  import styled from '@emotion/styled';
2
- import { useTheme } from '../theme/hooks.js';
2
+ import { useValidTheme } from '../theme/hooks.js';
3
3
 
4
- const Wrapper = styled.input(() => {
4
+ const Wrapper = styled.input(({ theme }) => {
5
5
  var _a;
6
- const theme = useTheme();
6
+ const validTheme = useValidTheme(theme);
7
7
  return {
8
8
  visibility: "hidden",
9
9
  margin: 0,
@@ -25,7 +25,7 @@ const Wrapper = styled.input(() => {
25
25
  "&[aria-checked=true]": {
26
26
  "::after": {
27
27
  borderWidth: "0.3rem",
28
- borderColor: (_a = theme.colors) === null || _a === void 0 ? void 0 : _a.primary,
28
+ borderColor: (_a = validTheme.colors) === null || _a === void 0 ? void 0 : _a.primary,
29
29
  },
30
30
  },
31
31
  };
@@ -1,9 +1,9 @@
1
1
  import styled from '@emotion/styled';
2
- import { useTheme } from '../theme/hooks.js';
2
+ import { useValidTheme } from '../theme/hooks.js';
3
3
 
4
- const Wrapper = styled.div(() => {
4
+ const Wrapper = styled.div(({ theme }) => {
5
5
  var _a, _b;
6
- const theme = useTheme();
6
+ const validTheme = useValidTheme(theme);
7
7
  return {
8
8
  width: "1.8rem",
9
9
  height: "1rem",
@@ -24,8 +24,8 @@ const Wrapper = styled.div(() => {
24
24
  transition: "all .2s",
25
25
  },
26
26
  "&[aria-selected=true]": {
27
- borderColor: (_a = theme.colors) === null || _a === void 0 ? void 0 : _a.primary,
28
- backgroundColor: (_b = theme.colors) === null || _b === void 0 ? void 0 : _b.primary,
27
+ borderColor: (_a = validTheme.colors) === null || _a === void 0 ? void 0 : _a.primary,
28
+ backgroundColor: (_b = validTheme.colors) === null || _b === void 0 ? void 0 : _b.primary,
29
29
  "::before": {
30
30
  translate: "100%",
31
31
  backgroundColor: "white",
@@ -1,5 +1,6 @@
1
1
  import { useMemo } from 'react';
2
- import { useTheme as useTheme$1 } from '@emotion/react';
2
+ import '@emotion/react';
3
+ import { isEmpty } from '../utils/object.js';
3
4
 
4
5
  const palettes = {
5
6
  primary: {
@@ -85,7 +86,7 @@ const palettes = {
85
86
  * we set some presets theme
86
87
  * let ui components display well
87
88
  */
88
- const presets = {
89
+ const DEFAULT_THEME = {
89
90
  colors: {
90
91
  primary: palettes.primary[40],
91
92
  secondary: palettes.secondary[40],
@@ -139,18 +140,12 @@ const presets = {
139
140
  * @author murukal
140
141
  *
141
142
  * @description
142
- * hook wrapper for emotion theme hook
143
- * because emotion theme has the default value
144
- * but the default value can not be changed
145
- * set the preset theme for musae ui component
143
+ * use valid theme for components
146
144
  */
147
- const useTheme = () => {
148
- // emotion theme
149
- const theme = useTheme$1();
150
- // if theme is empty
151
- const isThemeEmpty = useMemo(() => Object.keys(theme).length === 0, [theme]);
152
- // when is empty, we always think there are not any theme. use presets!!!
153
- return useMemo(() => (isThemeEmpty ? presets : theme), [theme, isThemeEmpty]);
154
- };
145
+ const useValidTheme = (usedTheme) => useMemo(() => {
146
+ if (isEmpty(usedTheme))
147
+ return DEFAULT_THEME;
148
+ return usedTheme;
149
+ }, [usedTheme]);
155
150
 
156
- export { presets, useTheme };
151
+ export { DEFAULT_THEME, useValidTheme };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @author murukal
3
+ *
4
+ * is empty
5
+ */
6
+ export declare const isEmpty: (value?: Object | null) => boolean;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @author murukal
3
+ *
4
+ * is empty
5
+ */
6
+ const isEmpty = (value) => {
7
+ if (!value)
8
+ return true;
9
+ return Object.keys(value).length === 0;
10
+ };
11
+
12
+ export { isEmpty };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musae",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "musae-ui",
5
5
  "author": "tutu@fantufantu.com",
6
6
  "license": "MIT",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes