@sebgroup/green-react 1.0.0-beta.18 → 1.0.0-beta.20
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/index.d.ts +1 -0
- package/index.esm.js +128 -5
- package/index.umd.js +127 -3
- package/lib/badge/badge.d.ts +3 -1
- package/package.json +3 -3
package/index.d.ts
CHANGED
package/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import React, { useState, useLayoutEffect, useEffect, useMemo, useRef } from 'react';
|
|
3
|
-
import { randomId, validateClassName, createDropdown } from '@sebgroup/extract';
|
|
3
|
+
import { randomId, validateClassName, createStepper, createDropdown } from '@sebgroup/extract';
|
|
4
4
|
|
|
5
5
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
6
6
|
|
|
@@ -2526,13 +2526,29 @@ function Badge(_a) {
|
|
|
2526
2526
|
children,
|
|
2527
2527
|
badgeType,
|
|
2528
2528
|
isCloseable,
|
|
2529
|
-
closeText
|
|
2529
|
+
closeText,
|
|
2530
|
+
customColor,
|
|
2531
|
+
customBackgroundColor
|
|
2530
2532
|
} = _a,
|
|
2531
|
-
props = __rest(_a, ["children", "badgeType", "isCloseable", "closeText"]);
|
|
2533
|
+
props = __rest(_a, ["children", "badgeType", "isCloseable", "closeText", "customColor", "customBackgroundColor"]);
|
|
2532
2534
|
|
|
2533
2535
|
const [isClosed, setIsClosed] = React.useState(false);
|
|
2536
|
+
const [type, setType] = React.useState('');
|
|
2537
|
+
React.useEffect(() => {
|
|
2538
|
+
if (badgeType) {
|
|
2539
|
+
setType(badgeType);
|
|
2540
|
+
}
|
|
2541
|
+
|
|
2542
|
+
if (!!customColor || !!customBackgroundColor) {
|
|
2543
|
+
setType('');
|
|
2544
|
+
}
|
|
2545
|
+
}, []);
|
|
2534
2546
|
return !isClosed ? jsxs("span", Object.assign({}, props, {
|
|
2535
|
-
className: `badge ${
|
|
2547
|
+
className: `badge ${type}`,
|
|
2548
|
+
style: {
|
|
2549
|
+
color: customColor,
|
|
2550
|
+
backgroundColor: customBackgroundColor
|
|
2551
|
+
}
|
|
2536
2552
|
}, {
|
|
2537
2553
|
children: [jsx("strong", {
|
|
2538
2554
|
children: children
|
|
@@ -2546,6 +2562,113 @@ function Badge(_a) {
|
|
|
2546
2562
|
})) : null;
|
|
2547
2563
|
}
|
|
2548
2564
|
|
|
2565
|
+
const noop = () => {};
|
|
2566
|
+
|
|
2567
|
+
const useStepper = ({
|
|
2568
|
+
min,
|
|
2569
|
+
max,
|
|
2570
|
+
value: _value = 0,
|
|
2571
|
+
step: _step = 1,
|
|
2572
|
+
id: _id = randomId()
|
|
2573
|
+
}) => {
|
|
2574
|
+
const pStepper = {
|
|
2575
|
+
down: noop,
|
|
2576
|
+
setMax: noop,
|
|
2577
|
+
setMin: noop,
|
|
2578
|
+
setStep: noop,
|
|
2579
|
+
setValue: noop,
|
|
2580
|
+
up: noop
|
|
2581
|
+
};
|
|
2582
|
+
const [stepper, setStepper] = useState(pStepper);
|
|
2583
|
+
const [data, setData] = useState({
|
|
2584
|
+
id: _id,
|
|
2585
|
+
value: _value,
|
|
2586
|
+
min,
|
|
2587
|
+
max,
|
|
2588
|
+
step: _step
|
|
2589
|
+
});
|
|
2590
|
+
useEffect(() => {
|
|
2591
|
+
if (max !== data.max) stepper.setMax(max);
|
|
2592
|
+
}, [stepper, max]);
|
|
2593
|
+
useEffect(() => {
|
|
2594
|
+
if (min !== data.min) stepper.setMin(min);
|
|
2595
|
+
}, [stepper, min]);
|
|
2596
|
+
useEffect(() => {
|
|
2597
|
+
if (_step !== data.step) stepper.setStep(_step || 1);
|
|
2598
|
+
}, [stepper, _step]);
|
|
2599
|
+
useEffect(() => {
|
|
2600
|
+
if (_value !== data.value) stepper.setValue(_value || 0);
|
|
2601
|
+
}, [stepper, _value]);
|
|
2602
|
+
useEffect(() => {
|
|
2603
|
+
setStepper(createStepper({
|
|
2604
|
+
id: _id,
|
|
2605
|
+
value: _value,
|
|
2606
|
+
min,
|
|
2607
|
+
max,
|
|
2608
|
+
step: _step
|
|
2609
|
+
}, setData));
|
|
2610
|
+
}, []);
|
|
2611
|
+
return [stepper, data];
|
|
2612
|
+
};
|
|
2613
|
+
|
|
2614
|
+
function Stepper(_a) {
|
|
2615
|
+
var {
|
|
2616
|
+
label,
|
|
2617
|
+
description,
|
|
2618
|
+
statusMessage,
|
|
2619
|
+
onChange
|
|
2620
|
+
} = _a,
|
|
2621
|
+
props = __rest(_a, ["label", "description", "statusMessage", "onChange"]);
|
|
2622
|
+
|
|
2623
|
+
const [stepper, data] = useStepper(props);
|
|
2624
|
+
useEffect(() => {
|
|
2625
|
+
if (onChange && data.value) onChange(data.value);
|
|
2626
|
+
}, [data.value]);
|
|
2627
|
+
|
|
2628
|
+
const onChangeEvent = e => {
|
|
2629
|
+
stepper.setValue(e.target.valueAsNumber);
|
|
2630
|
+
};
|
|
2631
|
+
|
|
2632
|
+
return jsxs("div", Object.assign({
|
|
2633
|
+
className: "form-group"
|
|
2634
|
+
}, {
|
|
2635
|
+
children: [label && jsx("label", Object.assign({
|
|
2636
|
+
htmlFor: data.id
|
|
2637
|
+
}, {
|
|
2638
|
+
children: label
|
|
2639
|
+
})), description && jsx("span", Object.assign({
|
|
2640
|
+
className: "form-info"
|
|
2641
|
+
}, {
|
|
2642
|
+
children: description
|
|
2643
|
+
})), jsxs("div", Object.assign({
|
|
2644
|
+
className: "group group-border group-stepper"
|
|
2645
|
+
}, {
|
|
2646
|
+
children: [jsx("button", Object.assign({
|
|
2647
|
+
onClick: () => stepper.down()
|
|
2648
|
+
}, {
|
|
2649
|
+
children: "-"
|
|
2650
|
+
})), jsx("input", {
|
|
2651
|
+
id: data.id,
|
|
2652
|
+
type: "number",
|
|
2653
|
+
onChange: onChangeEvent,
|
|
2654
|
+
onFocus: ({
|
|
2655
|
+
target
|
|
2656
|
+
}) => target.select(),
|
|
2657
|
+
placeholder: "0",
|
|
2658
|
+
value: data.value
|
|
2659
|
+
}), jsx("button", Object.assign({
|
|
2660
|
+
onClick: () => stepper.up()
|
|
2661
|
+
}, {
|
|
2662
|
+
children: "+"
|
|
2663
|
+
}))]
|
|
2664
|
+
})), statusMessage && jsx("span", Object.assign({
|
|
2665
|
+
className: "form-info"
|
|
2666
|
+
}, {
|
|
2667
|
+
children: statusMessage
|
|
2668
|
+
}))]
|
|
2669
|
+
}));
|
|
2670
|
+
}
|
|
2671
|
+
|
|
2549
2672
|
const useDropdown = ({
|
|
2550
2673
|
id,
|
|
2551
2674
|
texts,
|
|
@@ -2770,4 +2893,4 @@ const Dropdown = ({
|
|
|
2770
2893
|
}));
|
|
2771
2894
|
};
|
|
2772
2895
|
|
|
2773
|
-
export { Alert, Badge, Button, ButtonGroup, Card, Checkbox, Dropdown, EmailInput, Flexbox, Form, FormItems, Group, Link, List, Modal, Navbar, NumberInput, RadioButton, RadioGroup, RenderInput, Text, TextInput };
|
|
2896
|
+
export { Alert, Badge, Button, ButtonGroup, Card, Checkbox, Dropdown, EmailInput, Flexbox, Form, FormItems, Group, Link, List, Modal, Navbar, NumberInput, RadioButton, RadioGroup, RenderInput, Stepper, Text, TextInput };
|
package/index.umd.js
CHANGED
|
@@ -2532,13 +2532,29 @@
|
|
|
2532
2532
|
children,
|
|
2533
2533
|
badgeType,
|
|
2534
2534
|
isCloseable,
|
|
2535
|
-
closeText
|
|
2535
|
+
closeText,
|
|
2536
|
+
customColor,
|
|
2537
|
+
customBackgroundColor
|
|
2536
2538
|
} = _a,
|
|
2537
|
-
props = __rest(_a, ["children", "badgeType", "isCloseable", "closeText"]);
|
|
2539
|
+
props = __rest(_a, ["children", "badgeType", "isCloseable", "closeText", "customColor", "customBackgroundColor"]);
|
|
2538
2540
|
|
|
2539
2541
|
const [isClosed, setIsClosed] = React__default["default"].useState(false);
|
|
2542
|
+
const [type, setType] = React__default["default"].useState('');
|
|
2543
|
+
React__default["default"].useEffect(() => {
|
|
2544
|
+
if (badgeType) {
|
|
2545
|
+
setType(badgeType);
|
|
2546
|
+
}
|
|
2547
|
+
|
|
2548
|
+
if (!!customColor || !!customBackgroundColor) {
|
|
2549
|
+
setType('');
|
|
2550
|
+
}
|
|
2551
|
+
}, []);
|
|
2540
2552
|
return !isClosed ? jsxRuntime.jsxs("span", Object.assign({}, props, {
|
|
2541
|
-
className: `badge ${
|
|
2553
|
+
className: `badge ${type}`,
|
|
2554
|
+
style: {
|
|
2555
|
+
color: customColor,
|
|
2556
|
+
backgroundColor: customBackgroundColor
|
|
2557
|
+
}
|
|
2542
2558
|
}, {
|
|
2543
2559
|
children: [jsxRuntime.jsx("strong", {
|
|
2544
2560
|
children: children
|
|
@@ -2552,6 +2568,113 @@
|
|
|
2552
2568
|
})) : null;
|
|
2553
2569
|
}
|
|
2554
2570
|
|
|
2571
|
+
const noop = () => {};
|
|
2572
|
+
|
|
2573
|
+
const useStepper = ({
|
|
2574
|
+
min,
|
|
2575
|
+
max,
|
|
2576
|
+
value: _value = 0,
|
|
2577
|
+
step: _step = 1,
|
|
2578
|
+
id: _id = extract.randomId()
|
|
2579
|
+
}) => {
|
|
2580
|
+
const pStepper = {
|
|
2581
|
+
down: noop,
|
|
2582
|
+
setMax: noop,
|
|
2583
|
+
setMin: noop,
|
|
2584
|
+
setStep: noop,
|
|
2585
|
+
setValue: noop,
|
|
2586
|
+
up: noop
|
|
2587
|
+
};
|
|
2588
|
+
const [stepper, setStepper] = React.useState(pStepper);
|
|
2589
|
+
const [data, setData] = React.useState({
|
|
2590
|
+
id: _id,
|
|
2591
|
+
value: _value,
|
|
2592
|
+
min,
|
|
2593
|
+
max,
|
|
2594
|
+
step: _step
|
|
2595
|
+
});
|
|
2596
|
+
React.useEffect(() => {
|
|
2597
|
+
if (max !== data.max) stepper.setMax(max);
|
|
2598
|
+
}, [stepper, max]);
|
|
2599
|
+
React.useEffect(() => {
|
|
2600
|
+
if (min !== data.min) stepper.setMin(min);
|
|
2601
|
+
}, [stepper, min]);
|
|
2602
|
+
React.useEffect(() => {
|
|
2603
|
+
if (_step !== data.step) stepper.setStep(_step || 1);
|
|
2604
|
+
}, [stepper, _step]);
|
|
2605
|
+
React.useEffect(() => {
|
|
2606
|
+
if (_value !== data.value) stepper.setValue(_value || 0);
|
|
2607
|
+
}, [stepper, _value]);
|
|
2608
|
+
React.useEffect(() => {
|
|
2609
|
+
setStepper(extract.createStepper({
|
|
2610
|
+
id: _id,
|
|
2611
|
+
value: _value,
|
|
2612
|
+
min,
|
|
2613
|
+
max,
|
|
2614
|
+
step: _step
|
|
2615
|
+
}, setData));
|
|
2616
|
+
}, []);
|
|
2617
|
+
return [stepper, data];
|
|
2618
|
+
};
|
|
2619
|
+
|
|
2620
|
+
function Stepper(_a) {
|
|
2621
|
+
var {
|
|
2622
|
+
label,
|
|
2623
|
+
description,
|
|
2624
|
+
statusMessage,
|
|
2625
|
+
onChange
|
|
2626
|
+
} = _a,
|
|
2627
|
+
props = __rest(_a, ["label", "description", "statusMessage", "onChange"]);
|
|
2628
|
+
|
|
2629
|
+
const [stepper, data] = useStepper(props);
|
|
2630
|
+
React.useEffect(() => {
|
|
2631
|
+
if (onChange && data.value) onChange(data.value);
|
|
2632
|
+
}, [data.value]);
|
|
2633
|
+
|
|
2634
|
+
const onChangeEvent = e => {
|
|
2635
|
+
stepper.setValue(e.target.valueAsNumber);
|
|
2636
|
+
};
|
|
2637
|
+
|
|
2638
|
+
return jsxRuntime.jsxs("div", Object.assign({
|
|
2639
|
+
className: "form-group"
|
|
2640
|
+
}, {
|
|
2641
|
+
children: [label && jsxRuntime.jsx("label", Object.assign({
|
|
2642
|
+
htmlFor: data.id
|
|
2643
|
+
}, {
|
|
2644
|
+
children: label
|
|
2645
|
+
})), description && jsxRuntime.jsx("span", Object.assign({
|
|
2646
|
+
className: "form-info"
|
|
2647
|
+
}, {
|
|
2648
|
+
children: description
|
|
2649
|
+
})), jsxRuntime.jsxs("div", Object.assign({
|
|
2650
|
+
className: "group group-border group-stepper"
|
|
2651
|
+
}, {
|
|
2652
|
+
children: [jsxRuntime.jsx("button", Object.assign({
|
|
2653
|
+
onClick: () => stepper.down()
|
|
2654
|
+
}, {
|
|
2655
|
+
children: "-"
|
|
2656
|
+
})), jsxRuntime.jsx("input", {
|
|
2657
|
+
id: data.id,
|
|
2658
|
+
type: "number",
|
|
2659
|
+
onChange: onChangeEvent,
|
|
2660
|
+
onFocus: ({
|
|
2661
|
+
target
|
|
2662
|
+
}) => target.select(),
|
|
2663
|
+
placeholder: "0",
|
|
2664
|
+
value: data.value
|
|
2665
|
+
}), jsxRuntime.jsx("button", Object.assign({
|
|
2666
|
+
onClick: () => stepper.up()
|
|
2667
|
+
}, {
|
|
2668
|
+
children: "+"
|
|
2669
|
+
}))]
|
|
2670
|
+
})), statusMessage && jsxRuntime.jsx("span", Object.assign({
|
|
2671
|
+
className: "form-info"
|
|
2672
|
+
}, {
|
|
2673
|
+
children: statusMessage
|
|
2674
|
+
}))]
|
|
2675
|
+
}));
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2555
2678
|
const useDropdown = ({
|
|
2556
2679
|
id,
|
|
2557
2680
|
texts,
|
|
@@ -2796,6 +2919,7 @@
|
|
|
2796
2919
|
exports.RadioButton = RadioButton;
|
|
2797
2920
|
exports.RadioGroup = RadioGroup;
|
|
2798
2921
|
exports.RenderInput = RenderInput;
|
|
2922
|
+
exports.Stepper = Stepper;
|
|
2799
2923
|
exports.Text = Text;
|
|
2800
2924
|
exports.TextInput = TextInput;
|
|
2801
2925
|
|
package/lib/badge/badge.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export interface BadgeProps extends HTMLProps<HTMLSpanElement> {
|
|
|
5
5
|
badgeType?: BadgeType;
|
|
6
6
|
isCloseable?: boolean;
|
|
7
7
|
closeText?: string;
|
|
8
|
+
customColor?: string;
|
|
9
|
+
customBackgroundColor?: string;
|
|
8
10
|
}
|
|
9
|
-
export declare function Badge({ children, badgeType, isCloseable, closeText, ...props }: BadgeProps): JSX.Element | null;
|
|
11
|
+
export declare function Badge({ children, badgeType, isCloseable, closeText, customColor, customBackgroundColor, ...props }: BadgeProps): JSX.Element | null;
|
|
10
12
|
export default Badge;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebgroup/green-react",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.20",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"react": "^17 || ^18",
|
|
6
6
|
"react-dom": "^17 || ^18"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@sebgroup/chlorophyll": "^1.0.0-beta.
|
|
10
|
-
"@sebgroup/extract": "^1.0.0-beta.
|
|
9
|
+
"@sebgroup/chlorophyll": "^1.0.0-beta.19",
|
|
10
|
+
"@sebgroup/extract": "^1.0.0-beta.19"
|
|
11
11
|
},
|
|
12
12
|
"description": "React components built on top of @sebgroup/chlorophyll.",
|
|
13
13
|
"repository": {
|