@kwiz/fluentui 1.0.78 → 1.0.79

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.
Files changed (87) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +53 -53
  3. package/dist/controls/svg.js +21 -21
  4. package/dist/controls/svg.js.map +1 -1
  5. package/package.json +85 -85
  6. package/.dependency-cruiser.js +0 -399
  7. package/.github/workflows/npm-publish.yml +0 -24
  8. package/dist/@types/forwardRef.d.ts +0 -0
  9. package/dist/@types/forwardRef.js +0 -1
  10. package/dist/@types/forwardRef.js.map +0 -1
  11. package/dist/controls/error-boundary copy.d.ts +0 -23
  12. package/dist/controls/error-boundary copy.js +0 -33
  13. package/dist/controls/error-boundary copy.js.map +0 -1
  14. package/dist/helpers/common.d.ts +0 -4
  15. package/dist/helpers/common.js +0 -2
  16. package/dist/helpers/common.js.map +0 -1
  17. package/dist/helpers/context.d.ts +0 -26
  18. package/dist/helpers/context.js +0 -15
  19. package/dist/helpers/context.js.map +0 -1
  20. package/dist/helpers/drag-drop/exports.d.ts +0 -12
  21. package/dist/helpers/drag-drop/exports.js +0 -3
  22. package/dist/helpers/drag-drop/exports.js.map +0 -1
  23. package/dist/helpers/exports.d.ts +0 -7
  24. package/dist/helpers/exports.js +0 -8
  25. package/dist/helpers/exports.js.map +0 -1
  26. package/src/_modules/config.ts +0 -9
  27. package/src/_modules/constants.ts +0 -3
  28. package/src/controls/ColorPickerDialog.tsx +0 -84
  29. package/src/controls/accordion.tsx +0 -62
  30. package/src/controls/button.tsx +0 -181
  31. package/src/controls/canvas/CustomEventTargetBase.ts +0 -33
  32. package/src/controls/canvas/DrawPad.tsx +0 -297
  33. package/src/controls/canvas/DrawPadManager.ts +0 -695
  34. package/src/controls/canvas/bezier.ts +0 -110
  35. package/src/controls/canvas/point.ts +0 -45
  36. package/src/controls/card-list.tsx +0 -32
  37. package/src/controls/card.tsx +0 -78
  38. package/src/controls/centered.tsx +0 -15
  39. package/src/controls/date.tsx +0 -88
  40. package/src/controls/diagram-picker.tsx +0 -97
  41. package/src/controls/divider.tsx +0 -16
  42. package/src/controls/dropdown.tsx +0 -67
  43. package/src/controls/error-boundary.tsx +0 -42
  44. package/src/controls/field-editor.tsx +0 -43
  45. package/src/controls/file-upload.tsx +0 -156
  46. package/src/controls/horizontal.tsx +0 -49
  47. package/src/controls/html-editor/editor.tsx +0 -182
  48. package/src/controls/index.ts +0 -33
  49. package/src/controls/input.tsx +0 -161
  50. package/src/controls/kwizoverflow.tsx +0 -107
  51. package/src/controls/list.tsx +0 -120
  52. package/src/controls/loading.tsx +0 -11
  53. package/src/controls/menu.tsx +0 -196
  54. package/src/controls/merge-text.tsx +0 -126
  55. package/src/controls/please-wait.tsx +0 -33
  56. package/src/controls/progress-bar.tsx +0 -110
  57. package/src/controls/prompt.tsx +0 -122
  58. package/src/controls/qrcode.tsx +0 -37
  59. package/src/controls/search.tsx +0 -72
  60. package/src/controls/section.tsx +0 -134
  61. package/src/controls/svg.tsx +0 -139
  62. package/src/controls/toolbar.tsx +0 -47
  63. package/src/controls/vertical-content.tsx +0 -50
  64. package/src/controls/vertical.tsx +0 -43
  65. package/src/helpers/block-nav.tsx +0 -89
  66. package/src/helpers/context-const.ts +0 -30
  67. package/src/helpers/context-export.tsx +0 -78
  68. package/src/helpers/context-internal.ts +0 -14
  69. package/src/helpers/drag-drop/drag-drop-container.tsx +0 -54
  70. package/src/helpers/drag-drop/drag-drop-context-internal.tsx +0 -10
  71. package/src/helpers/drag-drop/drag-drop-context.tsx +0 -62
  72. package/src/helpers/drag-drop/drag-drop.types.ts +0 -21
  73. package/src/helpers/drag-drop/index.ts +0 -12
  74. package/src/helpers/drag-drop/readme.md +0 -76
  75. package/src/helpers/drag-drop/use-draggable.ts +0 -48
  76. package/src/helpers/drag-drop/use-droppable.ts +0 -39
  77. package/src/helpers/forwardRef.ts +0 -7
  78. package/src/helpers/hooks-events.ts +0 -150
  79. package/src/helpers/hooks.tsx +0 -175
  80. package/src/helpers/index.ts +0 -8
  81. package/src/helpers/use-alerts.tsx +0 -75
  82. package/src/helpers/use-editable-control.tsx +0 -38
  83. package/src/helpers/use-toast.tsx +0 -30
  84. package/src/index.ts +0 -3
  85. package/src/styles/index.ts +0 -1
  86. package/src/styles/styles.ts +0 -105
  87. package/src/styles/theme.ts +0 -91
