@geoinsight/react-components 0.4.5 → 0.5.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/dist/cjs/index.css +13 -3
- package/dist/cjs/index.js +24 -23
- package/dist/esm/index.css +13 -3
- package/dist/esm/index.js +24 -23
- package/package.json +2 -1
package/dist/cjs/index.css
CHANGED
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
[palette
|
|
82
|
+
[data-palette="water"] {
|
|
83
83
|
--color-primary-100: #d6efff;
|
|
84
84
|
--color-primary-200: #ade0ff;
|
|
85
85
|
--color-primary-300: #85d0ff;
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
--color-primary-900: #00588f;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
[palette
|
|
94
|
+
[data-palette="earth"]{
|
|
95
95
|
--color-primary-100: #f6e3cb;
|
|
96
96
|
--color-primary-200: #edc897;
|
|
97
97
|
--color-primary-300: #eabe86;
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
--color-primary-900: #684312;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
[palette
|
|
106
|
+
[data-palette="forest"] {
|
|
107
107
|
--color-primary-100: #bee8b0;
|
|
108
108
|
--color-primary-200: #a4df90;
|
|
109
109
|
--color-primary-300: #8ad671;
|
|
@@ -295,14 +295,18 @@ transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic
|
|
|
295
295
|
display: flex;
|
|
296
296
|
flex-direction: column;
|
|
297
297
|
align-items: flex-start;
|
|
298
|
+
width: 100%;
|
|
298
299
|
}
|
|
299
300
|
|
|
300
301
|
.input {
|
|
302
|
+
box-sizing: border-box;
|
|
301
303
|
background-color: var(--color-white);
|
|
302
304
|
border-radius: var(--spacing-8);
|
|
303
305
|
border: 2px solid var(--color-primary);
|
|
304
306
|
color: var(--color-black);
|
|
305
307
|
padding: var(--spacing-16) var(--spacing-24);
|
|
308
|
+
font-size:var(--font-size-16);
|
|
309
|
+
width: 100%;
|
|
306
310
|
}
|
|
307
311
|
|
|
308
312
|
.input:hover {
|
|
@@ -318,6 +322,11 @@ transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic
|
|
|
318
322
|
border: 3px solid var(--color-danger);
|
|
319
323
|
}
|
|
320
324
|
|
|
325
|
+
.input--error:focus {
|
|
326
|
+
border: 3px solid var(--color-danger);
|
|
327
|
+
outline: none;
|
|
328
|
+
}
|
|
329
|
+
|
|
321
330
|
.error {
|
|
322
331
|
font-size: 12px;
|
|
323
332
|
color: var(--color-danger);
|
|
@@ -326,6 +335,7 @@ transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic
|
|
|
326
335
|
.textarea {
|
|
327
336
|
margin-bottom: var(--spacing-8);
|
|
328
337
|
position: relative;
|
|
338
|
+
width: 100%;
|
|
329
339
|
}
|
|
330
340
|
|
|
331
341
|
.textarea__input {
|
package/dist/cjs/index.js
CHANGED
|
@@ -99,9 +99,19 @@ function Button({ children = "Click me", className = "", icon = undefined, isNew
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
const ThemeContext = react.createContext(undefined);
|
|
102
|
-
function ThemeProvider({ children }) {
|
|
102
|
+
function ThemeProvider({ children, dataTheme: dataThemeProp, dataPalette: dataPaletteProp = "water", }) {
|
|
103
103
|
const [dataTheme, setDataTheme] = react.useState();
|
|
104
|
-
const [
|
|
104
|
+
const [dataPalette, setDataPalette] = react.useState();
|
|
105
|
+
react.useEffect(() => {
|
|
106
|
+
if (dataPaletteProp) {
|
|
107
|
+
switchDataPalette(dataPaletteProp);
|
|
108
|
+
}
|
|
109
|
+
}, [dataPaletteProp]);
|
|
110
|
+
react.useEffect(() => {
|
|
111
|
+
if (dataThemeProp) {
|
|
112
|
+
switchDataTheme(dataThemeProp);
|
|
113
|
+
}
|
|
114
|
+
}, [dataThemeProp]);
|
|
105
115
|
react.useEffect(() => {
|
|
106
116
|
if (window.matchMedia) {
|
|
107
117
|
if (localStorage.getItem("data-theme")) {
|
|
@@ -119,27 +129,15 @@ function ThemeProvider({ children }) {
|
|
|
119
129
|
setDataTheme(mode);
|
|
120
130
|
localStorage.setItem("data-theme", mode);
|
|
121
131
|
};
|
|
122
|
-
const
|
|
123
|
-
document.documentElement.setAttribute("palette
|
|
124
|
-
|
|
132
|
+
const switchDataPalette = (mode) => {
|
|
133
|
+
document.documentElement.setAttribute("data-palette", mode);
|
|
134
|
+
setDataPalette(mode);
|
|
125
135
|
localStorage.setItem("palette-theme", mode);
|
|
126
136
|
};
|
|
127
|
-
return (jsxRuntime.jsx(ThemeContext.Provider, { value: { dataTheme, switchDataTheme,
|
|
137
|
+
return (jsxRuntime.jsx(ThemeContext.Provider, { value: { dataTheme, switchDataTheme, dataPalette, switchDataPalette }, children: children }));
|
|
128
138
|
}
|
|
129
|
-
function useTheme(
|
|
139
|
+
function useTheme() {
|
|
130
140
|
const context = react.useContext(ThemeContext);
|
|
131
|
-
// only happens if there is an initial mode value.
|
|
132
|
-
react.useEffect(() => {
|
|
133
|
-
if (dataTheme && !localStorage.getItem("data-theme")) {
|
|
134
|
-
context?.switchDataTheme(dataTheme);
|
|
135
|
-
}
|
|
136
|
-
else if (!dataTheme && localStorage.getItem("data-theme")) {
|
|
137
|
-
localStorage.removeItem("data-theme");
|
|
138
|
-
}
|
|
139
|
-
}, []);
|
|
140
|
-
react.useEffect(() => {
|
|
141
|
-
context?.switchPaletteTheme(paletteTheme);
|
|
142
|
-
}, []);
|
|
143
141
|
if (context === undefined) {
|
|
144
142
|
throw new Error("useTheme must be used within a ThemeProvider");
|
|
145
143
|
}
|
|
@@ -179,11 +177,14 @@ const AccordionContent = function AccordionContent({ children, label, toggle, })
|
|
|
179
177
|
toggle[label].isToggle && (jsxRuntime.jsx("div", { className: "accordion-content", children: children })));
|
|
180
178
|
};
|
|
181
179
|
|
|
182
|
-
function Input({ className = "", classNameGroup = "",
|
|
183
|
-
|
|
180
|
+
function Input({ className = "", classNameGroup = "", error = {
|
|
181
|
+
is: false,
|
|
182
|
+
message: "",
|
|
183
|
+
}, inputRef, styleGroup, placeholder = "Insert value", isRequired, ...rest }) {
|
|
184
|
+
return (jsxRuntime.jsxs("div", { className: clsx("input-group", classNameGroup), style: styleGroup, children: [jsxRuntime.jsx("input", { ref: inputRef, className: clsx("input", error.is ? "input--error" : "", className), placeholder: placeholder, ...rest }), error && error.is && jsxRuntime.jsx("span", { className: "error", children: error.message })] }));
|
|
184
185
|
}
|
|
185
186
|
|
|
186
|
-
function TextArea({ className = "", disabled = true, hasToggleButton = true, hideHeight = "5rem", placeholder = "", showHeight = "10rem", style = {}, textareaClassName = "", ...rest }) {
|
|
187
|
+
function TextArea({ className = "", disabled = true, hasToggleButton = true, hideHeight = "5rem", placeholder = "Insert value", showHeight = "10rem", style = {}, textareaClassName = "", ...rest }) {
|
|
187
188
|
const ref = react.useRef();
|
|
188
189
|
const [isShow, setIsShow] = react.useState(false);
|
|
189
190
|
const handleClickToggle = () => {
|
|
@@ -199,7 +200,7 @@ function TextArea({ className = "", disabled = true, hasToggleButton = true, hid
|
|
|
199
200
|
};
|
|
200
201
|
return (jsxRuntime.jsxs("div", { className: clsx("textarea", className), style: style, children: [jsxRuntime.jsx("textarea", { ref: ref, className: clsx("textarea__input", textareaClassName), style: {
|
|
201
202
|
height: hasToggleButton ? hideHeight : showHeight,
|
|
202
|
-
}, placeholder: placeholder, disabled: disabled, ...rest }), hasToggleButton && (jsxRuntime.jsx("button", { className: clsx("textarea__button", isShow && "textarea__button--show"), onClick: handleClickToggle, disabled: disabled, children: jsxRuntime.jsx(tb.TbArrowsDiagonal2, { size: "1.5rem" }) }))] }));
|
|
203
|
+
}, placeholder: placeholder, disabled: disabled, ...rest }), hasToggleButton && (jsxRuntime.jsx("button", { type: "button", className: clsx("textarea__button", isShow && "textarea__button--show"), onClick: handleClickToggle, disabled: disabled, children: jsxRuntime.jsx(tb.TbArrowsDiagonal2, { size: "1.5rem" }) }))] }));
|
|
203
204
|
}
|
|
204
205
|
|
|
205
206
|
function Modal({ modalref, children, title, subtitle, footer, hasCloseButton = true, handleClose, }) {
|
package/dist/esm/index.css
CHANGED
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
[palette
|
|
82
|
+
[data-palette="water"] {
|
|
83
83
|
--color-primary-100: #d6efff;
|
|
84
84
|
--color-primary-200: #ade0ff;
|
|
85
85
|
--color-primary-300: #85d0ff;
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
--color-primary-900: #00588f;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
[palette
|
|
94
|
+
[data-palette="earth"]{
|
|
95
95
|
--color-primary-100: #f6e3cb;
|
|
96
96
|
--color-primary-200: #edc897;
|
|
97
97
|
--color-primary-300: #eabe86;
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
--color-primary-900: #684312;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
[palette
|
|
106
|
+
[data-palette="forest"] {
|
|
107
107
|
--color-primary-100: #bee8b0;
|
|
108
108
|
--color-primary-200: #a4df90;
|
|
109
109
|
--color-primary-300: #8ad671;
|
|
@@ -295,14 +295,18 @@ transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic
|
|
|
295
295
|
display: flex;
|
|
296
296
|
flex-direction: column;
|
|
297
297
|
align-items: flex-start;
|
|
298
|
+
width: 100%;
|
|
298
299
|
}
|
|
299
300
|
|
|
300
301
|
.input {
|
|
302
|
+
box-sizing: border-box;
|
|
301
303
|
background-color: var(--color-white);
|
|
302
304
|
border-radius: var(--spacing-8);
|
|
303
305
|
border: 2px solid var(--color-primary);
|
|
304
306
|
color: var(--color-black);
|
|
305
307
|
padding: var(--spacing-16) var(--spacing-24);
|
|
308
|
+
font-size:var(--font-size-16);
|
|
309
|
+
width: 100%;
|
|
306
310
|
}
|
|
307
311
|
|
|
308
312
|
.input:hover {
|
|
@@ -318,6 +322,11 @@ transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic
|
|
|
318
322
|
border: 3px solid var(--color-danger);
|
|
319
323
|
}
|
|
320
324
|
|
|
325
|
+
.input--error:focus {
|
|
326
|
+
border: 3px solid var(--color-danger);
|
|
327
|
+
outline: none;
|
|
328
|
+
}
|
|
329
|
+
|
|
321
330
|
.error {
|
|
322
331
|
font-size: 12px;
|
|
323
332
|
color: var(--color-danger);
|
|
@@ -326,6 +335,7 @@ transition: var(--transition-bg-cubic-bezier), var(--transition-box-shadow-cubic
|
|
|
326
335
|
.textarea {
|
|
327
336
|
margin-bottom: var(--spacing-8);
|
|
328
337
|
position: relative;
|
|
338
|
+
width: 100%;
|
|
329
339
|
}
|
|
330
340
|
|
|
331
341
|
.textarea__input {
|
package/dist/esm/index.js
CHANGED
|
@@ -97,9 +97,19 @@ function Button({ children = "Click me", className = "", icon = undefined, isNew
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
const ThemeContext = createContext(undefined);
|
|
100
|
-
function ThemeProvider({ children }) {
|
|
100
|
+
function ThemeProvider({ children, dataTheme: dataThemeProp, dataPalette: dataPaletteProp = "water", }) {
|
|
101
101
|
const [dataTheme, setDataTheme] = useState();
|
|
102
|
-
const [
|
|
102
|
+
const [dataPalette, setDataPalette] = useState();
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (dataPaletteProp) {
|
|
105
|
+
switchDataPalette(dataPaletteProp);
|
|
106
|
+
}
|
|
107
|
+
}, [dataPaletteProp]);
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (dataThemeProp) {
|
|
110
|
+
switchDataTheme(dataThemeProp);
|
|
111
|
+
}
|
|
112
|
+
}, [dataThemeProp]);
|
|
103
113
|
useEffect(() => {
|
|
104
114
|
if (window.matchMedia) {
|
|
105
115
|
if (localStorage.getItem("data-theme")) {
|
|
@@ -117,27 +127,15 @@ function ThemeProvider({ children }) {
|
|
|
117
127
|
setDataTheme(mode);
|
|
118
128
|
localStorage.setItem("data-theme", mode);
|
|
119
129
|
};
|
|
120
|
-
const
|
|
121
|
-
document.documentElement.setAttribute("palette
|
|
122
|
-
|
|
130
|
+
const switchDataPalette = (mode) => {
|
|
131
|
+
document.documentElement.setAttribute("data-palette", mode);
|
|
132
|
+
setDataPalette(mode);
|
|
123
133
|
localStorage.setItem("palette-theme", mode);
|
|
124
134
|
};
|
|
125
|
-
return (jsx(ThemeContext.Provider, { value: { dataTheme, switchDataTheme,
|
|
135
|
+
return (jsx(ThemeContext.Provider, { value: { dataTheme, switchDataTheme, dataPalette, switchDataPalette }, children: children }));
|
|
126
136
|
}
|
|
127
|
-
function useTheme(
|
|
137
|
+
function useTheme() {
|
|
128
138
|
const context = useContext(ThemeContext);
|
|
129
|
-
// only happens if there is an initial mode value.
|
|
130
|
-
useEffect(() => {
|
|
131
|
-
if (dataTheme && !localStorage.getItem("data-theme")) {
|
|
132
|
-
context?.switchDataTheme(dataTheme);
|
|
133
|
-
}
|
|
134
|
-
else if (!dataTheme && localStorage.getItem("data-theme")) {
|
|
135
|
-
localStorage.removeItem("data-theme");
|
|
136
|
-
}
|
|
137
|
-
}, []);
|
|
138
|
-
useEffect(() => {
|
|
139
|
-
context?.switchPaletteTheme(paletteTheme);
|
|
140
|
-
}, []);
|
|
141
139
|
if (context === undefined) {
|
|
142
140
|
throw new Error("useTheme must be used within a ThemeProvider");
|
|
143
141
|
}
|
|
@@ -177,11 +175,14 @@ const AccordionContent = function AccordionContent({ children, label, toggle, })
|
|
|
177
175
|
toggle[label].isToggle && (jsx("div", { className: "accordion-content", children: children })));
|
|
178
176
|
};
|
|
179
177
|
|
|
180
|
-
function Input({ className = "", classNameGroup = "",
|
|
181
|
-
|
|
178
|
+
function Input({ className = "", classNameGroup = "", error = {
|
|
179
|
+
is: false,
|
|
180
|
+
message: "",
|
|
181
|
+
}, inputRef, styleGroup, placeholder = "Insert value", isRequired, ...rest }) {
|
|
182
|
+
return (jsxs("div", { className: clsx("input-group", classNameGroup), style: styleGroup, children: [jsx("input", { ref: inputRef, className: clsx("input", error.is ? "input--error" : "", className), placeholder: placeholder, ...rest }), error && error.is && jsx("span", { className: "error", children: error.message })] }));
|
|
182
183
|
}
|
|
183
184
|
|
|
184
|
-
function TextArea({ className = "", disabled = true, hasToggleButton = true, hideHeight = "5rem", placeholder = "", showHeight = "10rem", style = {}, textareaClassName = "", ...rest }) {
|
|
185
|
+
function TextArea({ className = "", disabled = true, hasToggleButton = true, hideHeight = "5rem", placeholder = "Insert value", showHeight = "10rem", style = {}, textareaClassName = "", ...rest }) {
|
|
185
186
|
const ref = useRef();
|
|
186
187
|
const [isShow, setIsShow] = useState(false);
|
|
187
188
|
const handleClickToggle = () => {
|
|
@@ -197,7 +198,7 @@ function TextArea({ className = "", disabled = true, hasToggleButton = true, hid
|
|
|
197
198
|
};
|
|
198
199
|
return (jsxs("div", { className: clsx("textarea", className), style: style, children: [jsx("textarea", { ref: ref, className: clsx("textarea__input", textareaClassName), style: {
|
|
199
200
|
height: hasToggleButton ? hideHeight : showHeight,
|
|
200
|
-
}, placeholder: placeholder, disabled: disabled, ...rest }), hasToggleButton && (jsx("button", { className: clsx("textarea__button", isShow && "textarea__button--show"), onClick: handleClickToggle, disabled: disabled, children: jsx(TbArrowsDiagonal2, { size: "1.5rem" }) }))] }));
|
|
201
|
+
}, placeholder: placeholder, disabled: disabled, ...rest }), hasToggleButton && (jsx("button", { type: "button", className: clsx("textarea__button", isShow && "textarea__button--show"), onClick: handleClickToggle, disabled: disabled, children: jsx(TbArrowsDiagonal2, { size: "1.5rem" }) }))] }));
|
|
201
202
|
}
|
|
202
203
|
|
|
203
204
|
function Modal({ modalref, children, title, subtitle, footer, hasCloseButton = true, handleClose, }) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geoinsight/react-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "This library is the main UI component library for geoinsight",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"clsx": "^1.2.1",
|
|
19
19
|
"react": "^18.2.0",
|
|
20
20
|
"react-dom": "^18.2.0",
|
|
21
|
+
"react-hook-form": "^7.45.2",
|
|
21
22
|
"react-icons": "^4.7.1",
|
|
22
23
|
"typescript": "^4.9.4"
|
|
23
24
|
},
|