@sebgroup/green-react 3.1.0 → 3.3.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/index.esm.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
- import React, { useState, useEffect, useMemo, useRef, useLayoutEffect, forwardRef, useCallback, useId } from 'react';
2
+ import React, { useState, useEffect, useRef, useLayoutEffect, useMemo, forwardRef, useCallback, useId } from 'react';
3
3
  import { randomId, validateClassName, debounce, delay, sliderColors, getSliderTrackBackground } from '@sebgroup/extract';
4
4
  import { createComponent } from '@lit/react';
5
- import { getScopedTagName, GdsDatepicker, GdsDropdown, GdsOption, GdsContextMenu, GdsMenuItem } from '@sebgroup/green-core';
5
+ import { getScopedTagName, GdsDatepicker, GdsContextMenu, GdsMenuItem, GdsMenuHeading, GdsDropdown, GdsOption } from '@sebgroup/green-core';
6
6
  import { registerTransitionalStyles } from '@sebgroup/green-core/transitional-styles';
7
7
  import classNames from 'classnames';
8
8
 
@@ -2106,7 +2106,6 @@ const Datepicker = _a => {
2106
2106
  const min = minDate ? minDate : new Date(new Date().getFullYear() - 10, 0, 1);
2107
2107
  const max = maxDate ? maxDate : new Date(new Date().getFullYear() + 10, 0, 1);
2108
2108
  const onChangeHandler = e => {
2109
- console.log('OnChange event handler');
2110
2109
  if (onChange) {
2111
2110
  onChange(e.detail.value);
2112
2111
  }
@@ -2121,7 +2120,9 @@ const Datepicker = _a => {
2121
2120
  max: max,
2122
2121
  showWeekNumbers: showWeeks,
2123
2122
  onchange: onChangeHandler,
2124
- value: value
2123
+ size: props.size,
2124
+ value: value,
2125
+ hideLabel: props.hideLabel
2125
2126
  }, props))
2126
2127
  }));
2127
2128
  };
@@ -2256,6 +2257,30 @@ $$a({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }
2256
2257
  }
2257
2258
  });
2258
2259
 
2260
+ registerTransitionalStyles();
2261
+ const ContextMenu = createComponent({
2262
+ tagName: getScopedTagName('gds-context-menu'),
2263
+ elementClass: GdsContextMenu,
2264
+ events: {
2265
+ onMenuItemClick: 'gds-menu-item-click',
2266
+ onUiStateChange: 'gds-ui-state'
2267
+ },
2268
+ react: React
2269
+ });
2270
+ const MenuItem = createComponent({
2271
+ tagName: getScopedTagName('gds-menu-item'),
2272
+ elementClass: GdsMenuItem,
2273
+ events: {
2274
+ onMenuItemClick: 'gds-menu-item-click'
2275
+ },
2276
+ react: React
2277
+ });
2278
+ const CoreMenuHeading = createComponent({
2279
+ tagName: getScopedTagName('gds-menu-heading'),
2280
+ elementClass: GdsMenuHeading,
2281
+ react: React
2282
+ });
2283
+
2259
2284
  registerTransitionalStyles();