@@ -1,150 +0,0 @@
1
- import { isDebug, isFunction } from "@kwiz/common";
2
- import { MutableRefObject, useEffect, useRef, useState } from "react";
3
- import { KnownClassNames } from "../styles/styles";
4
- import { useEffectOnlyOnMount } from "./hooks";
5
-
6
- export function useTrackFocus<elmType extends HTMLElement>(props: { onFocus: () => void, onLoseFocus: () => void, ref?: MutableRefObject<elmType> }) {
7
- const wrapperDiv: MutableRefObject<elmType> = props.ref || useRef<HTMLDivElement>(null) as any;
8
- useEffect(() => {
9
- function focusIn(e: FocusEvent) {
10
- let elm = e.target as HTMLElement;//document.activeElement;
11
- if (wrapperDiv.current) {
12
- while (elm && elm !== wrapperDiv.current) {
13
- elm = elm.parentElement;
14
- }
15
- } else elm = null;
16
- if (wrapperDiv.current && elm === wrapperDiv.current) props.onFocus();
17
- else props.onLoseFocus();
18
- }
19
-
20
- if (wrapperDiv.current) {
21
- if (wrapperDiv.current) wrapperDiv.current.tabIndex = 1;
22
- window.addEventListener("focusin", focusIn);
23
- // Remove event listener on cleanup
24
- return () => window.removeEventListener("focusin", focusIn);
25
- }
26
- }, [wrapperDiv.current]);
27
- return wrapperDiv;
28
- }
29
- export function useWindowSize() {
30
- // Initialize state with undefined width/height so server and client renders match
31
- // Learn more here: https://joshwcomeau.com/react/the-perils-of-rehydration/
32
- const [windowSize, setWindowSize] = useState<{
33
- width: number,
34
- height: number
35
- }>({
36
- width: undefined,
37
- height: undefined
38
- });
39
- useEffect(() => {
40
- // Handler to call on window resize
41
- function handleResize() {
42
-
43
- // Set window width/height to state
44
- setWindowSize({
45
- width: window.innerWidth,
46
- height: window.innerHeight
47
- });
48
- }
49
- // Add event listener
50
- window.addEventListener("resize", handleResize);
51
- // Call handler right away so state gets updated with initial window size
52
- handleResize();
53
- // Remove event listener on cleanup
54
- return () => window.removeEventListener("resize", handleResize);
55
- }, useEffectOnlyOnMount);
56
- return windowSize;
57
- }
58
- export function useElementSize(elm: HTMLElement) {
59
- // Initialize state with undefined width/height so server and client renders match
60
- // Learn more here: https://joshwcomeau.com/react/the-perils-of-rehydration/
61
- const [elmSize, setELmSize] = useState<{
62
- width: number,
63
- height: number
64
- }>({
65
- width: undefined,
66
- height: undefined
67
- });
68
- useEffect(() => {
69
- if (elm) {
70
- // Handler to call on elm resize
71
- function handleResize() {
72
- // Set elm width/height to state
73
- setELmSize({
74
- width: (elm instanceof Window) ? elm.innerWidth : elm.clientWidth,
75
- height: (elm instanceof Window) ? elm.innerHeight : elm.clientHeight,
76
- });
77
- }
78
- // Add event listener
79
- const observer = new ResizeObserver(handleResize);
80
- observer.observe(elm);
81
- // Call handler right away so state gets updated with initial elm size
82
- handleResize();
83
- // Remove event listener on cleanup
84
- return () => observer.disconnect();
85
- }
86
- }, [elm]);
87
- return elmSize;
88
- }
89
- export function useIsInPrint() {
90
- // Initialize state with media query
91
- const [printMode, setPrintMode] = useState<boolean>(window.matchMedia ? window.matchMedia('print').matches : false);
92
- useEffect(() => {
93
- if (printMode)
94
- document.body.classList.add(KnownClassNames.print);
95
- else
96
- document.body.classList.remove(KnownClassNames.print);
97
- }, [printMode]);
98
-
99
- useEffect(() => {
100
- const forcePrintOn = () => setPrintMode(true);
101
- const forcePrintOff = () => setPrintMode(false);
102
-
103
- function printDebugHelper(e: KeyboardEvent) {
104
- if (e.ctrlKey && e.shiftKey && e.altKey) {
105
- if (e.key.toLocaleLowerCase() === "q") {
106
- forcePrintOff();
107
- }
108
- else {
109
- console.warn('forced print mode - to exit refresh to ctrl+shift+alt+q');
110
- forcePrintOn();
111
- }
112
- }
113
- }
114
-
115
- // Add event listener
116
- window.addEventListener("beforeprint", forcePrintOn);
117
- window.addEventListener("afterprint", forcePrintOff);
118
- if (isDebug())
119
- window.addEventListener("keydown", printDebugHelper);
120
- // Remove event listener on cleanup
121
- return () => {
122
- window.removeEventListener("beforeprint", forcePrintOn);
123
- window.removeEventListener("afterprint", forcePrintOff);
124
- if (isDebug())
125
- window.removeEventListener("keydown", printDebugHelper);
126
- };
127
- }, useEffectOnlyOnMount);
128
- return printMode;
129
- }
130
-
131
- export function useKeyDown(options: {
132
- //default use document
133
- elm?: HTMLElement | Document;
134
- onEnter?: (e: KeyboardEvent) => void;
135
- onEscape?: (e: KeyboardEvent) => void;
136
- onKeyDown?: (e: KeyboardEvent) => void;
137
- }) {
138
- let elm = options.elm || document;
139
-
140
- useEffect(() => {
141
- let handler = (e: KeyboardEvent) => {
142
- if (e.key === "Enter" && isFunction(options.onEnter)) options.onEnter(e);
143
- else if (e.key === "Escape" && isFunction(options.onEscape)) options.onEscape(e);
144
- if (isFunction(options.onKeyDown))
145
- options.onKeyDown(e);
146
- };
147
- elm.addEventListener("keydown", handler);
148
- return () => elm.removeEventListener("keydown", handler);
149
- }, [elm, options.onEnter, options.onEscape, options.onKeyDown]);
150
- }
@@ -1,175 +0,0 @@
1
- import { makeStyles } from "@fluentui/react-components";
2
- import { isFunction, isNotEmptyArray, isNullOrEmptyString, isPrimitiveValue, jsonClone, jsonStringify, LoggerLevel, objectsEqual } from "@kwiz/common";
3
- import { HTMLAttributes, MutableRefObject, SetStateAction, useCallback, useEffect, useRef, useState } from "react";
4
- import { GetLogger } from "../_modules/config";
5
- import { mixins } from "../styles/styles";
6
-
7
- /** Empty array ensures that effect is only run on mount */
8
- export const useEffectOnlyOnMount = [];
9
-
10
- type stateExOptions<ValueType> = {
11
- onChange?: (newValue: ValueType, isValueChanged: boolean) => ValueType;
12
- //will not set state if value did not change
13
- skipUpdateIfSame?: boolean;
14
- //optional, provide a name for better logging
15
- name?: string;
16
- };
17
- function extractStringValue(e: any) {
18
- try {
19
- if (e instanceof HTMLElement)
20
- return e.outerHTML;
21
- } catch (e) { }
22
- try {
23
- let json = jsonStringify(e);
24
- if (json === "{}") return Object.keys(e).join();//maybe just object with functions, no members or values
25
- else return json;
26
- } catch (e) { }
27
- try {
28
- return e.toString();
29
- } catch (e) { }
30
- return '';
31
- }
32
- /** set state on steroids. provide promise callback after render, onChange transformer and automatic skip-set when value not changed */
33
- export function useStateEX<ValueType>(initialValue: ValueType, options?: stateExOptions<ValueType>):
34
- [ValueType, (newValue: SetStateAction<ValueType>) => Promise<ValueType>, MutableRefObject<ValueType>] {
35
- options = options || {};
36
- const name = options.name || '';
37
-
38
- let logger = GetLogger(`useStateWithTrack${isNullOrEmptyString(name) ? '' : ` ${name}`}`);
39
- logger.setLevel(LoggerLevel.WARN);
40
-
41
- const [value, setValueInState] = useState<ValueType>(initialValue);
42
-
43
- const currentValue = useRef<ValueType>();
44
- //json clone complex/ref values so we can compare if value changed, in case caller makes chagnes on the value object directly.
45
- const currentValueForChecks = useRef<ValueType>();
46
- useEffect(() => {
47
- updateCurrentRef(initialValue);
48
- }, useEffectOnlyOnMount);
49
-
50
- //keep a ref to onChange so the caller's latet state is accessible
51
- const onChange = useRef(options.onChange);
52
- onChange.current = options.onChange;
53
-
54
- /** make this a collection in case several callers are awaiting the same propr update */
55
- const resolveState = useRef<((v: ValueType) => void)[]>([]);
56
- const isMounted = useRef(false);
57
-
58
- useEffect(() => {
59
- isMounted.current = true;
60
-
61
- return () => {
62
- isMounted.current = false;
63
- };
64
- }, useEffectOnlyOnMount);
65
-
66
- function resolvePromises() {
67
- if (isNotEmptyArray(resolveState.current)) {
68
- let resolvers = resolveState.current.slice();
69
- resolveState.current = [];//clear
70
- resolvers.map(r => r(currentValue.current));
71
- }
72
- };
73
- useEffect(() => {
74
- resolvePromises();
75
- }, [value]);
76
-
77
- function getIsValueChanged(newValue: ValueType): boolean {
78
- let error: Error = null;
79
- let result: boolean;
80
- try {
81
- if (!objectsEqual(newValue as object, currentValueForChecks.current as object)) {
82
- result = true;
83
- }
84
- else {
85
- result = false;
86
- }
87
- } catch (e) {
88
- error = e;
89
- result = true;
90
- }
91
-
92
- return logger.groupSync(result ? 'value changed' : 'value not changed', log => {
93
- if (logger.getLevel() === LoggerLevel.VERBOSE) {
94
- log('old: ' + extractStringValue(currentValueForChecks.current));
95
- log('new: ' + extractStringValue(newValue));
96
- if (error) log({ label: "Error", value: error });
97
- }
98
- return result;
99
- });
100
- };
101
- function updateCurrentRef(newValue: ValueType) {
102
- currentValue.current = newValue;
103
- currentValueForChecks.current = isPrimitiveValue(newValue) || isFunction(newValue)
104
- ? newValue
105
- //fix skipUpdateIfSame for complex objects
106
- //if we don't clone it, currentValue.current will be a ref to the value in the owner
107
- //and will be treated as unchanged object, and it will be out of sync
108
- //this leads to skipUpdateIfSame failing after just 1 unchanged update
109
- : jsonClone(newValue) as ValueType;
110
- }
111
-
112
- const setValue = useCallback((newState: ValueType) => new Promise<ValueType>(resolve => {
113
- if (!isMounted.current) {
114
- //unmounted may never resolve
115
- logger.log(`resolved without wait`);
116
- resolve(newState);
117
- }
118
- else {
119
- resolveState.current.push(resolve);
120
- const isChanged = isFunction(onChange.current) || options.skipUpdateIfSame
121
- ? getIsValueChanged(newState)//don't call this if there is no onChange handler and if we don't need to monitor skipUpdateIfSame
122
- : true;
123
- if (isFunction(onChange.current))
124
- newState = onChange.current(newState, isChanged);
125
-
126
- //keep current value ref up to date
127
- updateCurrentRef(newState);
128
-
129
- //set state
130
- if (!options.skipUpdateIfSame || isChanged)
131
- setValueInState(newState);
132
- else//don't set in state - just resolve pending promises, UI will not be updated.
133
- resolvePromises();
134
- }
135
- }), useEffectOnlyOnMount);
136
-
137
- return [value, setValue, currentValue];
138
- }
139
-
140
- /** use a ref, that can be tracked as useEffect dependency */
141
- export function useRefWithState<T>(initialValue?: T, stateOptions: stateExOptions<T> = { skipUpdateIfSame: true, name: "useRefWithState" }) {
142
- let asRef = useRef<T>(initialValue);
143
- let [asState, setState] = useStateEX<T>(initialValue, stateOptions);
144
- let setRef = useCallback((newValue: T) => {
145
- asRef.current = newValue;
146
- setState(newValue);
147
- }, useEffectOnlyOnMount);
148
- return {
149
- /** ref object for getting latest value in handlers */
150
- ref: asRef,
151
- /** for useEffect dependency */
152
- value: asState,
153
- /** for setting on element: ref={e.set} */
154
- set: setRef
155
- };
156
- }
157
-
158
- const useStyles = makeStyles({
159
- clickable: mixins.clickable,
160
- });
161
-
162
- /** return props to make div appear as clickable, and accept enter key as click */
163
- export function useClickableDiv() {
164
- const cssNames = useStyles();
165
-
166
- const props: HTMLAttributes<HTMLDivElement> = {
167
- className: cssNames.clickable,
168
- tabIndex: 0,
169
- onKeyDown: e => {
170
- if (e.key === "Enter") (e.target as HTMLDivElement).click();
171
- }
172
- };
173
-
174
- return props;
175
- }
@@ -1,8 +0,0 @@
1
- export * from './block-nav';
2
- export * from './context-export';
3
- export * from './drag-drop';
4
- export * from './hooks';
5
- export * from './hooks-events';
6
- export * from './use-alerts';
7
- export * from './use-editable-control';
8
- export * from './use-toast';
@@ -1,75 +0,0 @@
1
- import { Label } from "@fluentui/react-components";
2
- import { isFunction, isString } from "@kwiz/common";
3
- import { useCallback } from "react";
4
- import { IPrompterProps, Prompter } from "../controls/prompt";
5
- import { useEffectOnlyOnMount, useStateEX } from "./hooks";
6
-
7
- export interface iAlerts {
8
- promptEX: (info: IPrompterProps) => void;
9
- confirmEX: (message: string | JSX.Element, onOK?: () => void, onCancel?: () => void) => Promise<boolean>;
10
- alertEX: (message: string | JSX.Element, onOK?: () => void) => Promise<void>;
11
- alertPrompt?: JSX.Element;
12
- close: () => void;
13
- }
14
-
15
- /** set block message if you want to block nav.
16
- * - call setMessage to add a blocker message
17
- * - call onNav when you have internal navigation (open / close popups)
18
- * - render the navPrompt control to your page
19
- * FYI for page unload, most modern browsers won't show your message but a generic one instead. */
20
- export function useAlerts(): iAlerts {
21
- const [_prompt, _setPrompt] = useStateEX<IPrompterProps>(null);
22
-
23
- const promptEX = useCallback((info: IPrompterProps) => {
24
- //need to release react to re-render the prompt
25
- window.setTimeout(() => {
26
- //prompt, if ok - clear messages and nav.
27
- _setPrompt({
28
- ...info,
29
- onCancel: () => {
30
- _setPrompt(null);
31
- if (isFunction(info.onCancel)) info.onCancel();
32
- },
33
- onOK: () => {
34
- _setPrompt(null);
35
- if (isFunction(info.onOK)) info.onOK();
36
- }
37
- });
38
- }, 1);
39
- }, useEffectOnlyOnMount);
40
-
41
- const confirmEX = useCallback((message: string | JSX.Element, onOK?: () => void, onCancel?: () => void) => {
42
- return new Promise<boolean>(resolve => {
43
- promptEX({
44
- children: isString(message) ? <Label>{message}</Label> : message,
45
- onCancel: () => {
46
- if (isFunction(onCancel)) onCancel();
47
- resolve(false);
48
- },
49
- onOK: () => {
50
- if (isFunction(onOK)) onOK();
51
- resolve(true);
52
- }
53
- });
54
- });
55
- }, useEffectOnlyOnMount);
56
-
57
- const alertEX = useCallback((message: string | JSX.Element, onOK: () => void) => {
58
- return new Promise<void>(resolve => {
59
- promptEX({
60
- children: isString(message) ? <Label>{message}</Label> : message,
61
- hideCancel: true,
62
- onOK: () => {
63
- if (isFunction(onOK)) onOK();
64
- resolve();
65
- }
66
- });
67
- });
68
- }, useEffectOnlyOnMount);
69
-
70
- return {
71
- promptEX, confirmEX, alertEX,
72
- alertPrompt: _prompt ? <Prompter {..._prompt} /> : undefined,
73
- close: () => _setPrompt(null)
74
- };
75
- }
@@ -1,38 +0,0 @@
1
- import { Toast, ToastTitle, Toaster, useId, useToastController } from "@fluentui/react-components";
2
- import { useCallback, useState } from "react";
3
- import { PleaseWait } from "../controls/please-wait";
4
- import { useEffectOnlyOnMount, useStateEX } from "./hooks";
5
-
6
- /* Provides useful helpers for tracking if control has changes, and handling the save changes with progress bar and on success/fail messages. */
7
- export function useEditableControl() {
8
- const [showProgress, setShowProgress] = useState(false);
9
- const [hasChanges, setHasChanges, hasChangesRef] = useStateEX(false, { skipUpdateIfSame: true });
10
-
11
- const toasterId = useId("toaster");
12
- const { dispatchToast } = useToastController(toasterId);
13
-
14
- const onSaveChanges = useCallback(async (worker: () => Promise<{ success: boolean; message?: string; }>) => {
15
- setShowProgress(true);
16
- const success = await worker();
17
- setShowProgress(false);
18
-
19
- if (success.success !== true) {
20
- dispatchToast(<Toast>
21
- <ToastTitle>{success.message || "Could not save your changes."}</ToastTitle>
22
- </Toast>, { intent: "warning", timeout: 10000 });
23
- }
24
- else {
25
- setHasChanges(false);
26
- dispatchToast(<Toast>
27
- <ToastTitle>{success.message || "Changes saved!"}</ToastTitle>
28
- </Toast>, { intent: "success", timeout: 2000 });
29
- }
30
- }, useEffectOnlyOnMount);
31
-
32
- return {
33
- hasChanges, hasChangesRef, setHasChanges, onSaveChanges, editablePageElement: <>
34
- {showProgress && <PleaseWait />}
35
- <Toaster toasterId={toasterId} />
36
- </>
37
- };
38
- }
@@ -1,30 +0,0 @@
1
- import { Link, Toast, ToastBody, Toaster, ToastFooter, ToastIntent, ToastTitle, useId, useToastController } from "@fluentui/react-components";
2
- import { isNotEmptyArray } from "@kwiz/common";
3
- import { useKWIZFluentContext } from "./context-internal";
4
-
5
- export function useToast() {
6
- const ctx = useKWIZFluentContext();
7
- const toasterId = useId("toaster");
8
- const { dispatchToast } = useToastController(toasterId);
9
- return {
10
- control: <Toaster mountNode={ctx.mountNode} toasterId={toasterId} />,
11
- dispatch: (info: {
12
- title?: string;
13
- body?: string;
14
- subtitle?: string;
15
- titleAction?: { text: string, onClick: () => void },
16
- footerActions?: { text: string, onClick: () => void }[],
17
- intent?: ToastIntent
18
- }) => {
19
- dispatchToast(<Toast>
20
- {info.title && <ToastTitle action={info.titleAction ? <Link onClick={info.titleAction.onClick}>{info.titleAction.text}</Link> : undefined}>{info.title}</ToastTitle>}
21
- {info.body && <ToastBody subtitle={info.subtitle}>{info.body}</ToastBody>}
22
- {isNotEmptyArray(info.footerActions) &&
23
- <ToastFooter>
24
- {info.footerActions.map((a, i) => <Link key={`l${i}`} onClick={a.onClick}>{a.text}</Link>)}
25
- </ToastFooter>
26
- }
27
- </Toast>, { intent: info.intent || "info" });
28
- }
29
- }
30
- }
package/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './controls';
2
- export * from './helpers';
3
- export * from './styles';
@@ -1 +0,0 @@
1
- export { commonSizes, KnownClassNames } from './styles';
@@ -1,105 +0,0 @@
1
- import { GriffelStyle, makeStyles, tokens } from "@fluentui/react-components";
2
-
3
- export module mixins {
4
- export const main: GriffelStyle = {
5
- flexShrink: 1,
6
- flexGrow: 1
7
- };
8
- export const clickable: GriffelStyle = {
9
- cursor: "pointer",
10
- ['& label']: {
11
- cursor: "pointer"
12
- }
13
- }
14
- export const box: GriffelStyle = {
15
- padding: tokens.spacingHorizontalM,
16
- borderRadius: tokens.borderRadiusMedium,
17
- boxShadow: tokens.shadow4,
18
- margin: tokens.spacingHorizontalXXS
19
- }
20
- export const float: GriffelStyle = {
21
- ...box,
22
- /** make buttons work */
23
- position: "relative",
24
- /** make buttons work */
25
- maxWidth: "33%",
26
- /** stop bleeding into page */
27
- overflowX: "hidden",
28
-
29
- ['& img']: {
30
- maxWidth: "100%"
31
- }
32
- }
33
-
34
- export const flex: GriffelStyle = {
35
- display: 'flex',
36
- flexWrap: 'nowrap',
37
- rowGap: tokens.spacingVerticalM,
38
- columnGap: tokens.spacingVerticalM,
39
- }
40
-
41
- export const wrap: GriffelStyle = {
42
- flexWrap: "wrap"
43
- }
44
- export const nogap: GriffelStyle = {
45
- rowGap: 0,
46
- columnGap: 0
47
- }
48
- export const ellipsis: GriffelStyle = {
49
- whiteSpace: 'nowrap',
50
- display: 'block',
51
- overflow: 'hidden',
52
- textOverflow: 'ellipsis'
53
- }
54
-
55
- // export const box: GriffelStyle = {
56
- // }
57
- }
58
-
59
- export const KnownClassNames = {
60
- print: 'print-root',
61
- printHide: 'print-hide',
62
- printShow: 'print-show',
63
- section: 'kfui-section',
64
- vertical: 'kfui-vertical',
65
- horizontal: 'kfui-horizontal',
66
- list: 'kfui-list',
67
- accordion: 'kfui-accordion',
68
- accordionHeader: 'kfui-accordion-header',
69
- accordionBody: 'kfui-accordion-body',
70
- accordionBodyWrapper: 'kfui-accordion-body-wrapper',
71
- isOpen: 'is-opened',
72
- progressBarStepLabel: 'step-label',
73
- left: 'float-left',
74
- right: 'float-right'
75
- }
76
- export const useCommonStyles = makeStyles({
77
- hintLabel: {
78
- color: tokens.colorNeutralForeground3,
79
- fontSize: tokens.fontSizeBase200,
80
- fontWeight: tokens.fontWeightRegular,
81
- lineHeight: tokens.lineHeightBase200
82
- },
83
- validationLabel: {
84
- color: tokens.colorPaletteRedForeground1,
85
- fontSize: tokens.fontSizeBase200,
86
- fontWeight: tokens.fontWeightRegular,
87
- lineHeight: tokens.lineHeightBase200
88
- },
89
- fullscreen: {
90
- position: "fixed",
91
- top: 0, bottom: 0, left: 0, right: 0,
92
- zIndex: 1,
93
- backgroundColor: tokens.colorNeutralBackground1,
94
- overflow: "auto",
95
- padding: tokens.spacingHorizontalL,
96
- paddingLeft: "20px",
97
- paddingRight: "20px"
98
- }
99
- });
100
-
101
- export const commonSizes = {
102
- widthMedium: 360,
103
- widthWide: 520,
104
- extraWidthWide: 820,
105
- }
@@ -1,91 +0,0 @@
1
- import { BrandVariants, Theme, createDarkTheme, createLightTheme, teamsDarkTheme, teamsLightTheme } from "@fluentui/react-components";
2
-
3
- export interface iThemeContext {
4
- teams?: boolean;
5
- dark?: boolean;
6
- }
7
-
8
- export function getTheme(ctx: iThemeContext, t: BrandVariants = kThemeDefault) {
9
- return ctx.dark
10
- ? getDarkTheme(ctx, t)
11
- : getLightTheme(ctx, t);
12
- }
13
-
14
-
15
- const kThemeDefault: BrandVariants = {
16
- 10: "#04010A",
17
- 20: "#16103B",
18
- 30: "#17176F",
19
- 40: "#0F1D9A",
20
- 50: "#2F2AA1",
21
- 60: "#4338A8",
22
- 70: "#5546AF",
23
- 80: "#6555B6",
24
- 90: "#7563BD",
25
- 100: "#8472C4",
26
- 110: "#9282CB",
27
- 120: "#A191D2",
28
- 130: "#AFA1D9",
29
- 140: "#BDB1E0",
30
- 150: "#CBC1E7",
31
- 160: "#D9D2EE"
32
- };
33
-
34
- const kThemeOrange: BrandVariants = {
35
- 10: "#040301",
36
- 20: "#1E170A",
37
- 30: "#312610",
38
- 40: "#403112",
39
- 50: "#503D14",
40
- 60: "#604915",
41
- 70: "#705516",
42
- 80: "#816216",
43
- 90: "#926E16",
44
- 100: "#A37B15",
45
- 110: "#B58914",
46
- 120: "#C79612",
47
- 130: "#DAA40E",
48
- 140: "#EDB208",
49
- 150: "#FFC001",
50
- 160: "#FFD47F"
51
- };
52
-
53
- const kThemeSecondary: BrandVariants = {
54
- 10: "#020304",
55
- 20: "#101A1D",
56
- 30: "#162B32",
57
- 40: "#1A3742",
58
- 50: "#1D4552",
59
- 60: "#1F5363",
60
- 70: "#216175",
61
- 80: "#227087",
62
- 90: "#227F9A",
63
- 100: "#208EAD",
64
- 110: "#1E9EC0",
65
- 120: "#1AADD4",
66
- 130: "#12BEE8",
67
- 140: "#02CEFD",
68
- 150: "#6BDAFF",
69
- 160: "#A0E5FF"
70
- };
71
-
72
- function getLightTheme(ctx: iThemeContext, t: BrandVariants = kThemeDefault) {
73
- if (ctx.teams) return teamsLightTheme;
74
- //return jsonClone(webLightTheme);
75
- const lightTheme: Theme = {
76
- ...createLightTheme(t),
77
- };
78
- return lightTheme;
79
- }
80
-
81
- function getDarkTheme(ctx: iThemeContext, t: BrandVariants = kThemeDefault) {
82
- if (ctx.teams) return teamsDarkTheme;
83
- //return jsonClone(webDarkTheme);
84
- const darkTheme: Theme = {
85
- ...createDarkTheme(t),
86
- };
87
-
88
- darkTheme.colorBrandForeground1 = t[110];
89
- darkTheme.colorBrandForeground2 = t[120];
90
- return darkTheme;
91
- }