@ballistix.digital/react-components 0.5.6 → 0.5.8

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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import React, { FC, ReactNode, RefObject, ReactElement, ChangeEventHandler, FocusEventHandler, HTMLInputTypeAttribute, Dispatch, SetStateAction, ElementType, ChangeEvent } from 'react';
1
+ import React, { FC, ReactNode, RefObject, MouseEvent as MouseEvent$1, ReactElement, ChangeEventHandler, FocusEventHandler, HTMLInputTypeAttribute, Dispatch, SetStateAction, ElementType, ChangeEvent } from 'react';
2
2
  import { DeepPartialType as DeepPartialType$1 } from 'types/DeepPartialType';
3
3
  import { IconName } from '@fortawesome/fontawesome-svg-core';
4
4
  import { Menu } from '@headlessui/react';
@@ -92,7 +92,7 @@ type TButtonElementProps = {
92
92
  status?: 'idle' | 'loading' | 'success' | 'error';
93
93
  isDisabled?: boolean;
94
94
  styles?: TButtonElementStyles;
95
- onClick?: () => void;
95
+ onClick?: (e?: MouseEvent$1<HTMLButtonElement>) => void;
96
96
  };
97
97
  declare const ButtonElement: FC<TButtonElementProps>;
98
98
 
package/dist/index.esm.js CHANGED
@@ -538,7 +538,9 @@ var ButtonElement = function (props) {
538
538
  return result;
539
539
  };
540
540
  var styles = handleGenerateStyle();
541
- return (jsxs("button", { type: htmlType, className: styles.container, disabled: isDisabled || status !== 'idle', onClick: onClick, ref: innerRef, children: [status === 'idle' && children, status === 'loading' && (jsxs("div", { className: styles.content, children: [jsx(IconElement, { type: "regular", accessor: "spinner", className: styles.spinner }), jsx("div", { children: children })] })), status === 'error' && (jsxs("div", { className: styles.content, children: [jsx(IconElement, { type: "regular", accessor: "circle-exclamation", className: styles.icon }), jsx("div", { children: children })] })), status === 'success' && (jsxs("div", { className: styles.content, children: [jsx(IconElement, { type: "regular", accessor: "circle-check", className: styles.icon }), jsx("div", { children: children })] }))] }));
541
+ return (jsxs("button", { type: htmlType, className: styles.container, disabled: isDisabled || status !== 'idle', onClick: function (e) {
542
+ onClick && onClick(e);
543
+ }, ref: innerRef, children: [status === 'idle' && children, status === 'loading' && (jsxs("div", { className: styles.content, children: [jsx(IconElement, { type: "regular", accessor: "spinner", className: styles.spinner }), jsx("div", { children: children })] })), status === 'error' && (jsxs("div", { className: styles.content, children: [jsx(IconElement, { type: "regular", accessor: "circle-exclamation", className: styles.icon }), jsx("div", { children: children })] })), status === 'success' && (jsxs("div", { className: styles.content, children: [jsx(IconElement, { type: "regular", accessor: "circle-check", className: styles.icon }), jsx("div", { children: children })] }))] }));
542
544
  };
543
545
 
544
546
  var base$n = {
@@ -2481,7 +2483,7 @@ var SelectMenuForm = function (props) {
2481
2483
  var styles = handleGenerateStyle();
2482
2484
  // Simulate onClear event.
2483
2485
  useEffect(function () {
2484
- if (state === null) {
2486
+ if (state === null && !isFocus) {
2485
2487
  onClear && onClear(name);
2486
2488
  }
2487
2489
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -2493,6 +2495,10 @@ var SelectMenuForm = function (props) {
2493
2495
  }
2494
2496
  // eslint-disable-next-line react-hooks/exhaustive-deps
2495
2497
  }, [isFocus]);
2498
+ // listen to value changes.
2499
+ useEffect(function () {
2500
+ setState(value);
2501
+ }, [value]);
2496
2502
  return (jsxs("div", { className: styles.container, children: [jsxs("div", { className: styles.head, children: [label && (jsx("label", { htmlFor: name, className: styles.label, children: label })), !required && !isRequired && typeof label === 'string' && (jsx("span", { className: styles.hint, children: "Optional" })), required && required({ isRequired: isRequired })] }), jsxs("div", { className: styles.container, children: [jsx(Select, { primaryColor: "primary",
2497
2503
  //
2498
2504
  placeholder: placeholder === null || placeholder === void 0 ? void 0 : placeholder.select, noOptionsMessage: (jsx("p", { className: styles.emptyState, children: (_a = placeholder === null || placeholder === void 0 ? void 0 : placeholder.emptyState) !== null && _a !== void 0 ? _a : 'No results found' })), searchInputPlaceholder: placeholder === null || placeholder === void 0 ? void 0 : placeholder.searchInput,
@@ -9563,7 +9569,7 @@ var OpeningHourItem = function (props) {
9563
9569
  };
9564
9570
  onUpdate && onUpdate(params);
9565
9571
  }
9566
- }, className: toClassName(styles$2.control.action, form.values.closed ? 'bg-primary-500' : 'bg-gray-200'), children: [jsx("span", { className: styles$2.control.sr, children: "Toggle closed" }), jsx("span", { "aria-hidden": "true", className: toClassName(styles$2.control.span, form.values.closed ? 'translate-x-5' : 'translate-x-0') })] })] }), !isCreating ? (jsx(ButtonElement, { size: "sm", type: "outline", onClick: function () { return onDelete && onDelete(form.values.id); }, children: jsx(XMarkIcon, { className: "w-4 h-4" }) })) : (jsx(ButtonElement, { size: "sm", type: "secondary", onClick: form.handleSubmit, children: jsx(PlusIcon, { className: "w-4 h-4" }) }))] }));
9572
+ }, className: toClassName(styles$2.control.action, form.values.closed ? 'bg-primary-500' : 'bg-gray-200'), children: [jsx("span", { className: styles$2.control.sr, children: "Toggle closed" }), jsx("span", { "aria-hidden": "true", className: toClassName(styles$2.control.span, form.values.closed ? 'translate-x-5' : 'translate-x-0') })] })] }), !isCreating ? (jsx(ButtonElement, { size: "sm", type: "outline", onClick: function () { return onDelete && onDelete(form.values.id); }, children: jsx(XMarkIcon, { className: "w-4 h-4" }) })) : (jsx(ButtonElement, { size: "sm", type: "secondary", onClick: function () { return form.handleSubmit(); }, children: jsx(PlusIcon, { className: "w-4 h-4" }) }))] }));
9567
9573
  };
9568
9574
 
9569
9575
  var styles$2 = {