addon-ui 0.9.1 → 0.10.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.
- package/README.md +51 -12
- package/dist-types/components/Select/Select.d.ts +1 -1
- package/dist-types/components/Select/SelectIcon.d.ts +1 -1
- package/dist-types/components/Select/SelectValue.d.ts +1 -1
- package/dist-types/components/TextField/TextField.d.ts +2 -1
- package/dist-types/components/TextField/utils.d.ts +8 -0
- package/dist-types/components/Truncate/Truncate.d.ts +2 -2
- package/dist-types/components/Truncate/utils.d.ts +2 -0
- package/dist-types/plugin/index.d.ts +28 -2
- package/dist-types/providers/theme/ThemeProvider.d.ts +88 -0
- package/dist-types/providers/ui/UIProvider.d.ts +22 -1
- package/package.json +4 -8
- package/src/components/Select/Select.tsx +1 -1
- package/src/components/Select/SelectIcon.tsx +1 -1
- package/src/components/Select/SelectValue.tsx +1 -1
- package/src/components/TextField/TextField.tsx +66 -13
- package/src/components/TextField/text-field.module.scss +3 -1
- package/src/components/TextField/utils.ts +56 -0
- package/src/components/Truncate/Truncate.tsx +38 -56
- package/src/components/Truncate/truncate.module.scss +14 -15
- package/src/components/Truncate/utils.ts +62 -0
- package/src/plugin/index.ts +223 -9
- package/src/providers/theme/ThemeProvider.tsx +121 -15
- package/src/providers/ui/UIProvider.tsx +42 -15
- package/src/providers/ui/styles/default.scss +1 -1
- package/src/styles/mixins.scss +19 -6
- /package/src/providers/theme/{ThemeStorage.tsx → ThemeStorage.ts} +0 -0
|
@@ -15,18 +15,34 @@ import "addon-ui-style.scss";
|
|
|
15
15
|
|
|
16
16
|
import config from "addon-ui-config";
|
|
17
17
|
|
|
18
|
-
export interface UIProviderProps extends Partial<Config>, Pick<ThemeProviderProps, "storage"> {
|
|
18
|
+
export interface UIProviderProps extends Partial<Config>, Pick<ThemeProviderProps, "storage" | "container"> {
|
|
19
|
+
/**
|
|
20
|
+
* A custom view identifier that allows developers to specify a unique name for styling customization.
|
|
21
|
+
* This value is set as a "view" attribute on the container element and can be targeted through SCSS mixins
|
|
22
|
+
* to apply view-specific styles and behavior.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <UIProvider view="dashboard">
|
|
27
|
+
* <App />
|
|
28
|
+
* </UIProvider>
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```scss
|
|
33
|
+
* @include view("dashboard") {
|
|
34
|
+
* .some-class {
|
|
35
|
+
* // Custom styles for dashboard view
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
19
40
|
view?: string;
|
|
20
41
|
}
|
|
21
42
|
|
|
22
|
-
const UIProvider: FC<PropsWithChildren<UIProviderProps>> =
|
|
23
|
-
children,
|
|
24
|
-
|
|
25
|
-
extra = {},
|
|
26
|
-
icons = {},
|
|
27
|
-
storage,
|
|
28
|
-
view,
|
|
29
|
-
}) => {
|
|
43
|
+
const UIProvider: FC<PropsWithChildren<UIProviderProps>> = props => {
|
|
44
|
+
const {children, components = {}, extra = {}, icons = {}, storage, view, container = "html"} = props;
|
|
45
|
+
|
|
30
46
|
const componentsProps = useMemo<ComponentsProps>(() => merge(config.components || {}, components), [components]);
|
|
31
47
|
|
|
32
48
|
const extraProps = useMemo<ExtraProps>(() => merge(config.extra || {}, extra), [extra]);
|
|
@@ -34,17 +50,28 @@ const UIProvider: FC<PropsWithChildren<UIProviderProps>> = ({
|
|
|
34
50
|
const svgIcons = useMemo<Icons>(() => merge(config.icons || {}, icons), [icons]);
|
|
35
51
|
|
|
36
52
|
useEffect(() => {
|
|
37
|
-
|
|
38
|
-
|
|
53
|
+
if (container === false) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const element = typeof container === "string" ? document.querySelector(container) : container;
|
|
58
|
+
|
|
59
|
+
if (element) {
|
|
39
60
|
if (view) {
|
|
40
|
-
|
|
61
|
+
element.setAttribute("view", view);
|
|
41
62
|
}
|
|
42
|
-
|
|
63
|
+
|
|
64
|
+
element.setAttribute("browser", getBrowser());
|
|
65
|
+
|
|
66
|
+
return () => {
|
|
67
|
+
element.removeAttribute("browser");
|
|
68
|
+
element.removeAttribute("view");
|
|
69
|
+
};
|
|
43
70
|
}
|
|
44
|
-
}, [view]);
|
|
71
|
+
}, [view, container]);
|
|
45
72
|
|
|
46
73
|
return (
|
|
47
|
-
<ThemeProvider components={componentsProps} storage={storage}>
|
|
74
|
+
<ThemeProvider components={componentsProps} storage={storage} container={container}>
|
|
48
75
|
<ExtraProvider extra={extraProps}>
|
|
49
76
|
<IconsProvider icons={svgIcons}>{children}</IconsProvider>
|
|
50
77
|
</ExtraProvider>
|
package/src/styles/mixins.scss
CHANGED
|
@@ -1,35 +1,48 @@
|
|
|
1
|
+
@mixin _attribute-context($attr, $value) {
|
|
2
|
+
@if & {
|
|
3
|
+
[#{$attr}="#{$value}"] &,
|
|
4
|
+
&[#{$attr}="#{$value}"] {
|
|
5
|
+
@content;
|
|
6
|
+
}
|
|
7
|
+
} @else {
|
|
8
|
+
[#{$attr}="#{$value}"] {
|
|
9
|
+
@content;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
1
14
|
@mixin light {
|
|
2
|
-
|
|
15
|
+
@include _attribute-context("theme", "light") {
|
|
3
16
|
@content;
|
|
4
17
|
}
|
|
5
18
|
}
|
|
6
19
|
|
|
7
20
|
@mixin dark {
|
|
8
|
-
|
|
21
|
+
@include _attribute-context("theme", "dark") {
|
|
9
22
|
@content;
|
|
10
23
|
}
|
|
11
24
|
}
|
|
12
25
|
|
|
13
26
|
@mixin ltr {
|
|
14
|
-
|
|
27
|
+
@include _attribute-context("dir", "ltr") {
|
|
15
28
|
@content;
|
|
16
29
|
}
|
|
17
30
|
}
|
|
18
31
|
|
|
19
32
|
@mixin rtl {
|
|
20
|
-
|
|
33
|
+
@include _attribute-context("dir", "rtl") {
|
|
21
34
|
@content;
|
|
22
35
|
}
|
|
23
36
|
}
|
|
24
37
|
|
|
25
38
|
@mixin view($view) {
|
|
26
|
-
|
|
39
|
+
@include _attribute-context("view", $view) {
|
|
27
40
|
@content;
|
|
28
41
|
}
|
|
29
42
|
}
|
|
30
43
|
|
|
31
44
|
@mixin browser($browser) {
|
|
32
|
-
|
|
45
|
+
@include _attribute-context("browser", $browser) {
|
|
33
46
|
@content;
|
|
34
47
|
}
|
|
35
48
|
}
|
|
File without changes
|