@app-studio/web 0.8.40 → 0.8.42

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.
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import { ModalLayoutProps } from './Modal.props';
3
- export declare const ModalLayout: ({ modals }: ModalLayoutProps) => React.JSX.Element | null;
3
+ export declare const ModalLayout: ({ modals: availableModals }: ModalLayoutProps) => React.JSX.Element | null;
@@ -1,12 +1,15 @@
1
- export interface ModalState {
2
- modal: string | boolean;
3
- modalProps: any & {
1
+ export interface ModalItem {
2
+ name: string;
3
+ props: any & {
4
4
  isVisible: boolean;
5
5
  };
6
6
  overlayProps: any;
7
- show: (modal: string, modalProps?: any, overlayProps?: any) => void;
8
- hide: () => void;
7
+ }
8
+ export interface ModalState {
9
+ modals: ModalItem[];
10
+ show: (name: string, modalProps?: any, overlayProps?: any) => void;
11
+ hide: (name?: string) => void;
9
12
  }
10
13
  export declare const useModalStore: any;
11
- export declare const showModal: (modal: string, modalProps?: any, overlayProps?: any) => void;
12
- export declare const hideModal: () => void;
14
+ export declare const showModal: (name: string, modalProps?: any, overlayProps?: any) => void;
15
+ export declare const hideModal: (name?: string | undefined) => void;
@@ -2403,7 +2403,7 @@ var ButtonView = _ref => {
2403
2403
  ariaLabel,
2404
2404
  // Initializes default values for the ButtonProps object; useful for defining states like isAuto, isFilled, etc.
2405
2405
  externalHref,
2406
- isAuto,
2406
+ isAuto = false,
2407
2407
  // Determines if button should be active based on isDisabled and isLoading properties.
2408
2408
  isFilled = false,
2409
2409
  // Prepares default properties for the native button element based on isActive state.
@@ -2481,7 +2481,8 @@ var ButtonView = _ref => {
2481
2481
  var buttonSizeStyles = ButtonSizes[size];
2482
2482
  var buttonVariant = ButtonVariants[variant];
2483
2483
  var scaleWidth = {
2484
- minWidth: isAuto ? 'fit-content' : isFilled ? '100%' : buttonSizeStyles.width
2484
+ width: isAuto === true ? 'fit-content' : isFilled ? '100%' : buttonSizeStyles.width,
2485
+ minWidth: isAuto === true ? 'fit-content' : isFilled ? '100%' : buttonSizeStyles.width
2485
2486
  };
2486
2487
  var changePadding = isIconRounded ? IconSizes$1[size] : ButtonSizes[size];
2487
2488
  var content = /*#__PURE__*/React__default.createElement(Horizontal, {
@@ -6629,46 +6630,51 @@ var MessageLayout = _ref => {
6629
6630
  };
6630
6631
 
6631
6632
  var useModalStore = /*#__PURE__*/zustand.create(set => ({
6632
- modal: false,
6633
- modalProps: {
6634
- isVisible: false
6635
- },
6636
- overlayProps: {},
6637
- show: function show(modal, modalProps, overlayProps) {
6633
+ modals: [],
6634
+ show: function show(name, modalProps, overlayProps) {
6638
6635
  if (modalProps === void 0) {
6639
6636
  modalProps = {};
6640
6637
  }
6641
6638
  if (overlayProps === void 0) {
6642
6639
  overlayProps = {};
6643
6640
  }
6644
- if (modal) {
6645
- modalProps.isVisible = true;
6646
- }
6647
- set(state => Object.assign({}, state, {
6648
- modal,
6649
- modalProps,
6650
- overlayProps
6641
+ set(state => ({
6642
+ modals: [...state.modals, {
6643
+ name,
6644
+ props: Object.assign({}, modalProps, {
6645
+ isVisible: true
6646
+ }),
6647
+ overlayProps
6648
+ }]
6651
6649
  }));
6652
6650
  },
6653
- hide: () => {
6654
- set(state => Object.assign({}, state, {
6655
- modalProps: Object.assign({}, state.modalProps, {
6656
- isVisible: false
6657
- })
6658
- }));
6651
+ hide: name => {
6652
+ set(state => {
6653
+ if (!name) {
6654
+ // Hide all modals
6655
+ return {
6656
+ modals: []
6657
+ };
6658
+ }
6659
+ // Hide specific modal by name
6660
+ return {
6661
+ modals: state.modals.filter(modal => modal.name !== name)
6662
+ };
6663
+ });
6659
6664
  }
6660
6665
  }));
6661
- var showModal = function showModal(modal, modalProps, overlayProps) {
6666
+ var showModal = function showModal(name, modalProps, overlayProps) {
6662
6667
  if (modalProps === void 0) {
6663
6668
  modalProps = {};
6664
6669
  }
6665
6670
  if (overlayProps === void 0) {
6666
6671
  overlayProps = {};
6667
6672
  }
6668
- useModalStore.getState().show(modal, modalProps, overlayProps);
6673
+ useModalStore.getState().show(name, modalProps, overlayProps);
6669
6674
  };
6670
- var hideModal = () => {
6671
- useModalStore.getState().hide();
6675
+ var hideModal = name => {
6676
+ console.log('hideModal', name);
6677
+ useModalStore.getState().hide(typeof name === 'string' ? name : undefined);
6672
6678
  };
6673
6679
 
6674
6680
  var ContainerShapes = {
@@ -6838,33 +6844,29 @@ var ModalFooter = _ref5 => {
6838
6844
 
6839
6845
  var ModalLayout = _ref => {
6840
6846
  var {
6841
- modals
6847
+ modals: availableModals
6842
6848
  } = _ref;
6843
- var modalStore = useModalStore(_ref2 => {
6844
- var {
6845
- modal,
6846
- modalProps,
6847
- overlayProps
6848
- } = _ref2;
6849
- return {
6850
- modal,
6851
- modalProps,
6852
- overlayProps
6853
- };
6854
- });
6855
- if (typeof modalStore.modal === 'boolean') {
6856
- return null;
6857
- }
6858
- var Modal = modals[modalStore.modal];
6859
- if (!Modal) {
6860
- console.error(modalStore.modal + " modal doesn't exist");
6849
+ var activeModals = useModalStore(state => state.modals);
6850
+ if (activeModals.length === 0) {
6861
6851
  return null;
6862
6852
  }
6863
- return /*#__PURE__*/React__default.createElement(React.Fragment, null, /*#__PURE__*/React__default.createElement(ModalOverlay, Object.assign({
6864
- isOpen: modalStore.modalProps.isVisible,
6865
- onClose: hideModal,
6866
- blur: 10
6867
- }, modalStore.overlayProps), Modal !== undefined && /*#__PURE__*/React__default.createElement(Modal, Object.assign({}, modalStore.modalProps))));
6853
+ return /*#__PURE__*/React__default.createElement(React.Fragment, null, activeModals.map((modal, index) => {
6854
+ var ModalComponent = availableModals[modal.name];
6855
+ if (!ModalComponent) {
6856
+ console.error(modal.name + " modal doesn't exist");
6857
+ return null;
6858
+ }
6859
+ return /*#__PURE__*/React__default.createElement(ModalOverlay, Object.assign({
6860
+ key: index,
6861
+ isOpen: modal.props.isVisible,
6862
+ onClose: () => hideModal(modal.name),
6863
+ blur: 5
6864
+ }, modal.overlayProps, {
6865
+ style: {
6866
+ zIndex: 1000 + index
6867
+ }
6868
+ }), /*#__PURE__*/React__default.createElement(ModalComponent, Object.assign({}, modal.props)));
6869
+ }));
6868
6870
  };
6869
6871
 
6870
6872
  /**