2260
2285
  const CoreDropdown = createComponent({
2261
2286
  tagName: getScopedTagName('gds-dropdown'),
@@ -2270,23 +2295,25 @@ const CoreOption = createComponent({
2270
2295
  elementClass: GdsOption,
2271
2296
  react: React
2272
2297
  });
2273
- const Dropdown = ({
2274
- compareWith,
2275
- display: _display = 'label',
2276
- id,
2277
- informationLabel,
2278
- label,
2279
- multiSelect,
2280
- onChange,
2281
- options,
2282
- searchFilter,
2283
- searchable,
2284
- texts,
2285
- useValue: _useValue = 'value',
2286
- validator,
2287
- value,
2288
- syncPopoverWidth
2289
- }) => {
2298
+ const Dropdown = _a => {
2299
+ var {
2300
+ compareWith,
2301
+ display = 'label',
2302
+ id,
2303
+ informationLabel,
2304
+ label,
2305
+ multiSelect,
2306
+ onChange,
2307
+ options,
2308
+ searchFilter,
2309
+ searchable,
2310
+ texts,
2311
+ useValue = 'value',
2312
+ validator,
2313
+ value,
2314
+ syncPopoverWidth
2315
+ } = _a,
2316
+ props = __rest(_a, ["compareWith", "display", "id", "informationLabel", "label", "multiSelect", "onChange", "options", "searchFilter", "searchable", "texts", "useValue", "validator", "value", "syncPopoverWidth"]);
2290
2317
  const handleOnChange = e => {
2291
2318
  var _a;
2292
2319
  if ((_a = e.detail) === null || _a === void 0 ? void 0 : _a.value) {
@@ -2299,7 +2326,7 @@ const Dropdown = ({
2299
2326
  return compareFn(o1, o2);
2300
2327
  };
2301
2328
  const searchFilterAdapter = (q, o) => {
2302
- if (searchFilter) return searchFilter(q, o.value[_useValue]);else return ((q, o) => o.innerHTML.toLowerCase().includes(q.toLowerCase()))(q, o);
2329
+ if (searchFilter) return searchFilter(q, o.value[useValue]);else return ((q, o) => o.innerHTML.toLowerCase().includes(q.toLowerCase()))(q, o);
2303
2330
  };
2304
2331
  return jsx("div", Object.assign({
2305
2332
  className: "form-group"
@@ -2314,7 +2341,9 @@ const Dropdown = ({
2314
2341
  compareWith: compareWithAdapter,
2315
2342
  value: value,
2316
2343
  searchFilter: searchFilterAdapter,
2317
- syncPopoverWidth: syncPopoverWidth
2344
+ syncPopoverWidth: syncPopoverWidth,
2345
+ size: props.size,
2346
+ hideLabel: props.hideLabel
2318
2347
  }, {
2319
2348
  children: [informationLabel && jsx("span", Object.assign({
2320
2349
  slot: "sub-label"
@@ -2329,11 +2358,18 @@ const Dropdown = ({
2329
2358
  "aria-hidden": true
2330
2359
  }, {
2331
2360
  children: (texts === null || texts === void 0 ? void 0 : texts.placeholder) || 'Select'
2332
- })), options.map(option => jsx(CoreOption, Object.assign({
2333
- value: option[_useValue]
2334
- }, {
2335
- children: option[_display]
2336
- }), option[_useValue]))]
2361
+ })), options.map(option => {
2362
+ if (option.heading) {
2363
+ return jsx(CoreMenuHeading, {
2364
+ children: option[display]
2365
+ }, option.label);
2366
+ }
2367
+ return jsx(CoreOption, Object.assign({
2368
+ value: option[useValue]
2369
+ }, {
2370
+ children: option[display]
2371
+ }), option[useValue]);
2372
+ })]
2337
2373
  }))
2338
2374
  }));
2339
2375
  };
@@ -2373,7 +2409,7 @@ const IconButton = _a => {
2373
2409
  } = _a,
2374
2410
  props = __rest(_a, ["children", "onClick"]);
2375
2411
  return jsx("button", Object.assign({
2376
- className: `icon ${props.size == 'small' && 'small'}`,
2412
+ className: `icon ${props.size === 'small' && 'small'}`,
2377
2413
  onClick: onClick,
2378
2414
  "aria-controls": props['aria-controls'],
2379
2415
  "aria-expanded": props['aria-expanded'],
@@ -2417,46 +2453,48 @@ const ButtonGroup = ({
2417
2453
  }));
2418
2454
  };
2419
2455
 
2420
- const useInput = (props, onChanges, onChangeInput) => {
2421
- const id = useMemo(() => props.id || randomId(), [props.id]);
2422
- const ref = useRef(null);
2423
- const onChange = event => {
2424
- onChanges && onChanges(event);
2425
- onChangeInput && onChangeInput(event.target.value);
2426
- };
2427
- return Object.assign(Object.assign({}, props), {
2428
- id,
2429
- ref,
2430
- onChange
2431
- });
2432
- };
2433
-
2434
2456
  const Checkbox = _a => {
2435
2457
  var {
2458
+ 'aria-describedby': ariaDescribedBy,
2459
+ id = randomId(),
2436
2460
  label,
2437
- onChange,
2438
2461
  validator,
2439
- testId
2462
+ testId,
2463
+ required,
2464
+ className
2440
2465
  } = _a,
2441
- props = __rest(_a, ["label", "onChange", "validator", "testId"]);
2442
- const inputProps = useInput(props, onChange);
2443
- const labelClassNames = classNames('form-control', validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator));
2444
- const inputClassNames = classNames(validator && validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator));
2466
+ props = __rest(_a, ['aria-describedby', "id", "label", "validator", "testId", "required", "className"]);
2467
+ const [uuid] = useState(id);
2468
+ const validationClassName = validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
2469
+ const labelClassNames = classNames('form-control', {
2470
+ [validationClassName]: validator
2471
+ });
2472
+ const inputClassNames = classNames(className, {
2473
+ [validationClassName]: validator
2474
+ });
2475
+ const describedBy = classNames(ariaDescribedBy, {
2476
+ [`${uuid}_message`]: (validator === null || validator === void 0 ? void 0 : validator.message) !== undefined && validator.message.length > 0
2477
+ });
2445
2478
  return jsxs("div", Object.assign({
2446
2479
  className: "form-group"
2447
2480
  }, {
2448
2481
  children: [jsxs("label", Object.assign({
2449
- htmlFor: inputProps.id,
2482
+ htmlFor: uuid,
2450
2483
  className: labelClassNames
2451
2484
  }, {
2452
2485
  children: [label, jsx("input", Object.assign({
2486
+ "aria-describedby": describedBy || undefined,
2487
+ "aria-invalid": (validator === null || validator === void 0 ? void 0 : validator.indicator) === 'error',
2488
+ "aria-required": required,
2489
+ className: inputClassNames || undefined,
2453
2490
  type: "checkbox",
2454
- "data-testid": testId
2455
- }, inputProps, {
2456
- className: inputClassNames
2457
- })), jsx("i", {})]
2491
+ "data-testid": testId,
2492
+ id: uuid,
2493
+ required: required
2494
+ }, props)), jsx("i", {})]
2458
2495
  })), validator && jsx("span", Object.assign({
2459
- className: "form-info"
2496
+ className: "form-info",
2497
+ id: `${uuid}_message`
2460
2498
  }, {
2461
2499
  children: validator.message
2462
2500
  }))]
@@ -2676,7 +2714,8 @@ function Group({
2676
2714
  }, {
2677
2715
  children: children
2678
2716
  })), error && jsx("span", Object.assign({
2679
- className: "form-info"
2717
+ className: "form-info",
2718
+ id: id && `${id}-message`
2680
2719
  }, {
2681
2720
  children: errorMessage
2682
2721
  }))]
