@qoretechnologies/reqore 0.40.6 → 0.40.7

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.
@@ -30,8 +30,15 @@ export interface IReqoreNotifications {
30
30
  options?: IReqoreOptions;
31
31
  }
32
32
 
33
+ export interface IReqoreModal {
34
+ modal: IReqoreModalFromProps | TReqoreCustomModal;
35
+ options?: {
36
+ closable?: boolean;
37
+ };
38
+ }
39
+
33
40
  export interface IReqoreModals {
34
- [id: string]: IReqoreModalFromProps | TReqoreCustomModal;
41
+ [id: string]: IReqoreModal;
35
42
  }
36
43
 
37
44
  export interface IReqoreModalFromProps extends IReqoreModalProps {}
@@ -86,13 +93,22 @@ const ReqoreProvider: React.FC<IReqoreNotifications> = ({ children, options = {}
86
93
  };
87
94
 
88
95
  const addModal = useCallback(
89
- (modal: IReqoreModalFromProps | TReqoreCustomModal, id?: string): string => {
96
+ (
97
+ modal: IReqoreModalFromProps | TReqoreCustomModal,
98
+ id?: string,
99
+ options?: IReqoreModal['options']
100
+ ): string => {
90
101
  const _id = id || shortid.generate();
91
102
 
92
103
  setModals((cur) => {
93
104
  return {
94
105
  ...cur,
95
- [_id]: modal,
106
+ [_id]: {
107
+ modal,
108
+ options: {
109
+ closable: options?.closable ?? true,
110
+ },
111
+ },
96
112
  };
97
113
  });
98
114
 
@@ -233,16 +249,18 @@ const ReqoreProvider: React.FC<IReqoreNotifications> = ({ children, options = {}
233
249
  </ReqoreTextEffect>
234
250
  </ReqoreModal>
235
251
  )}
236
- {map(modals, (modal, key) =>
252
+ {map(modals, ({ modal, options }, key) =>
237
253
  React.isValidElement(modal) ? (
238
254
  createPortal(
239
255
  React.cloneElement(modal, {
240
256
  key,
241
257
  isOpen: true,
242
- onClose: () => {
243
- removeModal(key);
244
- modal.props.onClose?.();
245
- },
258
+ onClose: options?.closable
259
+ ? () => {
260
+ removeModal(key);
261
+ modal.props.onClose?.();
262
+ }
263
+ : undefined,
246
264
  }),
247
265
  document.querySelector('#reqore-portal')!
248
266
  )
@@ -251,10 +269,14 @@ const ReqoreProvider: React.FC<IReqoreNotifications> = ({ children, options = {}
251
269
  {...modal}
252
270
  key={key}
253
271
  isOpen
254
- onClose={() => {
255
- removeModal(key);
256
- modal.onClose?.();
257
- }}
272
+ onClose={
273
+ options?.closable
274
+ ? () => {
275
+ removeModal(key);
276
+ modal.onClose?.();
277
+ }
278
+ : undefined
279
+ }
258
280
  />
259
281
  )
260
282
  )}
@@ -2,6 +2,7 @@ import { createContext } from 'use-context-selector';
2
2
  import { DEFAULT_THEME, IReqoreTheme } from '../constants/theme';
3
3
  import {
4
4
  IReqoreConfirmationModal,
5
+ IReqoreModal,
5
6
  IReqoreModalFromProps,
6
7
  IReqoreNotificationData,
7
8
  TReqoreCustomModal,
@@ -12,7 +13,11 @@ export interface IReqoreContext {
12
13
  readonly confirmAction: (data: IReqoreConfirmationModal) => void;
13
14
  readonly notifications?: IReqoreNotificationData[] | null;
14
15
  readonly addNotification?: (data: IReqoreNotificationData) => any;
15
- readonly addModal?: (modal: IReqoreModalFromProps | TReqoreCustomModal, id?: string) => string;
16
+ readonly addModal?: (
17
+ modal: IReqoreModalFromProps | TReqoreCustomModal,
18
+ id?: string,
19
+ options?: IReqoreModal['options']
20
+ ) => string;
16
21
  readonly removeModal?: (id: string) => void;
17
22
  readonly removeNotification?: (id: string) => any;
18
23
  readonly isMobile?: boolean;
@@ -231,9 +231,9 @@ export const getColorFromMaybeString = (
231
231
 
232
232
  if (shading) {
233
233
  if (shading === 'lighten') {
234
- _color = lighten(0.1 * multiplier, _color) as TReqoreHexColor;
234
+ _color = lighten(0.033 * multiplier, _color) as TReqoreHexColor;
235
235
  } else if (shading === 'darken') {
236
- _color = darken(0.1 * multiplier, _color) as TReqoreHexColor;
236
+ _color = darken(0.033 * multiplier, _color) as TReqoreHexColor;
237
237
  }
238
238
  }
239
239
 
@@ -161,7 +161,7 @@ const Template: StoryFn<IReqoreMenuProps> = (args) => {
161
161
  onRightIconClick={() => alert('Icon clicked')}
162
162
  description='Button with right icon and description'
163
163
  customTheme={{
164
- main: 'info:darken:1:0.3',
164
+ main: 'info:darken:5:0.3',
165
165
  }}
166
166
  >
167
167
  Some button
@@ -20,7 +20,7 @@ const TIMEOUT = 2000;
20
20
  const meta = {
21
21
  title: 'Utilities/Global Modal/Tests',
22
22
  component: ReqoreModal,
23
- render: ({ data, updateToData }) => {
23
+ render: ({ data, updateToData, options }) => {
24
24
  const addModal = useReqoreProperty('addModal');
25
25
  const [modalId, setModalId] = useState<string>(undefined);
26
26
 
@@ -37,7 +37,7 @@ const meta = {
37
37
  <ReqoreButton
38
38
  id='modal'
39
39
  onClick={() => {
40
- setModalId(addModal(data, 'modal'));
40
+ setModalId(addModal(data, 'modal', options));
41
41
  }}
42
42
  >
43
43
  Open new modal
@@ -162,6 +162,20 @@ export const CanBeClosedManually: Story = {
162
162
  },
163
163
  };
164
164
 
165
+ export const CannotBeClosed: Story = {
166
+ args: {
167
+ data: {
168
+ children: 'I cannot be closed',
169
+ },
170
+ options: {
171
+ closable: false,
172
+ },
173
+ },
174
+ play: async ({ canvasElement, ...rest }) => {
175
+ await FromObject.play({ canvasElement, ...rest });
176
+ },
177
+ };
178
+
165
179
  export const CanBeUpdated: Story = {
166
180
  args: {
167
181
  data: (<ModalWithState label='Test modal' />) as any,