@kwiz/fluentui 1.0.31 → 1.0.33
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/controls/button.d.ts +14 -13
- package/dist/controls/button.js +8 -7
- package/dist/controls/button.js.map +1 -1
- package/dist/controls/divider.js +2 -2
- package/dist/controls/divider.js.map +1 -1
- package/dist/controls/horizontal.d.ts +1 -0
- package/dist/controls/horizontal.js +6 -1
- package/dist/controls/horizontal.js.map +1 -1
- package/dist/controls/menu.d.ts +34 -0
- package/dist/controls/menu.js +96 -0
- package/dist/controls/menu.js.map +1 -0
- package/dist/controls/prompt.d.ts +2 -0
- package/dist/controls/prompt.js +27 -6
- package/dist/controls/prompt.js.map +1 -1
- package/dist/controls/search.js +4 -3
- package/dist/controls/search.js.map +1 -1
- package/dist/helpers/drag-drop/drag-drop-container.js +3 -3
- package/dist/helpers/drag-drop/drag-drop-container.js.map +1 -1
- package/dist/helpers/hooks.d.ts +19 -5
- package/dist/helpers/hooks.js +45 -4
- package/dist/helpers/hooks.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/styles/styles.d.ts +5 -1
- package/dist/styles/styles.js +5 -2
- package/dist/styles/styles.js.map +1 -1
- package/package.json +4 -4
- package/src/controls/button.tsx +15 -10
- package/src/controls/divider.tsx +3 -3
- package/src/controls/horizontal.tsx +7 -1
- package/src/controls/menu.tsx +159 -0
- package/src/controls/prompt.tsx +33 -8
- package/src/controls/search.tsx +4 -3
- package/src/helpers/drag-drop/drag-drop-container.tsx +3 -3
- package/src/helpers/hooks.tsx +65 -5
- package/src/index.ts +2 -1
- package/src/styles/styles.ts +5 -2
package/src/helpers/hooks.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Link, Toast, ToastBody, Toaster, ToastFooter, ToastIntent, ToastTitle, useId, useToastController } from "@fluentui/react-components";
|
|
1
|
+
import { Label, Link, Toast, ToastBody, Toaster, ToastFooter, ToastIntent, ToastTitle, useId, useToastController } from "@fluentui/react-components";
|
|
2
2
|
import { IDictionary, isDebug, isFunction, isNotEmptyArray, isNullOrEmptyString, jsonClone, jsonStringify, LoggerLevel, objectsEqual, wrapFunction } from "@kwiz/common";
|
|
3
3
|
import { MutableRefObject, SetStateAction, useCallback, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { GetLogger } from "../_modules/config";
|
|
@@ -190,14 +190,20 @@ export function useIsInPrint() {
|
|
|
190
190
|
}, useEffectOnlyOnMount);
|
|
191
191
|
return printMode;
|
|
192
192
|
}
|
|
193
|
+
export interface iBlockNav {
|
|
194
|
+
setMessage: (id: string, message?: string) => void;
|
|
195
|
+
onNav: (nav: () => void) => void;
|
|
196
|
+
navPrompt?: JSX.Element;
|
|
197
|
+
|
|
198
|
+
}
|
|
193
199
|
/** set block message if you want to block nav.
|
|
194
200
|
* - call setMessage to add a blocker message
|
|
195
201
|
* - call onNav when you have internal navigation (open / close popups)
|
|
196
202
|
* - render the navPrompt control to your page
|
|
197
203
|
* FYI for page unload, most modern browsers won't show your message but a generic one instead. */
|
|
198
|
-
export function useBlockNav() {
|
|
204
|
+
export function useBlockNav(): iBlockNav {
|
|
199
205
|
const [, setBlockNavMessages, blockNavMessagesRef] = useStateEX<IDictionary<string>>({});
|
|
200
|
-
const [
|
|
206
|
+
const [_prompt, setPrompt] = useStateEX<IPrompterProps>(null);
|
|
201
207
|
|
|
202
208
|
const getMessagesArr = useCallback(() => {
|
|
203
209
|
return Object.keys(blockNavMessagesRef.current).map(id => blockNavMessagesRef.current[id]);
|
|
@@ -265,7 +271,7 @@ export function useBlockNav() {
|
|
|
265
271
|
// getMessages,
|
|
266
272
|
// getMessagesArr,
|
|
267
273
|
onNav,
|
|
268
|
-
navPrompt:
|
|
274
|
+
navPrompt: _prompt ? <Prompter {..._prompt} /> : undefined
|
|
269
275
|
};
|
|
270
276
|
}
|
|
271
277
|
|
|
@@ -287,7 +293,7 @@ export function useKeyDown(options: {
|
|
|
287
293
|
};
|
|
288
294
|
elm.addEventListener("keydown", handler);
|
|
289
295
|
return () => elm.removeEventListener("keydown", handler);
|
|
290
|
-
}, [elm]);
|
|
296
|
+
}, [elm, options.onEnter, options.onEscape, options.onKeyDown]);
|
|
291
297
|
}
|
|
292
298
|
|
|
293
299
|
|
|
@@ -333,4 +339,58 @@ export function useKWIZFluentContextProvider(options: {
|
|
|
333
339
|
});
|
|
334
340
|
}, [options.root]);
|
|
335
341
|
return kwizFluentContext;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export interface iAlerts {
|
|
345
|
+
promptEX: (info: IPrompterProps) => void;
|
|
346
|
+
confirmEX: (message: string, onOK: () => void, onCancel?: () => void) => void;
|
|
347
|
+
alertEX: (message: string, onOK: () => void) => void;
|
|
348
|
+
alertPrompt?: JSX.Element;
|
|
349
|
+
}
|
|
350
|
+
/** set block message if you want to block nav.
|
|
351
|
+
* - call setMessage to add a blocker message
|
|
352
|
+
* - call onNav when you have internal navigation (open / close popups)
|
|
353
|
+
* - render the navPrompt control to your page
|
|
354
|
+
* FYI for page unload, most modern browsers won't show your message but a generic one instead. */
|
|
355
|
+
export function useAlerts(): iAlerts {
|
|
356
|
+
const [_prompt, _setPrompt] = useStateEX<IPrompterProps>(null);
|
|
357
|
+
|
|
358
|
+
const promptEX = useCallback((info: IPrompterProps) => {
|
|
359
|
+
//need to release react to re-render the prompt
|
|
360
|
+
window.setTimeout(() => {
|
|
361
|
+
//prompt, if ok - clear messages and nav.
|
|
362
|
+
_setPrompt({
|
|
363
|
+
...info,
|
|
364
|
+
onCancel: () => {
|
|
365
|
+
_setPrompt(null);
|
|
366
|
+
if (isFunction(info.onCancel)) info.onCancel();
|
|
367
|
+
},
|
|
368
|
+
onOK: () => {
|
|
369
|
+
_setPrompt(null);
|
|
370
|
+
if (isFunction(info.onOK)) info.onOK();
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
}, 1);
|
|
374
|
+
}, useEffectOnlyOnMount);
|
|
375
|
+
|
|
376
|
+
const confirmEX = useCallback((message: string, onOK: () => void, onCancel?: () => void) => {
|
|
377
|
+
promptEX({
|
|
378
|
+
children: <Label>{message}</Label>,
|
|
379
|
+
onCancel,
|
|
380
|
+
onOK
|
|
381
|
+
});
|
|
382
|
+
}, useEffectOnlyOnMount);
|
|
383
|
+
|
|
384
|
+
const alertEX = useCallback((message: string, onOK: () => void) => {
|
|
385
|
+
promptEX({
|
|
386
|
+
children: <Label>{message}</Label>,
|
|
387
|
+
hideCancel: true,
|
|
388
|
+
onOK
|
|
389
|
+
});
|
|
390
|
+
}, useEffectOnlyOnMount);
|
|
391
|
+
|
|
392
|
+
return {
|
|
393
|
+
promptEX, confirmEX, alertEX,
|
|
394
|
+
alertPrompt: _prompt ? <Prompter {..._prompt} /> : undefined
|
|
395
|
+
};
|
|
336
396
|
}
|
package/src/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from './controls/input';
|
|
|
12
12
|
export * from './controls/kwizoverflow';
|
|
13
13
|
export * from './controls/list';
|
|
14
14
|
export * from './controls/loading';
|
|
15
|
+
export * from './controls/menu';
|
|
15
16
|
export * from './controls/please-wait';
|
|
16
17
|
export * from './controls/prompt';
|
|
17
18
|
export * from './controls/search';
|
|
@@ -24,5 +25,5 @@ export { KWIZFluentContext, useKWIZFluentContext } from './helpers/context';
|
|
|
24
25
|
export type { iKWIZFluentContext } from './helpers/context';
|
|
25
26
|
export * from './helpers/drag-drop/exports';
|
|
26
27
|
export * from './helpers/hooks';
|
|
27
|
-
export { KnownClassNames } from './styles/styles';
|
|
28
|
+
export { KnownClassNames, commonSizes } from './styles/styles';
|
|
28
29
|
|
package/src/styles/styles.ts
CHANGED