@sebgroup/green-react 2.6.1 → 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 +85 -91
- 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;
|
|
@@ -4929,93 +4923,74 @@ function Slider({
|
|
|
4929
4923
|
});
|
|
4930
4924
|
}
|
|
4931
4925
|
|
|
4932
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
4933
|
-
const noop = () => {};
|
|
4934
|
-
const useStepper = ({
|
|
4935
|
-
min,
|
|
4936
|
-
max,
|
|
4937
|
-
value: _value = 0,
|
|
4938
|
-
step: _step = 1,
|
|
4939
|
-
id: _id = randomId(),
|
|
4940
|
-
onChange
|
|
4941
|
-
}) => {
|
|
4942
|
-
const pStepper = {
|
|
4943
|
-
down: noop,
|
|
4944
|
-
setMax: noop,
|
|
4945
|
-
setMin: noop,
|
|
4946
|
-
setStep: noop,
|
|
4947
|
-
setValue: noop,
|
|
4948
|
-
up: noop
|
|
4949
|
-
};
|
|
4950
|
-
const [stepper, setStepper] = useState(pStepper);
|
|
4951
|
-
const [data, setData] = useState({
|
|
4952
|
-
id: _id,
|
|
4953
|
-
value: _value,
|
|
4954
|
-
min,
|
|
4955
|
-
max,
|
|
4956
|
-
step: _step
|
|
4957
|
-
});
|
|
4958
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4959
|
-
useEffect(() => {
|
|
4960
|
-
if (max !== data.max) stepper.setMax(max);
|
|
4961
|
-
}, [stepper, max]);
|
|
4962
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4963
|
-
useEffect(() => {
|
|
4964
|
-
if (min !== data.min) stepper.setMin(min);
|
|
4965
|
-
}, [stepper, min]);
|
|
4966
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4967
|
-
useEffect(() => {
|
|
4968
|
-
if (_step !== data.step) stepper.setStep(_step || 1);
|
|
4969
|
-
}, [stepper, _step]);
|
|
4970
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4971
|
-
useEffect(() => {
|
|
4972
|
-
if (_value !== data.value) stepper.setValue(_value || 0, false);
|
|
4973
|
-
}, [stepper, _value]);
|
|
4974
|
-
useEffect(() => {
|
|
4975
|
-
setStepper(createStepper({
|
|
4976
|
-
id: _id,
|
|
4977
|
-
value: _value,
|
|
4978
|
-
min,
|
|
4979
|
-
max,
|
|
4980
|
-
step: _step,
|
|
4981
|
-
onChange
|
|
4982
|
-
}, setData));
|
|
4983
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4984
|
-
}, []);
|
|
4985
|
-
return [stepper, data];
|
|
4986
|
-
};
|
|
4987
|
-
|
|
4988
4926
|
// TODO: Should be named "Numeric input" instead of stepper?
|
|
4989
|
-
function Stepper(
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
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
|
+
}
|
|
5000
4972
|
};
|
|
5001
4973
|
const PrimitiveStepper = jsxs("div", Object.assign({
|
|
5002
4974
|
className: `group group-border group-stepper ${validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)}`
|
|
5003
4975
|
}, {
|
|
5004
4976
|
children: [jsx("button", Object.assign({
|
|
5005
|
-
|
|
4977
|
+
type: "button",
|
|
4978
|
+
onClick: down
|
|
5006
4979
|
}, {
|
|
5007
4980
|
children: "-"
|
|
5008
4981
|
})), jsx("input", {
|
|
5009
|
-
id:
|
|
4982
|
+
id: id,
|
|
5010
4983
|
type: "number",
|
|
5011
4984
|
onChange: onChangeEvent,
|
|
5012
4985
|
onFocus: ({
|
|
5013
4986
|
target
|
|
5014
4987
|
}) => target.select(),
|
|
4988
|
+
onKeyDown: handleKeyDown,
|
|
5015
4989
|
placeholder: "0",
|
|
5016
|
-
value:
|
|
4990
|
+
value: localValue
|
|
5017
4991
|
}), jsx("button", Object.assign({
|
|
5018
|
-
|
|
4992
|
+
type: "button",
|
|
4993
|
+
onClick: up
|
|
5019
4994
|
}, {
|
|
5020
4995
|
children: "+"
|
|
5021
4996
|
}))]
|
|
@@ -5025,7 +5000,7 @@ function Stepper(_a) {
|
|
|
5025
5000
|
className: "form-group"
|
|
5026
5001
|
}, {
|
|
5027
5002
|
children: [label && jsx("label", Object.assign({
|
|
5028
|
-
htmlFor:
|
|
5003
|
+
htmlFor: id
|
|
5029
5004
|
}, {
|
|
5030
5005
|
children: label
|
|
5031
5006
|
})), description && jsx("span", Object.assign({
|
|
@@ -5314,4 +5289,23 @@ const Modal = _a => {
|
|
|
5314
5289
|
});
|
|
5315
5290
|
};
|
|
5316
5291
|
|
|
5317
|
-
|
|
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;
|