@digital-ai/dot-components 4.20.0 → 4.20.1

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
@@ -2956,6 +2956,7 @@ const DotButton = forwardRef(({
2956
2956
  isSubmit = false,
2957
2957
  onClick,
2958
2958
  onKeyDown,
2959
+ onMouseDown,
2959
2960
  size = 'medium',
2960
2961
  startIcon,
2961
2962
  tabIndex,
@@ -3013,6 +3014,7 @@ const DotButton = forwardRef(({
3013
3014
  fullWidth: fullWidth,
3014
3015
  onClick: event => onClick && onClick(event),
3015
3016
  onKeyDown: onKeyDown,
3017
+ onMouseDown: onMouseDown,
3016
3018
  ref: ref,
3017
3019
  role: ariaRole,
3018
3020
  size: size,
@@ -11789,6 +11791,7 @@ function DotDashboardDialog({
11789
11791
  description,
11790
11792
  name
11791
11793
  } = formValues;
11794
+ const isSubmittingRef = useRef(false);
11792
11795
  const {
11793
11796
  dashboardSearchLoading,
11794
11797
  searchDashboards
@@ -11831,6 +11834,23 @@ function DotDashboardDialog({
11831
11834
  onClose(false);
11832
11835
  };
11833
11836
  }, []);
11837
+ const validateName = useCallback(nameToValidate => __awaiter(this, void 0, void 0, function* () {
11838
+ return cancelablePromise(searchDashboards({
11839
+ name: nameToValidate
11840
+ })).then(response => {
11841
+ if (response === null || 'error' in response) {
11842
+ setNameError('Could not check existing names due to a server error.');
11843
+ return false;
11844
+ } else if (response.length > 0) {
11845
+ const matchingNames = response.filter(dashboard => dashboard.name.toLowerCase() === nameToValidate.toLowerCase() && (!editDashboard || dashboard.name !== editDashboard.name));
11846
+ if (matchingNames.length > 0) {
11847
+ setNameError(`Cannot use duplicate name '${name}'`);
11848
+ return false;
11849
+ }
11850
+ }
11851
+ return true;
11852
+ });
11853
+ }), [editDashboard, name]);
11834
11854
  const handleSubmit = useCallback(isDone => __awaiter(this, void 0, void 0, function* () {
11835
11855
  setIsLoadingSubmit(true);
11836
11856
  // If this dashboard has a parent_id set, it means we are in an in-progress state and we need to use the ID
@@ -11843,8 +11863,12 @@ function DotDashboardDialog({
11843
11863
  if (validName) {
11844
11864
  yield onSubmit(useFormValues, isDone);
11845
11865
  }
11866
+ isSubmittingRef.current = false;
11846
11867
  setIsLoadingSubmit(false);
11847
- }), [formValues, editDashboard]);
11868
+ }), [formValues, editDashboard, validateName]);
11869
+ const handleMouseDown = () => {
11870
+ isSubmittingRef.current = true;
11871
+ };
11848
11872
  const handleSubmitCreate = useCallback(() => {
11849
11873
  handleSubmit(true);
11850
11874
  }, [handleSubmit]);
@@ -11859,7 +11883,7 @@ function DotDashboardDialog({
11859
11883
  [targetName]: value
11860
11884
  }));
11861
11885
  setIsDirty(true);
11862
- }, [formValues]);
11886
+ }, []);
11863
11887
  const handleChangeCategories = useCallback((_event, options, _reason) => {
11864
11888
  const values = options.map(option => option.title);
11865
11889
  setFormValues(orig => Object.assign(Object.assign({}, orig), {
@@ -11889,24 +11913,10 @@ function DotDashboardDialog({
11889
11913
  }
11890
11914
  return availableCategoryOptions;
11891
11915
  }, [availableCategories, categories]);
11892
- const validateName = nameToValidate => __awaiter(this, void 0, void 0, function* () {
11893
- return cancelablePromise(searchDashboards({
11894
- name: nameToValidate
11895
- })).then(response => {
11896
- if (response === null || 'error' in response) {
11897
- setNameError('Could not check existing names due to a server error.');
11898
- return false;
11899
- } else if (response.length > 0) {
11900
- const matchingNames = response.filter(dashboard => dashboard.name.toLowerCase() === nameToValidate.toLowerCase() && (!editDashboard || dashboard.name !== editDashboard.name));
11901
- if (matchingNames.length > 0) {
11902
- setNameError(`Cannot use duplicate name '${name}'`);
11903
- return false;
11904
- }
11905
- }
11906
- return true;
11907
- });
11908
- });
11909
11916
  const handleNameBlur = useCallback(event => {
11917
+ if (isSubmittingRef.current) {
11918
+ return;
11919
+ }
11910
11920
  const newName = event.target.value;
11911
11921
  if (newName) {
11912
11922
  validateName(newName);
@@ -12009,6 +12019,7 @@ function DotDashboardDialog({
12009
12019
  "data-testid": "save-edit-exit-dashboard-button",
12010
12020
  disabled: dashboardSearchLoading || isLoadingSubmit || !isDirty || !validateFields(),
12011
12021
  onClick: handleSubmitEdit,
12022
+ onMouseDown: handleMouseDown,
12012
12023
  type: "primary",
12013
12024
  children: "Save"
12014
12025
  })]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digital-ai/dot-components",
3
- "version": "4.20.0",
3
+ "version": "4.20.1",
4
4
  "private": false,
5
5
  "license": "SEE LICENSE IN <LICENSE.md>",
6
6
  "contributors": [
@@ -1,4 +1,4 @@
1
- import { KeyboardEventHandler, ReactNode } from 'react';
1
+ import { KeyboardEventHandler, MouseEventHandler, ReactNode } from 'react';
2
2
  import { BaseButtonProps } from '../BaseButtonProps';
3
3
  export interface ButtonProps extends BaseButtonProps {
4
4
  /** The text for the button. Button text should be in sentence case. */
@@ -6,6 +6,7 @@ export interface ButtonProps extends BaseButtonProps {
6
6
  /** Icon placed after the children. */
7
7
  endIcon?: ReactNode;
8
8
  onKeyDown?: KeyboardEventHandler;
9
+ onMouseDown?: MouseEventHandler;
9
10
  /** Icon placed before the children. */
10
11
  startIcon?: ReactNode;
11
12
  }