@@ -3881,7 +3920,8 @@ const FormItem = ({
3881
3920
  className: "gds-form-item__footer"
3882
3921
  }, {
3883
3922
  children: [validator && jsx("span", Object.assign({
3884
- className: "form-info"
3923
+ className: "form-info",
3924
+ id: `${inputId}_message`
3885
3925
  }, {
3886
3926
  children: validator.message
3887
3927
  })), rightAlignedFooterInfo && jsx("span", Object.assign({
@@ -3897,6 +3937,20 @@ const FormItem = ({
3897
3937
  }));
3898
3938
  };
3899
3939
 
3940
+ const useInput = (props, onChanges, onChangeInput) => {
3941
+ const id = useMemo(() => props.id || randomId(), [props.id]);
3942
+ const ref = useRef(null);
3943
+ const onChange = event => {
3944
+ onChanges && onChanges(event);
3945
+ onChangeInput && onChangeInput(event.target.value);
3946
+ };
3947
+ return Object.assign(Object.assign({}, props), {
3948
+ id,
3949
+ ref,
3950
+ onChange
3951
+ });
3952
+ };
3953
+
3900
3954
  const RadioButton = /*#__PURE__*/forwardRef((_a, ref) => {
3901
3955
  var {
3902
3956
  label,
@@ -3943,46 +3997,59 @@ const Input = _a => {
3943
3997
  role,
3944
3998
  validator,
3945
3999
  onChangeInput,
3946
- value = ''
4000
+ value = '',
4001
+ required
3947
4002
  } = _a,
3948
- props = __rest(_a, ['aria-describedby', "autoComplete", "children", "className", "testId", "expandableInfo", "expandableInfoButtonLabel", "formatter", "id", "label", "info", "onChange", "unit", "role", "validator", "onChangeInput", "value"]);
4003
+ props = __rest(_a, ['aria-describedby', "autoComplete", "children", "className", "testId", "expandableInfo", "expandableInfoButtonLabel", "formatter", "id", "label", "info", "onChange", "unit", "role", "validator", "onChangeInput", "value", "required"]);
3949
4004
  const [uuid] = useState(id);
3950
4005
  const [localValue, setLocalValue] = useState(value);
3951
4006
  useEffect(() => {
3952
4007
  setLocalValue(value);
3953
4008
  }, [value]);
3954
- const localOnChange = useCallback(event => {
3955
- const oldValue = event.target.value;
3956
- const newValue = formatter ? formatter(oldValue) : oldValue;
3957
- setLocalValue(newValue);
3958
- event.target.value = newValue;
3959
- if (onChange) onChange(event);
3960
- if (onChangeInput) onChangeInput(newValue);
4009
+ const handleChange = useCallback(event => {
4010
+ const {
4011
+ selectionStart,
4012
+ value
4013
+ } = event.target;
4014
+ const formattedValue = formatter ? formatter(value) : value;
4015
+ const nrAddedChars = formattedValue.length - value.length;
4016
+ const updateCaretPosition = nrAddedChars !== 0;
4017
+ const newSelectionStart = updateCaretPosition && selectionStart ? selectionStart + nrAddedChars : selectionStart;
3961
4018
  // Fixes bug: React loses caret position when you format the input value
3962
- if (!formatter || newValue.length > oldValue.length) return;
3963
- const pointer = event.target.selectionStart;
3964
- const element = event.target;
3965
4019
  window.requestAnimationFrame(() => {
3966
- element.selectionStart = pointer;
3967
- element.selectionEnd = pointer;
4020
+ event.target.selectionStart = newSelectionStart;
4021
+ event.target.selectionEnd = newSelectionStart;
3968
4022
  });
4023
+ setLocalValue(formattedValue);
4024
+ if (onChange) onChange(event);
4025
+ if (onChangeInput) onChangeInput(formattedValue);
3969
4026
  }, [formatter, setLocalValue, onChange, onChangeInput]);
3970
- const inputAriaDescribedBy = classNames(ariaDescribedBy, {
3971
- [`gds-expandable-info-${uuid}`]: expandableInfo,
3972
- [`${uuid}_info`]: info
3973
- }) || undefined;
3974
- const inputClassName = classNames(className, validator && validateClassName(validator.indicator)) || undefined;
4027
+ const showSimpleInput = !label && !info && !expandableInfo;
4028
+ const describedBy = classNames(ariaDescribedBy, {
4029
+ [`${uuid}_group-message`]: !showSimpleInput && (validator === null || validator === void 0 ? void 0 : validator.message) !== undefined && validator.message.length > 0,
4030
+ [`gds-expandable-info-${uuid}`]: !showSimpleInput && expandableInfo,
4031
+ [`${uuid}_info`]: !showSimpleInput && info
4032
+ });
4033
+ const inputClassName = classNames(className, {
4034
+ [validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)]: validator
4035
+ });
3975
4036
  const input = jsx("input", Object.assign({
3976
- "aria-describedby": inputAriaDescribedBy,
4037
+ "aria-describedby": describedBy || undefined,
4038
+ "aria-invalid": (validator === null || validator === void 0 ? void 0 : validator.indicator) === 'error',
4039
+ "aria-required": required,
3977
4040
  autoComplete: autoComplete,
3978
- className: inputClassName,
4041
+ className: inputClassName || undefined,
3979
4042
  "data-testid": dataTestId,
3980
4043
  id: uuid,
3981
- onChange: localOnChange,
4044
+ onChange: handleChange,
3982
4045
  role: role,
3983
- value: localValue
4046
+ value: localValue,
4047
+ required: required
3984
4048
  }, props));
3985
- if (!label && !info && !expandableInfo) return input;
4049
+ if (showSimpleInput) return input;
4050
+ const spanClassName = classNames('form-text', {
4051
+ 'disabled': props.disabled
4052
+ });
3986
4053
  return jsx(FormItem, Object.assign({
3987
4054
  expandableInfo: expandableInfo,
3988
4055
  expandableInfoButtonLabel: expandableInfoButtonLabel,
@@ -3997,10 +4064,11 @@ const Input = _a => {
3997
4064
  children: jsxs(Group, Object.assign({
3998
4065
  groupBorder: true,
3999
4066
  groupFocus: true,
4000
- error: validator && validator.message
4067
+ error: validator === null || validator === void 0 ? void 0 : validator.message,
4068
+ id: `${uuid}_group`
4001
4069
  }, {
4002
4070
  children: [input, unit && jsx("span", Object.assign({
4003
- className: `form-text${props.disabled ? ' disabled' : ''}`
4071
+ className: spanClassName
4004
4072
  }, {
4005
4073
  children: unit
4006
4074
  })), children]
@@ -4183,23 +4251,27 @@ const TextArea = _a => {
4183
4251
  validator,
4184
4252
  value,
4185
4253
  testId: dataTestId,
4186
- maxLength
4254
+ maxLength,
4255
+ required
4187
4256
  } = _a,
4188
- props = __rest(_a, ['aria-describedby', "autoComplete", "className", "expandableInfo", "expandableInfoButtonLabel", "id", "label", "info", "onChange", "role", "rows", "validator", "value", "testId", "maxLength"]);
4257
+ props = __rest(_a, ['aria-describedby', "autoComplete", "className", "expandableInfo", "expandableInfoButtonLabel", "id", "label", "info", "onChange", "role", "rows", "validator", "value", "testId", "maxLength", "required"]);
4189
4258
  const [uuid] = useState(id);
4190
4259
  const [localValue, setLocalValue] = useState(value);
4191
4260
  useEffect(() => {
4192
4261
  setLocalValue(value);
4193
4262
  }, [value]);
4194
- const localOnChange = useCallback(event => {
4263
+ const handleChange = useCallback(event => {
4195
4264
  setLocalValue(event.target.value);
4196
4265
  if (onChange) onChange(event);
4197
4266
  }, [setLocalValue, onChange]);
4198
- const inputAriaDescribedBy = classNames(ariaDescribedBy, {
4267
+ const describedBy = classNames(ariaDescribedBy, {
4199
4268
  [`gds-expandable-info-${uuid}`]: expandableInfo,
4200
- [`${uuid}_info`]: info
4269
+ [`${uuid}_info`]: info,
4270
+ [`${uuid}_message`]: (validator === null || validator === void 0 ? void 0 : validator.message) !== undefined && validator.message.length > 0
4271
+ });
4272
+ const inputClassName = classNames(className, {
4273
+ [validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)]: validator
4201
4274
  }) || undefined;
4202
- const inputClassName = classNames(className, validator && validateClassName(validator.indicator)) || undefined;
4203
4275
  const rightAlignedFooterInfo = maxLength ? `${(localValue === null || localValue === void 0 ? void 0 : localValue.length) || 0}/${maxLength}` : undefined;
4204
4276
  return jsx(FormItem, Object.assign({
4205
4277
  expandableInfo: expandableInfo,
@@ -4215,16 +4287,19 @@ const TextArea = _a => {
4215
4287
  className: "gds-input-wrapper"
4216
4288
  }, {
4217
4289
  children: jsx("textarea", Object.assign({
4218
- "aria-describedby": inputAriaDescribedBy,
4290
+ "aria-describedby": describedBy || undefined,
4291
+ "aria-invalid": (validator === null || validator === void 0 ? void 0 : validator.indicator) === 'error',
4292
+ "aria-required": required,
4219
4293
  autoComplete: autoComplete,
4220
- className: inputClassName,
4294
+ className: inputClassName || undefined,
4221
4295
  id: uuid,
4222
- onChange: localOnChange,
4296
+ onChange: handleChange,
4223
4297
  role: role,
4224
4298
  rows: rows,
4225
4299
  value: localValue,
4226
4300
  "data-testid": dataTestId,
4227
- maxLength: maxLength
4301
+ maxLength: maxLength,
4302
+ required: required
4228
4303
  }, props))
4229
4304
  }))
4230
4305
  }));
@@ -4532,75 +4607,56 @@ const Navbar = ({
4532
4607
  }));
4533
4608
  };
4534
4609
 
4535
- const Select = /*#__PURE__*/React.forwardRef(({
4536
- id,
4537
- className,
4538
- children,
4539
- validator,
4540
- label,
4541
- labelInformation,
4542
- defaultValue,
4543
- value,
4544
- testId,
4545
- onChange,
4546
- onSelect,
4547
- expandableInfo,
4548
- expandableInfoButtonLabel,
4549
- name
4550
- }, ref) => {
4551
- const selectId = id !== null && id !== void 0 ? id : randomId();
4552
- const validatorClassName = validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator);
4610
+ const Select = /*#__PURE__*/React.forwardRef((_a, ref) => {
4611
+ var {
4612
+ 'aria-describedby': ariaDescribedBy,
4613
+ id = randomId(),
4614
+ validator,
4615
+ label,
4616
+ info,
4617
+ testId,
4618
+ expandableInfo,
4619
+ expandableInfoButtonLabel,
4620
+ required
4621
+ } = _a,
4622
+ props = __rest(_a, ['aria-describedby', "id", "validator", "label", "info", "testId", "expandableInfo", "expandableInfoButtonLabel", "required"]);
4623
+ const [uuid] = useState(id);
4624
+ const selectClassName = classNames('gds-select', {
4625
+ [`${validateClassName(validator === null || validator === void 0 ? void 0 : validator.indicator)}`]: validator
4626
+ });
4627
+ const describedBy = classNames(ariaDescribedBy, {
4628
+ [`${uuid}_info`]: info,
4629
+ [`gds-expandable-info-${uuid}`]: expandableInfo,
4630
+ [`${uuid}_message`]: (validator === null || validator === void 0 ? void 0 : validator.message) !== undefined && validator.message.length > 0
4631
+ });
4553
4632
  return jsx(FormItem, Object.assign({
4554
4633
  label: label,
4555
- labelInformation: labelInformation,
4634
+ labelInformation: info !== null && info !== void 0 ? info : props.labelInformation,
4556
4635
  expandableInfo: expandableInfo,
4557
4636
  expandableInfoButtonLabel: expandableInfoButtonLabel,
4558
- inputId: selectId,
4637
+ inputId: uuid,
4559
4638
  validator: validator
4560
4639
  }, {
4561
4640
  children: jsxs("div", Object.assign({
4562
- className: `gds-select ${validatorClassName}`
4641
+ className: selectClassName
4563
4642
  }, {
4564
4643
  children: [jsx("select", Object.assign({
4565
- id: selectId,
4644
+ "aria-describedby": describedBy || undefined,
4645
+ "aria-invalid": (validator === null || validator === void 0 ? void 0 : validator.indicator) === 'error',
4646
+ "aria-required": required,
4647
+ id: uuid,
4566
4648
  "data-testid": testId,
4567
- className: className,
4568
- name: name,
4569
- defaultValue: defaultValue,
4570
- value: value,
4571
4649
  ref: ref,
4572
- onChange: event => {
4573
- onChange && onChange(event);
4574
- }
4575
- }, {
4576
- children: children
4577
- })), jsx(ChevronDown, {})]
4650
+ required: required
4651
+ }, props)), jsx(ChevronDown, {})]
4578
4652
  }))
4579
4653
  }));
4580
4654
  });
4581
- const Option = _a => {
4582
- var {
4583
- value,
4584
- children
4585
- } = _a,
4586
- rest = __rest(_a, ["value", "children"]);
4587
- return jsx("option", Object.assign({
4588
- value: value
4589
- }, rest, {
4590
- children: children
4591
- }));
4655
+ const Option = props => {
4656
+ return jsx("option", Object.assign({}, props));
4592
4657
  };
4593
- const OptionGroup = ({
4594
- label,
4595
- disabled,
4596
- children
4597
- }) => {
4598
- return jsx("optgroup", Object.assign({
4599
- label: label,
4600
- disabled: disabled
4601
- }, {
4602
- children: children
4603
- }));
4658
+ const OptionGroup = props => {
4659
+ return jsx("optgroup", Object.assign({}, props));
4604
4660
  };
4605
4661
 
4606
4662
  var anObject$3 = anObject$e;
@@ -5218,25 +5274,6 @@ const Modal = _a => {
5218
5274
  });
5219
5275
  };
5220
5276
 
5221
- registerTransitionalStyles();
5222
- const ContextMenu = createComponent({
5223
- tagName: getScopedTagName('gds-context-menu'),
5224
- elementClass: GdsContextMenu,
5225
- events: {
5226
- onMenuItemClick: 'gds-menu-item-click',
5227
- onUiStateChange: 'gds-ui-state'
5228
- },
5229
- react: React
5230
- });
5231
- const MenuItem = createComponent({
5232
- tagName: getScopedTagName('gds-menu-item'),
5233
- elementClass: GdsMenuItem,
5234
- events: {
5235
- onMenuItemClick: 'gds-menu-item-click'
5236
- },
5237
- react: React
5238
- });
5239
-
5240
5277
  var SortDirection;
5241
5278
  (function (SortDirection) {
5242
5279
  SortDirection["ASC"] = "ASC";
@@ -6457,4 +6494,4 @@ const Table = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef((_a, ref) =
6457
6494
  }));
6458
6495
  }));
6459
6496
 
6460
- export { Accordion, AlertRibbon as Alert, AlertRibbon, Badge, Button, ButtonGroup, Card, Checkbox, ContextMenu, CoreDatepicker, CoreDropdown, CoreOption, Datepicker, Dropdown, EmailInput, Flexbox, Form, FormItem, FormItems, Group, IconButton, InPageWizardStepCard, Input, Link, List$1 as List, MenuItem, Modal, Navbar, NumberInput, Option, OptionGroup, RadioButton, RadioGroup, Select, Slider, SortDirection, Stepper, Tab, Table, TableBody, TableCell, TableContext, TableHeader, TableHeaderCell, TableRow, Tabs, Text, TextArea, TextInput, valueList$1 as ValueList, filterArrayByColumns, onRowSelect, paginate, searchTextByColumns, sortArray, sumCols, useTableContext };
6497
+ export { Accordion, AlertRibbon as Alert, AlertRibbon, Badge, Button, ButtonGroup, Card, Checkbox, ContextMenu, CoreDatepicker, CoreDropdown, CoreMenuHeading, CoreOption, Datepicker, Dropdown, EmailInput, Flexbox, Form, FormItem, FormItems, Group, IconButton, InPageWizardStepCard, Input, Link, List$1 as List, MenuItem, Modal, Navbar, NumberInput, Option, OptionGroup, RadioButton, RadioGroup, Select, Slider, SortDirection, Stepper, Tab, Table, TableBody, TableCell, TableContext, TableHeader, TableHeaderCell, TableRow, Tabs, Text, TextArea, TextInput, valueList$1 as ValueList, filterArrayByColumns, onRowSelect, paginate, searchTextByColumns, sortArray, sumCols, useTableContext };
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@sebgroup/green-react",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
4
4
  "peerDependencies": {
5
5
  "react": "^17 || ^18",
6
6
  "react-dom": "^17 || ^18"
7
7
  },
8
8
  "dependencies": {
9
- "@sebgroup/green-core": "^1.5.0",
10
- "@sebgroup/chlorophyll": "^3.0.2",
11
- "@sebgroup/extract": "^3.0.0",
9
+ "@sebgroup/green-core": "^1.7.0",
10
+ "@sebgroup/chlorophyll": "^3.1.0",
11
+ "@sebgroup/extract": "^3.0.1",
12
12
  "@lit/react": "^1.0.2",
13
13
  "classnames": "^2.3.2"
14
14
  },
@@ -1,4 +1,4 @@
1
- import { GdsContextMenu, GdsMenuItem } from '@sebgroup/green-core';
1
+ import { GdsContextMenu, GdsMenuItem, GdsMenuHeading } from '@sebgroup/green-core';
2
2
  export declare const ContextMenu: import("@lit/react").ReactWebComponent<GdsContextMenu, {
3
3
  onMenuItemClick: string;
4
4
  onUiStateChange: string;
@@ -6,3 +6,4 @@ export declare const ContextMenu: import("@lit/react").ReactWebComponent<GdsCont
6
6
  export declare const MenuItem: import("@lit/react").ReactWebComponent<GdsMenuItem, {
7
7
  onMenuItemClick: string;
8
8
  }>;
9
+ export declare const CoreMenuHeading: import("@lit/react").ReactWebComponent<GdsMenuHeading, {}>;
@@ -10,6 +10,8 @@ export interface DatepickerOptions {
10
10
  value?: Date;
11
11
  showWeeks?: boolean;
12
12
  testId?: string;
13
+ size?: 'small' | 'medium';
14
+ hideLabel?: boolean;
13
15
  /** @deprecated Use `value` instead */
14
16
  selectedDate?: Date;
15
17
  /** @deprecated Use `value` instead */
@@ -30,6 +30,10 @@ export interface DropdownArgs {
30
30
  value?: any;
31
31
  /** Force width of the popover to match trigger */
32
32
  syncPopoverWidth?: boolean;
33
+ /** Size of the dropdown trigger */
34
+ size?: 'small' | 'medium';
35
+ /** Hide the label */
36
+ hideLabel?: boolean;
33
37
  }
34
38
  export interface DropdownTexts {
35
39
  placeholder?: string;
@@ -38,6 +42,7 @@ export interface DropdownOption {
38
42
  label?: string;
39
43
  value?: any;
40
44
  selected?: boolean;
45
+ heading?: boolean;
41
46
  [key: string]: any;
42
47
  }
43
48
  export declare const CoreDropdown: import("@lit/react").ReactWebComponent<GdsDropdown<any>, {
@@ -47,5 +52,5 @@ export declare const CoreOption: import("@lit/react").ReactWebComponent<GdsOptio
47
52
  export interface DropdownProps extends DropdownArgs {
48
53
  onChange?: OnChange;
49
54
  }
50
- export declare const Dropdown: ({ compareWith, display, id, informationLabel, label, multiSelect, onChange, options, searchFilter, searchable, texts, useValue, validator, value, syncPopoverWidth, }: DropdownProps) => import("react/jsx-runtime").JSX.Element;
55
+ export declare const Dropdown: ({ compareWith, display, id, informationLabel, label, multiSelect, onChange, options, searchFilter, searchable, texts, useValue, validator, value, syncPopoverWidth, ...props }: DropdownProps) => import("react/jsx-runtime").JSX.Element;
51
56
  export default Dropdown;
@@ -12,4 +12,4 @@ export interface CheckboxProps extends HTMLProps<HTMLInputElement> {
12
12
  /** A handler function that takes the event and can act on it */
13
13
  onChange?: FormEventHandler<HTMLInputElement>;
14
14
  }
15
- export declare const Checkbox: ({ label, onChange, validator, testId, ...props }: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const Checkbox: ({ "aria-describedby": ariaDescribedBy, id, label, validator, testId, required, className, ...props }: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
@@ -18,7 +18,7 @@ export interface InputProps extends IExpandableInformation, DetailedHTMLProps<In
18
18
  /** Function called when input value changes */
19
19
  onChangeInput?: (value: string) => string;
20
20
  }
21
- export declare const Input: ({ "aria-describedby": ariaDescribedBy, autoComplete, children, className, testId: dataTestId, expandableInfo, expandableInfoButtonLabel, formatter, id, label, info, onChange, unit, role, validator, onChangeInput, value, ...props }: InputProps) => import("react/jsx-runtime").JSX.Element;
21
+ export declare const Input: ({ "aria-describedby": ariaDescribedBy, autoComplete, children, className, testId: dataTestId, expandableInfo, expandableInfoButtonLabel, formatter, id, label, info, onChange, unit, role, validator, onChangeInput, value, required, ...props }: InputProps) => import("react/jsx-runtime").JSX.Element;
22
22
  export declare const TextInput: (props: Omit<InputProps, 'type'>) => import("react/jsx-runtime").JSX.Element;
23
23
  export declare const EmailInput: (props: Omit<InputProps, 'type'>) => import("react/jsx-runtime").JSX.Element;
24
24
  export declare const NumberInput: (props: Omit<InputProps, 'type'>) => import("react/jsx-runtime").JSX.Element;
@@ -12,4 +12,4 @@ export interface ITextAreaProps extends IExpandableInformation, DetailedHTMLProp
12
12
  /** Value of textarea */
13
13
  value?: string;
14
14
  }
15
- export declare const TextArea: ({ "aria-describedby": ariaDescribedBy, autoComplete, className, expandableInfo, expandableInfoButtonLabel, id, label, info, onChange, role, rows, validator, value, testId: dataTestId, maxLength, ...props }: ITextAreaProps) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const TextArea: ({ "aria-describedby": ariaDescribedBy, autoComplete, className, expandableInfo, expandableInfoButtonLabel, id, label, info, onChange, role, rows, validator, value, testId: dataTestId, maxLength, required, ...props }: ITextAreaProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,42 +1,25 @@
1
- import React, { ReactNode } from 'react';
2
- import { IValidator } from '@sebgroup/extract';
3
- import { SelectorAttributesProps, LabelProps } from '../../types';
4
- export interface SelectProps extends SelectorAttributesProps, LabelProps {
5
- children: ReactNode;
6
- validator?: IValidator;
7
- onChange?: (event: React.ChangeEvent<HTMLSelectElement>) => void;
8
- onSelect?: (event: React.ChangeEvent<HTMLSelectElement>) => void;
9
- defaultValue?: string | number;
10
- value?: string | number;
11
- testId?: string;
12
- expandableInfo?: string;
13
- expandableInfoButtonLabel?: string;
14
- name?: string;
15
- }
16
- interface OptionProps {
17
- children: string;
18
- value: string | number;
19
- disabled?: boolean;
20
- invalid?: boolean;
21
- autocomplete?: string;
22
- autofocus?: boolean;
23
- form?: string;
24
- name?: string;
25
- required?: boolean;
26
- size?: number;
27
- selected?: boolean;
28
- }
29
- interface OptionGroupProps {
1
+ import React from 'react';
2
+ import { IExpandableInformation, ILabelAndLabelInformation, IValidator } from '@sebgroup/extract';
3
+ export interface SelectProps extends IExpandableInformation, ILabelAndLabelInformation, React.DetailedHTMLProps<React.SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement> {
30
4
  label: string;
31
- children: React.ReactElement<OptionProps> | React.ReactElement<OptionProps>[];
32
- disabled?: boolean;
5
+ info?: string;
6
+ validator?: IValidator | undefined;
7
+ value?: string;
8
+ testId?: string;
9
+ /**
10
+ * @deprecated
11
+ * Use `info` instead
12
+ */
13
+ labelInformation?: string;
33
14
  }
34
- export declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLSelectElement>>;
35
- export declare const Option: ({ value, children, ...rest }: OptionProps) => import("react/jsx-runtime").JSX.Element;
36
- export declare const OptionGroup: ({ label, disabled, children, }: OptionGroupProps) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const Select: React.ForwardRefExoticComponent<Omit<SelectProps, "ref"> & React.RefAttributes<HTMLSelectElement>>;
16
+ declare type OptionProps = React.DetailedHTMLProps<React.OptionHTMLAttributes<HTMLOptionElement>, HTMLOptionElement>;
17
+ export declare const Option: (props: OptionProps) => import("react/jsx-runtime").JSX.Element;
18
+ declare type OptGroupProps = React.DetailedHTMLProps<React.OptgroupHTMLAttributes<HTMLOptGroupElement>, HTMLOptGroupElement>;
19
+ export declare const OptionGroup: (props: OptGroupProps) => import("react/jsx-runtime").JSX.Element;
37
20
  declare const _default: {
38
- Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLSelectElement>>;
39
- Option: ({ value, children, ...rest }: OptionProps) => import("react/jsx-runtime").JSX.Element;
40
- OptionGroup: ({ label, disabled, children, }: OptionGroupProps) => import("react/jsx-runtime").JSX.Element;
21
+ Select: React.ForwardRefExoticComponent<Omit<SelectProps, "ref"> & React.RefAttributes<HTMLSelectElement>>;
22
+ Option: (props: OptionProps) => import("react/jsx-runtime").JSX.Element;
23
+ OptionGroup: (props: OptGroupProps) => import("react/jsx-runtime").JSX.Element;
41
24
  };
42
25
  export default _default;