@sebgroup/green-react 2.6.0 → 2.6.2
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.esm.js +88 -92
- package/package.json +3 -2
- package/src/index.d.ts +1 -0
- package/src/lib/stepper/stepper.d.ts +2 -3
- package/src/lib/stepper/hook.d.ts +0 -3
package/index.esm.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import React, { useState, useEffect, useRef, useMemo, useLayoutEffect, forwardRef, useCallback } from 'react';
|
|
3
|
-
import { randomId, createDatepicker, months, years, validateClassName, debounce, delay, sliderColors, getSliderTrackBackground
|
|
4
|
-
import {
|
|
3
|
+
import { randomId, createDatepicker, months, years, validateClassName, debounce, delay, sliderColors, getSliderTrackBackground } from '@sebgroup/extract';
|
|
4
|
+
import { createComponent } from '@lit/react';
|
|
5
|
+
import { getScopedTagName, GdsDropdown, GdsOption, GdsContextMenu, GdsMenuItem } from '@sebgroup/green-core';
|
|
5
6
|
import { registerTransitionalStyles } from '@sebgroup/green-core/transitional-styles';
|
|
6
7
|
import classNames from 'classnames';
|
|
7
8
|
|
|
@@ -774,9 +775,9 @@ var iterators = {};
|
|
|
774
775
|
var global$c = global$k;
|
|
775
776
|
var isCallable$f = isCallable$l;
|
|
776
777
|
|
|
777
|
-
var WeakMap$
|
|
778
|
+
var WeakMap$1 = global$c.WeakMap;
|
|
778
779
|
|
|
779
|
-
var weakMapBasicDetection = isCallable$f(WeakMap$
|
|
780
|
+
var weakMapBasicDetection = isCallable$f(WeakMap$1) && /native code/.test(String(WeakMap$1));
|
|
780
781
|
|
|
781
782
|
var createPropertyDescriptor$3 = function (bitmap, value) {
|
|
782
783
|
return {
|
|
@@ -809,7 +810,7 @@ var hiddenKeys$1 = hiddenKeys$4;
|
|
|
809
810
|
|
|
810
811
|
var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
|
|
811
812
|
var TypeError$2 = global$b.TypeError;
|
|
812
|
-
var WeakMap
|
|
813
|
+
var WeakMap = global$b.WeakMap;
|
|
813
814
|
var set$1, get, has;
|
|
814
815
|
|
|
815
816
|
var enforce = function (it) {
|
|
@@ -826,7 +827,7 @@ var getterFor = function (TYPE) {
|
|
|
826
827
|
};
|
|
827
828
|
|
|
828
829
|
if (NATIVE_WEAK_MAP || shared.state) {
|
|
829
|
-
var store$1 = shared.state || (shared.state = new WeakMap
|
|
830
|
+
var store$1 = shared.state || (shared.state = new WeakMap());
|
|
830
831
|
/* eslint-disable no-self-assign -- prototype methods protection */
|
|
831
832
|
store$1.get = store$1.get;
|
|
832
833
|
store$1.has = store$1.has;
|
|
@@ -2226,15 +2227,8 @@ $$8({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }
|
|
|
2226
2227
|
}
|
|
2227
2228
|
});
|
|
2228
2229
|
|
|
2229
|
-
/**
|
|
2230
|
-
* @license
|
|
2231
|
-
* Copyright 2018 Google LLC
|
|
2232
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
2233
|
-
*/
|
|
2234
|
-
const e=new Set(["children","localName","ref","style","className"]),n=new WeakMap,t=(e,t,l,o,a)=>{const s=a?.[t];void 0===s||l===o?(e[t]=l,null==l&&t in HTMLElement.prototype&&e.removeAttribute(t)):((e,t,l)=>{let o=n.get(e);void 0===o&&n.set(e,o=new Map);let a=o.get(t);void 0!==l?void 0===a?(o.set(t,a={handleEvent:l}),e.addEventListener(t,a)):a.handleEvent=l:void 0!==a&&(o.delete(t),e.removeEventListener(t,a));})(e,s,l);},l=({react:n,tagName:l,elementClass:o,events:a,displayName:s})=>{const c=new Set(Object.keys(a??{})),i=n.forwardRef(((s,i)=>{const r=n.useRef(null),d=n.useRef(null),f={},u={};for(const[n,t]of Object.entries(s))e.has(n)?f["className"===n?"class":n]=t:c.has(n)||n in o.prototype?u[n]=t:f[n]=t;return n.useLayoutEffect((()=>{if(null!==d.current){for(const e in u)t(d.current,e,s[e],r.current?r.current[e]:void 0,a);r.current=s;}})),n.useLayoutEffect((()=>{d.current?.removeAttribute("defer-hydration");}),[]),f.suppressHydrationWarning=!0,n.createElement(l,{...f,ref:n.useCallback((e=>{d.current=e,"function"==typeof i?i(e):null!==i&&(i.current=e);}),[i])})}));return i.displayName=s??o.name,i};
|
|
2235
|
-
|
|
2236
2230
|
registerTransitionalStyles();
|
|
2237
|
-
const CoreDropdown =
|
|
2231
|
+
const CoreDropdown = createComponent({
|
|
2238
2232
|
tagName: getScopedTagName('gds-dropdown'),
|
|
2239
2233
|
elementClass: GdsDropdown,
|
|
2240
2234
|
events: {
|
|
@@ -2242,7 +2236,7 @@ const CoreDropdown = l({
|
|
|
2242
2236
|
},
|
|
2243
2237
|
react: React
|
|
2244
2238
|
});
|
|
2245
|
-
const CoreOption =
|
|
2239
|
+
const CoreOption = createComponent({
|
|
2246
2240
|
tagName: getScopedTagName('gds-option'),
|
|
2247
2241
|
elementClass: GdsOption,
|
|
2248
2242
|
react: React
|
|
@@ -2855,17 +2849,17 @@ var classof$1 = classof$4;
|
|
|
2855
2849
|
var getBuiltIn$2 = getBuiltIn$7;
|
|
2856
2850
|
var inspectSource$1 = inspectSource$3;
|
|
2857
2851
|
|
|
2858
|
-
var noop
|
|
2852
|
+
var noop = function () { /* empty */ };
|
|
2859
2853
|
var empty = [];
|
|
2860
2854
|
var construct = getBuiltIn$2('Reflect', 'construct');
|
|
2861
2855
|
var constructorRegExp = /^\s*(?:class|function)\b/;
|
|
2862
2856
|
var exec$1 = uncurryThis$6(constructorRegExp.exec);
|
|
2863
|
-
var INCORRECT_TO_STRING = !constructorRegExp.test(noop
|
|
2857
|
+
var INCORRECT_TO_STRING = !constructorRegExp.test(noop);
|
|
2864
2858
|
|
|
2865
2859
|
var isConstructorModern = function isConstructor(argument) {
|
|
2866
2860
|
if (!isCallable$5(argument)) return false;
|
|
2867
2861
|
try {
|
|
2868
|
-
construct(noop
|
|
2862
|
+
construct(noop, empty, argument);
|
|
2869
2863
|
return true;
|
|
2870
2864
|
} catch (error) {
|
|
2871
2865
|
return false;
|
|
@@ -4484,7 +4478,9 @@ const Link = _a => {
|
|
|
4484
4478
|
role
|
|
4485
4479
|
} = _a,
|
|
4486
4480
|
otherProps = __rest(_a, ["button", "children", "className", "role"]);
|
|
4487
|
-
const buttonClassName = classNames(className,
|
|
4481
|
+
const buttonClassName = classNames(className, {
|
|
4482
|
+
"button": button
|
|
4483
|
+
}, button);
|
|
4488
4484
|
return jsx("a", Object.assign({
|
|
4489
4485
|
className: buttonClassName,
|
|
4490
4486
|
role: button ? 'button' : role
|
|
@@ -4927,93 +4923,74 @@ function Slider({
|
|
|
4927
4923
|
});
|
|
4928
4924
|
}
|
|
4929
4925
|
|
|
4930
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
4931
|
-
const noop = () => {};
|
|
4932
|
-
const useStepper = ({
|
|
4933
|
-
min,
|
|
4934
|
-
max,
|
|
4935
|
-
value: _value = 0,
|
|
4936
|
-
step: _step = 1,
|
|
4937
|
-
id: _id = randomId(),
|
|
4938
|
-
onChange
|
|
4939
|
-
}) => {
|
|
4940
|
-
const pStepper = {
|
|
4941
|
-
down: noop,
|
|
4942
|
-
setMax: noop,
|
|
4943
|
-
setMin: noop,
|
|
4944
|
-
setStep: noop,
|
|
4945
|
-
setValue: noop,
|
|
4946
|
-
up: noop
|
|
4947
|
-
};
|
|
4948
|
-
const [stepper, setStepper] = useState(pStepper);
|
|
4949
|
-
const [data, setData] = useState({
|
|
4950
|
-
id: _id,
|
|
4951
|
-
value: _value,
|
|
4952
|
-
min,
|
|
4953
|
-
max,
|
|
4954
|
-
step: _step
|
|
4955
|
-
});
|
|
4956
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4957
|
-
useEffect(() => {
|
|
4958
|
-
if (max !== data.max) stepper.setMax(max);
|
|
4959
|
-
}, [stepper, max]);
|
|
4960
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4961
|
-
useEffect(() => {
|
|
4962
|
-
if (min !== data.min) stepper.setMin(min);
|
|
4963
|
-
}, [stepper, min]);
|
|
4964
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4965
|
-
useEffect(() => {
|
|
4966
|
-
if (_step !== data.step) stepper.setStep(_step || 1);
|
|
4967
|
-
}, [stepper, _step]);
|
|
4968
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4969
|
-
useEffect(() => {
|
|
4970
|
-
if (_value !== data.value) stepper.setValue(_value || 0, false);
|
|
4971
|
-
}, [stepper, _value]);
|
|
4972
|
-
useEffect(() => {
|
|
4973
|
-
setStepper(createStepper({
|
|
4974
|
-
id: _id,
|
|
4975
|
-
value: _value,
|
|
4976
|
-
min,
|
|
4977
|
-
max,
|
|
4978
|
-
step: _step,
|
|
4979
|
-
onChange
|
|
4980
|
-
}, setData));
|
|
4981
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4982
|
-
}, []);
|
|
4983
|
-
return [stepper, data];
|
|
4984
|
-
};
|
|
4985
|
-
|
|
4986
4926
|
// TODO: Should be named "Numeric input" instead of stepper?
|
|
4987
|
-
function Stepper(
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4927
|
+
function Stepper({
|
|
4928
|
+
id,
|
|
4929
|
+
label,
|
|
4930
|
+
description,
|
|
4931
|
+
statusMessage,
|
|
4932
|
+
validator,
|
|
4933
|
+
value = 0,
|
|
4934
|
+
onChange = () => undefined,
|
|
4935
|
+
min = Number.MIN_SAFE_INTEGER,
|
|
4936
|
+
max = Number.MAX_SAFE_INTEGER,
|
|
4937
|
+
step = 1
|
|
4938
|
+
}) {
|
|
4939
|
+
const [localValue, setLocalValue] = useState(value);
|
|
4940
|
+
const clamp = v => Math.max(min, Math.min(v, max));
|
|
4941
|
+
const onChangeEvent = useCallback(e => {
|
|
4942
|
+
if (isNaN(e.target.valueAsNumber)) return;
|
|
4943
|
+
const value = clamp(e.target.valueAsNumber);
|
|
4944
|
+
setLocalValue(value);
|
|
4945
|
+
onChange(value);
|
|
4946
|
+
}, [onChange]);
|
|
4947
|
+
useEffect(() => {
|
|
4948
|
+
setLocalValue(value);
|
|
4949
|
+
}, [value]);
|
|
4950
|
+
const down = () => {
|
|
4951
|
+
if (localValue > min) {
|
|
4952
|
+
const newValue = clamp(localValue - step);
|
|
4953
|
+
setLocalValue(newValue);
|
|
4954
|
+
onChange(newValue);
|
|
4955
|
+
}
|
|
4956
|
+
};
|
|
4957
|
+
const up = () => {
|
|
4958
|
+
if (localValue < max) {
|
|
4959
|
+
const newValue = clamp(localValue + step);
|
|
4960
|
+
setLocalValue(newValue);
|
|
4961
|
+
onChange(newValue);
|
|
4962
|
+
}
|
|
4963
|
+
};
|
|
4964
|
+
const handleKeyDown = e => {
|
|
4965
|
+
if (e.key === 'ArrowUp') {
|
|
4966
|
+
e.preventDefault();
|
|
4967
|
+
up();
|
|
4968
|
+
} else if (e.key === 'ArrowDown') {
|
|
4969
|
+
e.preventDefault();
|
|
4970
|
+
down();
|
|
4971
|
+
}
|
|
4998
4972
|
};
|
|
4999
4973
|
const PrimitiveStepper = jsxs("div", Object.assign({
|
|
5000
4974
|
className: `group group-border group-stepper ${validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)}`
|
|
5001
4975
|
}, {
|
|
5002
4976
|
children: [jsx("button", Object.assign({
|
|
5003
|
-
|
|
4977
|
+
type: "button",
|
|
4978
|
+
onClick: down
|
|
5004
4979
|
}, {
|
|
5005
4980
|
children: "-"
|
|
5006
4981
|
})), jsx("input", {
|
|
5007
|
-
id:
|
|
4982
|
+
id: id,
|
|
5008
4983
|
type: "number",
|
|
5009
4984
|
onChange: onChangeEvent,
|
|
5010
4985
|
onFocus: ({
|
|
5011
4986
|
target
|
|
5012
4987
|
}) => target.select(),
|
|
4988
|
+
onKeyDown: handleKeyDown,
|
|
5013
4989
|
placeholder: "0",
|
|
5014
|
-
value:
|
|
4990
|
+
value: localValue
|
|
5015
4991
|
}), jsx("button", Object.assign({
|
|
5016
|
-
|
|
4992
|
+
type: "button",
|
|
4993
|
+
onClick: up
|
|
5017
4994
|
}, {
|
|
5018
4995
|
children: "+"
|
|
5019
4996
|
}))]
|
|
@@ -5023,7 +5000,7 @@ function Stepper(_a) {
|
|
|
5023
5000
|
className: "form-group"
|
|
5024
5001
|
}, {
|
|
5025
5002
|
children: [label && jsx("label", Object.assign({
|
|
5026
|
-
htmlFor:
|
|
5003
|
+
htmlFor: id
|
|
5027
5004
|
}, {
|
|
5028
5005
|
children: label
|
|
5029
5006
|
})), description && jsx("span", Object.assign({
|
|
@@ -5312,4 +5289,23 @@ const Modal = _a => {
|
|
|
5312
5289
|
});
|
|
5313
5290
|
};
|
|
5314
5291
|
|
|
5315
|
-
|
|
5292
|
+
registerTransitionalStyles();
|
|
5293
|
+
const ContextMenu = createComponent({
|
|
5294
|
+
tagName: getScopedTagName('gds-context-menu'),
|
|
5295
|
+
elementClass: GdsContextMenu,
|
|
5296
|
+
events: {
|
|
5297
|
+
onMenuItemClick: 'gds-menu-item-click',
|
|
5298
|
+
onUiStateChange: 'gds-ui-state'
|
|
5299
|
+
},
|
|
5300
|
+
react: React
|
|
5301
|
+
});
|
|
5302
|
+
const MenuItem = createComponent({
|
|
5303
|
+
tagName: getScopedTagName('gds-menu-item'),
|
|
5304
|
+
elementClass: GdsMenuItem,
|
|
5305
|
+
events: {
|
|
5306
|
+
onMenuItemClick: 'gds-menu-item-click'
|
|
5307
|
+
},
|
|
5308
|
+
react: React
|
|
5309
|
+
});
|
|
5310
|
+
|
|
5311
|
+
export { Accordion, AlertRibbon as Alert, AlertRibbon, Badge, Button, ButtonGroup, Card, Checkbox, ContextMenu, CoreDropdown, CoreOption, Datepicker, Dropdown, EmailInput, Flexbox, Form, FormItem, FormItems, Group, InPageWizardStepCard, Input, Link, List$1 as List, MenuItem, Modal, Navbar, NumberInput, Option, OptionGroup, RadioButton, RadioGroup, Select, Slider, Stepper, Tab, Tabs, Text, TextArea, TextInput, valueList$1 as ValueList };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebgroup/green-react",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"react": "^17 || ^18",
|
|
6
6
|
"react-dom": "^17 || ^18"
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@sebgroup/green-core": "^1.2.4",
|
|
10
10
|
"@sebgroup/chlorophyll": "^2.3.0",
|
|
11
|
-
"@sebgroup/extract": "^2.1.
|
|
11
|
+
"@sebgroup/extract": "^2.1.2",
|
|
12
|
+
"@lit/react": "^1.0.2",
|
|
12
13
|
"classnames": "^2.3.2"
|
|
13
14
|
},
|
|
14
15
|
"description": "React components built on top of @sebgroup/chlorophyll.",
|
package/src/index.d.ts
CHANGED
|
@@ -16,5 +16,6 @@ export * from './lib/slider';
|
|
|
16
16
|
export * from './lib/stepper/stepper';
|
|
17
17
|
export * from './lib/tabs/tabs';
|
|
18
18
|
export * from './lib/modal/modal';
|
|
19
|
+
export * from './lib/context-menu/context-menu';
|
|
19
20
|
export * from './types';
|
|
20
21
|
export { AlertRibbon as Alert } from './lib/alert-ribbon/alert-ribbon';
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { StepperArgs } from '
|
|
2
|
-
import { IValidator } from "@sebgroup/extract";
|
|
1
|
+
import { IValidator, StepperArgs } from '@sebgroup/extract';
|
|
3
2
|
export interface StepperProps extends StepperArgs {
|
|
4
3
|
label?: string;
|
|
5
4
|
description?: string;
|
|
6
5
|
statusMessage?: string;
|
|
7
6
|
validator?: IValidator;
|
|
8
7
|
}
|
|
9
|
-
export declare function Stepper({ label, description, statusMessage, validator,
|
|
8
|
+
export declare function Stepper({ id, label, description, statusMessage, validator, value, onChange, min, max, step, }: StepperProps): import("react/jsx-runtime").JSX.Element;
|