@rolster/react-components 19.7.3 → 19.7.5
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/LICENSE +21 -21
- package/dist/cjs/index.cjs +33 -10
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/es/index.mjs +34 -12
- package/dist/es/index.mjs.map +1 -1
- package/dist/esm/components/molecules/Tabs/Tabs.d.ts +4 -1
- package/dist/esm/components/molecules/Tabs/Tabs.js +25 -11
- package/dist/esm/components/molecules/Tabs/Tabs.js.map +1 -1
- package/dist/esm/controllers/TabsController.d.ts +14 -0
- package/dist/esm/controllers/TabsController.js +12 -0
- package/dist/esm/controllers/TabsController.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +83 -83
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Rolster Technology
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Rolster Technology
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -2300,32 +2300,46 @@ function RlsSliderComponent({ children, className, disabled, formControl, identi
|
|
|
2300
2300
|
}
|
|
2301
2301
|
const RlsSlider = require$$0.memo(RlsSliderComponent);
|
|
2302
2302
|
|
|
2303
|
-
function RlsTab({ onSelect, tab, value }) {
|
|
2303
|
+
function RlsTab({ disabled, onSelect, tab, value }) {
|
|
2304
2304
|
const className = renderClassStatus('rls-tabs__children', {
|
|
2305
2305
|
active: tab.value === value,
|
|
2306
|
-
disabled: tab.disabled
|
|
2306
|
+
disabled: disabled || tab.disabled
|
|
2307
2307
|
});
|
|
2308
2308
|
const onClick = require$$0.useCallback(() => {
|
|
2309
|
-
if (!tab.disabled) {
|
|
2309
|
+
if (!disabled && !tab.disabled) {
|
|
2310
2310
|
onSelect(tab.value);
|
|
2311
2311
|
}
|
|
2312
|
-
}, [tab.disabled]);
|
|
2312
|
+
}, [disabled, tab.disabled, onSelect]);
|
|
2313
2313
|
return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsx("span", { children: tab.label }) }));
|
|
2314
2314
|
}
|
|
2315
|
-
function RlsTabsComponent({ tabs, onValue, rlsTheme }) {
|
|
2316
|
-
const [
|
|
2315
|
+
function RlsTabsComponent({ tabs, formControl, onValue, value, rlsTheme }) {
|
|
2316
|
+
const [valueInternal, setValueInternal] = require$$0.useState();
|
|
2317
|
+
const valueSelected = require$$0.useMemo(() => {
|
|
2318
|
+
return formControl ? formControl.value : valueInternal;
|
|
2319
|
+
}, [formControl?.value, valueInternal]);
|
|
2317
2320
|
const onSelect = require$$0.useCallback((value) => {
|
|
2318
|
-
|
|
2321
|
+
if (formControl) {
|
|
2322
|
+
formControl?.setValue(value);
|
|
2323
|
+
}
|
|
2324
|
+
else {
|
|
2325
|
+
setValueInternal(value);
|
|
2326
|
+
}
|
|
2319
2327
|
onValue?.(value);
|
|
2320
|
-
}, [onValue]);
|
|
2328
|
+
}, [formControl, onValue]);
|
|
2321
2329
|
require$$0.useEffect(() => {
|
|
2330
|
+
if (formControl?.value !== undefined) {
|
|
2331
|
+
return setValueInternal(formControl.value);
|
|
2332
|
+
}
|
|
2333
|
+
if (value !== undefined) {
|
|
2334
|
+
return setValueInternal(value);
|
|
2335
|
+
}
|
|
2322
2336
|
const initial = tabs.find((tab) => tab.defaultActive) ?? tabs[0];
|
|
2323
2337
|
if (initial) {
|
|
2324
2338
|
onSelect(initial.value);
|
|
2325
2339
|
}
|
|
2326
|
-
}, []);
|
|
2340
|
+
}, [value, formControl?.value]);
|
|
2327
2341
|
return (jsxRuntimeExports.jsx("div", { className: "rls-tabs", "rls-theme": rlsTheme, children: tabs.map((tab, index) => {
|
|
2328
|
-
return (jsxRuntimeExports.jsx(RlsTab, { tab: tab, value:
|
|
2342
|
+
return (jsxRuntimeExports.jsx(RlsTab, { tab: tab, disabled: formControl?.disabled, value: valueSelected, onSelect: onSelect }, index));
|
|
2329
2343
|
}) }));
|
|
2330
2344
|
}
|
|
2331
2345
|
const RlsTabs = require$$0.memo(RlsTabsComponent);
|
|
@@ -4722,6 +4736,14 @@ function usePortalController() {
|
|
|
4722
4736
|
return { close, open, visible };
|
|
4723
4737
|
}
|
|
4724
4738
|
|
|
4739
|
+
function useTabsController(options) {
|
|
4740
|
+
const formControl = reactForms.useFormControl(options.value);
|
|
4741
|
+
const Tabs = require$$0.useMemo(() => {
|
|
4742
|
+
return (jsxRuntimeExports.jsx(RlsTabs, { tabs: options.tabs, formControl: formControl, onValue: options.onValue }));
|
|
4743
|
+
}, [options.tabs, options.onValue, formControl]);
|
|
4744
|
+
return { Tabs, formControl };
|
|
4745
|
+
}
|
|
4746
|
+
|
|
4725
4747
|
const APP_THEME_ATTRIBUTE = 'app-theme';
|
|
4726
4748
|
function getAppTheme() {
|
|
4727
4749
|
if (typeof document === 'undefined') {
|
|
@@ -4890,4 +4912,5 @@ exports.useRelocationOnComponent = useRelocationOnComponent;
|
|
|
4890
4912
|
exports.useResize = useResize;
|
|
4891
4913
|
exports.useRlsContext = useRlsContext;
|
|
4892
4914
|
exports.useSnackbar = useSnackbar;
|
|
4915
|
+
exports.useTabsController = useTabsController;
|
|
4893
4916
|
//# sourceMappingURL=index.cjs.map
|