@kwiz/fluentui 1.0.73 → 1.0.75

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 (92) hide show
  1. package/.github/workflows/npm-publish.yml +24 -24
  2. package/LICENSE +21 -21
  3. package/README.md +53 -53
  4. package/dist/@types/forwardRef.d.ts +0 -0
  5. package/dist/@types/forwardRef.js +1 -0
  6. package/dist/@types/forwardRef.js.map +1 -0
  7. package/dist/controls/error-boundary copy.d.ts +23 -0
  8. package/dist/controls/error-boundary copy.js +33 -0
  9. package/dist/controls/error-boundary copy.js.map +1 -0
  10. package/dist/controls/menu.js +2 -2
  11. package/dist/controls/menu.js.map +1 -1
  12. package/dist/controls/search.js +19 -11
  13. package/dist/controls/search.js.map +1 -1
  14. package/dist/controls/svg.js +21 -21
  15. package/dist/controls/svg.js.map +1 -1
  16. package/dist/helpers/common.d.ts +4 -0
  17. package/dist/helpers/common.js +2 -0
  18. package/dist/helpers/common.js.map +1 -0
  19. package/dist/helpers/context.d.ts +26 -0
  20. package/dist/helpers/context.js +15 -0
  21. package/dist/helpers/context.js.map +1 -0
  22. package/dist/helpers/drag-drop/exports.d.ts +12 -0
  23. package/dist/helpers/drag-drop/exports.js +3 -0
  24. package/dist/helpers/drag-drop/exports.js.map +1 -0
  25. package/dist/helpers/exports.d.ts +7 -0
  26. package/dist/helpers/exports.js +8 -0
  27. package/dist/helpers/exports.js.map +1 -0
  28. package/dist/helpers/use-editable-control.d.ts +1 -1
  29. package/dist/helpers/use-editable-control.js.map +1 -1
  30. package/package.json +85 -84
  31. package/src/_modules/config.ts +9 -9
  32. package/src/_modules/constants.ts +3 -3
  33. package/src/controls/ColorPickerDialog.tsx +83 -83
  34. package/src/controls/accordion.tsx +62 -62
  35. package/src/controls/button.tsx +180 -180
  36. package/src/controls/canvas/CustomEventTargetBase.ts +32 -32
  37. package/src/controls/canvas/DrawPad.tsx +296 -296
  38. package/src/controls/canvas/DrawPadManager.ts +694 -694
  39. package/src/controls/canvas/bezier.ts +109 -109
  40. package/src/controls/canvas/point.ts +44 -44
  41. package/src/controls/card-list.tsx +31 -31
  42. package/src/controls/card.tsx +77 -77
  43. package/src/controls/centered.tsx +14 -14
  44. package/src/controls/date.tsx +87 -87
  45. package/src/controls/diagram-picker.tsx +96 -96
  46. package/src/controls/divider.tsx +15 -15
  47. package/src/controls/dropdown.tsx +66 -66
  48. package/src/controls/error-boundary.tsx +41 -41
  49. package/src/controls/field-editor.tsx +42 -42
  50. package/src/controls/file-upload.tsx +155 -155
  51. package/src/controls/horizontal.tsx +48 -48
  52. package/src/controls/html-editor/editor.tsx +182 -182
  53. package/src/controls/index.ts +33 -33
  54. package/src/controls/input.tsx +160 -160
  55. package/src/controls/kwizoverflow.tsx +106 -106
  56. package/src/controls/list.tsx +119 -119
  57. package/src/controls/loading.tsx +10 -10
  58. package/src/controls/menu.tsx +173 -173
  59. package/src/controls/merge-text.tsx +126 -126
  60. package/src/controls/please-wait.tsx +32 -32
  61. package/src/controls/progress-bar.tsx +109 -109
  62. package/src/controls/prompt.tsx +121 -121
  63. package/src/controls/qrcode.tsx +36 -36
  64. package/src/controls/search.tsx +71 -61
  65. package/src/controls/section.tsx +133 -133
  66. package/src/controls/svg.tsx +138 -138
  67. package/src/controls/toolbar.tsx +46 -46
  68. package/src/controls/vertical-content.tsx +49 -49
  69. package/src/controls/vertical.tsx +42 -42
  70. package/src/helpers/block-nav.tsx +88 -88
  71. package/src/helpers/context-const.ts +29 -29
  72. package/src/helpers/context-export.tsx +77 -77
  73. package/src/helpers/context-internal.ts +13 -13
  74. package/src/helpers/drag-drop/drag-drop-container.tsx +53 -53
  75. package/src/helpers/drag-drop/drag-drop-context-internal.tsx +9 -9
  76. package/src/helpers/drag-drop/drag-drop-context.tsx +61 -61
  77. package/src/helpers/drag-drop/drag-drop.types.ts +21 -21
  78. package/src/helpers/drag-drop/index.ts +12 -12
  79. package/src/helpers/drag-drop/readme.md +75 -75
  80. package/src/helpers/drag-drop/use-draggable.ts +47 -47
  81. package/src/helpers/drag-drop/use-droppable.ts +38 -38
  82. package/src/helpers/forwardRef.ts +7 -7
  83. package/src/helpers/hooks-events.ts +149 -149
  84. package/src/helpers/hooks.tsx +141 -141
  85. package/src/helpers/index.ts +8 -8
  86. package/src/helpers/use-alerts.tsx +74 -74
  87. package/src/helpers/use-editable-control.tsx +37 -37
  88. package/src/helpers/use-toast.tsx +29 -29
  89. package/src/index.ts +2 -2
  90. package/src/styles/index.ts +1 -1
  91. package/src/styles/styles.ts +104 -104
  92. package/src/styles/theme.ts +90 -90
@@ -1,182 +1,182 @@
1
- import { makeStyles, tokens } from '@fluentui/react-components';
2
- import { ArrowMaximize16Regular, ArrowMinimize16Regular, Dismiss16Regular, Save16Regular } from '@fluentui/react-icons';
3
- import { isObject } from '@kwiz/common';
4
- import JoditEditor, { Jodit } from "jodit-react";
5
- import React, { useRef } from 'react';
6
- import { ButtonEX, ButtonEXProps } from '../button';
7
- import { Section } from '../section';
8
- import { IconToSVG } from '../svg';
9
-
10
- //const logger = GetLogger("html-editor");
11
-
12
- const useStyles = makeStyles({
13
- htmlDiv: {
14
- border: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStrokeAccessible}`,
15
- padding: tokens.spacingHorizontalS,
16
- minHeight: `100px`
17
- }
18
- });
19
-
20
- interface IProps {
21
- value?: string;
22
- /** get notified as soon as user is out of the control */
23
- onChange?: (value: string) => void;
24
- /** add a save button and get the value once the user clicks save, close the editor after */
25
- onSave?: (value: string) => void;
26
- /** add a cancel button to close this editor */
27
- onCancel?: () => void;
28
- readonly?: boolean;
29
- css?: string[];
30
- /** render a smaller toolbar */
31
- smallToolbar?: boolean;
32
- /** show a div, click on it to render the editor */
33
- editOnDemand?: boolean;
34
-
35
- /** all designers */
36
- kitchensink?: boolean;
37
- speech?: boolean;
38
- spellcheck?: boolean;
39
- table?: boolean;
40
- media?: boolean;
41
- source?: boolean;
42
- /**
43
- * true: render the control in full screen
44
- * button: render only a button that opens the editor in full screen
45
- */
46
- fullScreen?: boolean | ButtonEXProps;
47
- }
48
- type JoditExpanded = Jodit & {//& IViewBased<IViewOptions>
49
- //value: string;
50
- kwizInstance: {
51
- props: IProps,
52
- setShowFullScreen: (value: boolean) => void;
53
- }
54
- };
55
-
56
- const saveIcon = IconToSVG(<Save16Regular title='Save' />);
57
- const cancelIcon = IconToSVG(<Dismiss16Regular title='Cancel' />);
58
- const maxIcon = IconToSVG(<ArrowMaximize16Regular title='Maximize' />);
59
- const minIcon = IconToSVG(<ArrowMinimize16Regular title='Minimize' />);
60
- export const HtmlEditor: React.FunctionComponent<React.PropsWithChildren<IProps>> = (props) => {
61
- const classes = useStyles();
62
- const [active, setActive] = React.useState(false);
63
- const [showFullScreen, setShowFullScreen] = React.useState(false);
64
-
65
-
66
- //quill react demos: https://codesandbox.io/examples/package/react-quill
67
- const editorRef = useRef<JoditExpanded>(null);
68
-
69
- const extraConfig = {
70
- uploader: {
71
- insertImageAsBase64URI: true,
72
- toolbarStickyOffset: 30,
73
- },
74
- autofocus: props.editOnDemand || showFullScreen,
75
- };
76
-
77
- const fullScreenButton = isObject(props.fullScreen) ? props.fullScreen as ButtonEXProps : null;
78
-
79
- const options = props.kitchensink ? {
80
- speech: true,
81
- spellcheck: true,
82
- table: true,
83
- media: true,
84
- source: true,
85
- fullScreen: true
86
- } : props
87
-
88
-
89
- Jodit.defaultOptions.controls.save = {
90
- template: () => saveIcon,
91
- exec: (view: JoditExpanded) => {
92
- view.kwizInstance.props.onChange?.(view.value);
93
- view.kwizInstance.props.onSave?.(view.value);
94
- view.kwizInstance.setShowFullScreen(false);
95
- }
96
- };
97
- Jodit.defaultOptions.controls.cancel = {
98
- template: () => cancelIcon,
99
- exec: (view: JoditExpanded) => {
100
- view.kwizInstance.props.onCancel?.();
101
- view.kwizInstance.setShowFullScreen(false);
102
- }
103
- };
104
- Jodit.defaultOptions.controls.maximize = {
105
- template: () => maxIcon,
106
- exec: (view: JoditExpanded) => {
107
- view.kwizInstance.props.onChange?.(view.value);//pass value from smaller editor to bigger one
108
- view.kwizInstance.setShowFullScreen(true);
109
- }
110
- };
111
- Jodit.defaultOptions.controls.minimize = {
112
- template: () => minIcon,
113
- exec: (view: JoditExpanded) => {
114
- view.kwizInstance.props.onChange?.(view.value);
115
- view.kwizInstance.setShowFullScreen(false);
116
- }
117
- };
118
-
119
- const minimalToolbar = !showFullScreen && options.fullScreen;
120
- const buttons = (minimalToolbar
121
- ? `${props.onSave && 'save,'}${props.onCancel && 'cancel,'}maximize,bold,ul,ol`//inline, with full screen option - show very minimal toolbar
122
- : `${props.onSave && 'save,'}${props.onCancel && 'cancel,'}${options.fullScreen && (showFullScreen
123
- ? fullScreenButton ? 'save,' : 'minimize,'//when in full screen, if we don't have a small editor but just a button - change the minimize button to save&close button
124
- : 'maximize,')}${(props.onSave || props.onCancel || options.fullScreen) && '|,'}bold,italic,underline,strikethrough,|,ul,ol,font,fontsize,paragraph,lineHeight,superscript,subscript,copyformat,brush,eraser,|,${options.media && 'image,video,'}${options.spellcheck && 'spellcheck,'}${options.speech && 'speechRecognize,'}hr,${options.table && 'table,'}link,indent,outdent,${options.source && '---,source,'}`)
125
- .replace(/undefined/g, '');
126
- const removeButtons: string[] = minimalToolbar
127
- //some buttons must be explicitly removed
128
- ? ["strikethrough", "italic", "eraser", "font", "fontsize", "paragraph", "lineHeight", "brush", "underline"]
129
- : undefined;
130
-
131
- const config = {
132
- ...extraConfig,
133
- readonly: props.readonly,
134
- inline: true,
135
- statusbar: false,
136
- toolbarButtonSize: props.smallToolbar ? "xsmall" : "middle",
137
- buttons, removeButtons,
138
- toolbarAdaptive: !minimalToolbar,
139
- // events: {
140
- // afterInit: (view: IViewBasedExpanded) => {
141
- // view.kwizInstance = {
142
- // props: props,
143
- // setShowFullScreen: setShowFullScreen
144
- // };
145
- // }
146
- // }
147
- };
148
- const editorElement = <JoditEditor key={"the-editor"}
149
- {...({
150
- editorRef: (view: JoditExpanded) => {
151
- //expand it for toolbar buttons
152
- view.kwizInstance = {
153
- props: props,
154
- setShowFullScreen: setShowFullScreen
155
- };
156
- editorRef.current = view;
157
- }
158
- })}
159
- value={props.value || ""}
160
- config={{ ...config as any }}
161
- onBlur={newContent => {
162
- props.onChange?.(newContent);
163
- setActive(false);
164
- }} // preferred to use only this option to update the content for performance reasons
165
- //onChange={newContent => { }}
166
- />;
167
-
168
- return (showFullScreen
169
- ? <Section fullscreen="portal">
170
- {editorElement}
171
- </Section>
172
- : fullScreenButton
173
- ? <ButtonEX {...fullScreenButton} onClick={() => {
174
- setShowFullScreen(true);
175
- }} />
176
- : props.editOnDemand && !active
177
- ? <div className={classes.htmlDiv} dangerouslySetInnerHTML={{ __html: props.value || "" }}
178
- tabIndex={0} onFocus={() => setActive(true)}
179
- onClick={() => setActive(true)} />
180
- : editorElement
181
- );
182
- }
1
+ import { makeStyles, tokens } from '@fluentui/react-components';
2
+ import { ArrowMaximize16Regular, ArrowMinimize16Regular, Dismiss16Regular, Save16Regular } from '@fluentui/react-icons';
3
+ import { isObject } from '@kwiz/common';
4
+ import JoditEditor, { Jodit } from "jodit-react";
5
+ import React, { useRef } from 'react';
6
+ import { ButtonEX, ButtonEXProps } from '../button';
7
+ import { Section } from '../section';
8
+ import { IconToSVG } from '../svg';
9
+
10
+ //const logger = GetLogger("html-editor");
11
+
12
+ const useStyles = makeStyles({
13
+ htmlDiv: {
14
+ border: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStrokeAccessible}`,
15
+ padding: tokens.spacingHorizontalS,
16
+ minHeight: `100px`
17
+ }
18
+ });
19
+
20
+ interface IProps {
21
+ value?: string;
22
+ /** get notified as soon as user is out of the control */
23
+ onChange?: (value: string) => void;
24
+ /** add a save button and get the value once the user clicks save, close the editor after */
25
+ onSave?: (value: string) => void;
26
+ /** add a cancel button to close this editor */
27
+ onCancel?: () => void;
28
+ readonly?: boolean;
29
+ css?: string[];
30
+ /** render a smaller toolbar */
31
+ smallToolbar?: boolean;
32
+ /** show a div, click on it to render the editor */
33
+ editOnDemand?: boolean;
34
+
35
+ /** all designers */
36
+ kitchensink?: boolean;
37
+ speech?: boolean;
38
+ spellcheck?: boolean;
39
+ table?: boolean;
40
+ media?: boolean;
41
+ source?: boolean;
42
+ /**
43
+ * true: render the control in full screen
44
+ * button: render only a button that opens the editor in full screen
45
+ */
46
+ fullScreen?: boolean | ButtonEXProps;
47
+ }
48
+ type JoditExpanded = Jodit & {//& IViewBased<IViewOptions>
49
+ //value: string;
50
+ kwizInstance: {
51
+ props: IProps,
52
+ setShowFullScreen: (value: boolean) => void;
53
+ }
54
+ };
55
+
56
+ const saveIcon = IconToSVG(<Save16Regular title='Save' />);
57
+ const cancelIcon = IconToSVG(<Dismiss16Regular title='Cancel' />);
58
+ const maxIcon = IconToSVG(<ArrowMaximize16Regular title='Maximize' />);
59
+ const minIcon = IconToSVG(<ArrowMinimize16Regular title='Minimize' />);
60
+ export const HtmlEditor: React.FunctionComponent<React.PropsWithChildren<IProps>> = (props) => {
61
+ const classes = useStyles();
62
+ const [active, setActive] = React.useState(false);
63
+ const [showFullScreen, setShowFullScreen] = React.useState(false);
64
+
65
+
66
+ //quill react demos: https://codesandbox.io/examples/package/react-quill
67
+ const editorRef = useRef<JoditExpanded>(null);
68
+
69
+ const extraConfig = {
70
+ uploader: {
71
+ insertImageAsBase64URI: true,
72
+ toolbarStickyOffset: 30,
73
+ },
74
+ autofocus: props.editOnDemand || showFullScreen,
75
+ };
76
+
77
+ const fullScreenButton = isObject(props.fullScreen) ? props.fullScreen as ButtonEXProps : null;
78
+
79
+ const options = props.kitchensink ? {
80
+ speech: true,
81
+ spellcheck: true,
82
+ table: true,
83
+ media: true,
84
+ source: true,
85
+ fullScreen: true
86
+ } : props
87
+
88
+
89
+ Jodit.defaultOptions.controls.save = {
90
+ template: () => saveIcon,
91
+ exec: (view: JoditExpanded) => {
92
+ view.kwizInstance.props.onChange?.(view.value);
93
+ view.kwizInstance.props.onSave?.(view.value);
94
+ view.kwizInstance.setShowFullScreen(false);
95
+ }
96
+ };
97
+ Jodit.defaultOptions.controls.cancel = {
98
+ template: () => cancelIcon,
99
+ exec: (view: JoditExpanded) => {
100
+ view.kwizInstance.props.onCancel?.();
101
+ view.kwizInstance.setShowFullScreen(false);
102
+ }
103
+ };
104
+ Jodit.defaultOptions.controls.maximize = {
105
+ template: () => maxIcon,
106
+ exec: (view: JoditExpanded) => {
107
+ view.kwizInstance.props.onChange?.(view.value);//pass value from smaller editor to bigger one
108
+ view.kwizInstance.setShowFullScreen(true);
109
+ }
110
+ };
111
+ Jodit.defaultOptions.controls.minimize = {
112
+ template: () => minIcon,
113
+ exec: (view: JoditExpanded) => {
114
+ view.kwizInstance.props.onChange?.(view.value);
115
+ view.kwizInstance.setShowFullScreen(false);
116
+ }
117
+ };
118
+
119
+ const minimalToolbar = !showFullScreen && options.fullScreen;
120
+ const buttons = (minimalToolbar
121
+ ? `${props.onSave && 'save,'}${props.onCancel && 'cancel,'}maximize,bold,ul,ol`//inline, with full screen option - show very minimal toolbar
122
+ : `${props.onSave && 'save,'}${props.onCancel && 'cancel,'}${options.fullScreen && (showFullScreen
123
+ ? fullScreenButton ? 'save,' : 'minimize,'//when in full screen, if we don't have a small editor but just a button - change the minimize button to save&close button
124
+ : 'maximize,')}${(props.onSave || props.onCancel || options.fullScreen) && '|,'}bold,italic,underline,strikethrough,|,ul,ol,font,fontsize,paragraph,lineHeight,superscript,subscript,copyformat,brush,eraser,|,${options.media && 'image,video,'}${options.spellcheck && 'spellcheck,'}${options.speech && 'speechRecognize,'}hr,${options.table && 'table,'}link,indent,outdent,${options.source && '---,source,'}`)
125
+ .replace(/undefined/g, '');
126
+ const removeButtons: string[] = minimalToolbar
127
+ //some buttons must be explicitly removed
128
+ ? ["strikethrough", "italic", "eraser", "font", "fontsize", "paragraph", "lineHeight", "brush", "underline"]
129
+ : undefined;
130
+
131
+ const config = {
132
+ ...extraConfig,
133
+ readonly: props.readonly,
134
+ inline: true,
135
+ statusbar: false,
136
+ toolbarButtonSize: props.smallToolbar ? "xsmall" : "middle",
137
+ buttons, removeButtons,
138
+ toolbarAdaptive: !minimalToolbar,
139
+ // events: {
140
+ // afterInit: (view: IViewBasedExpanded) => {
141
+ // view.kwizInstance = {
142
+ // props: props,
143
+ // setShowFullScreen: setShowFullScreen
144
+ // };
145
+ // }
146
+ // }
147
+ };
148
+ const editorElement = <JoditEditor key={"the-editor"}
149
+ {...({
150
+ editorRef: (view: JoditExpanded) => {
151
+ //expand it for toolbar buttons
152
+ view.kwizInstance = {
153
+ props: props,
154
+ setShowFullScreen: setShowFullScreen
155
+ };
156
+ editorRef.current = view;
157
+ }
158
+ })}
159
+ value={props.value || ""}
160
+ config={{ ...config as any }}
161
+ onBlur={newContent => {
162
+ props.onChange?.(newContent);
163
+ setActive(false);
164
+ }} // preferred to use only this option to update the content for performance reasons
165
+ //onChange={newContent => { }}
166
+ />;
167
+
168
+ return (showFullScreen
169
+ ? <Section fullscreen="portal">
170
+ {editorElement}
171
+ </Section>
172
+ : fullScreenButton
173
+ ? <ButtonEX {...fullScreenButton} onClick={() => {
174
+ setShowFullScreen(true);
175
+ }} />
176
+ : props.editOnDemand && !active
177
+ ? <div className={classes.htmlDiv} dangerouslySetInnerHTML={{ __html: props.value || "" }}
178
+ tabIndex={0} onFocus={() => setActive(true)}
179
+ onClick={() => setActive(true)} />
180
+ : editorElement
181
+ );
182
+ }
@@ -1,33 +1,33 @@
1
- export * from './accordion';
2
- export * from './button';
3
- export * from './canvas/DrawPad';
4
- export * from './card';
5
- export * from './card-list';
6
- export * from './centered';
7
- export * from './ColorPickerDialog';
8
- export * from './date';
9
- export * from './diagram-picker';
10
- export * from './divider';
11
- export * from './dropdown';
12
- export * from './error-boundary';
13
- export * from './field-editor';
14
- export * from './file-upload';
15
- export * from './horizontal';
16
- export * from './html-editor/editor';
17
- export * from './input';
18
- export * from './kwizoverflow';
19
- export * from './list';
20
- export * from './loading';
21
- export * from './menu';
22
- export * from './merge-text';
23
- export * from './please-wait';
24
- export * from './progress-bar';
25
- export * from './prompt';
26
- export * from './qrcode';
27
- export * from './search';
28
- export * from './section';
29
- export * from './svg';
30
- export * from './toolbar';
31
- export * from './vertical';
32
- export * from './vertical-content';
33
-
1
+ export * from './accordion';
2
+ export * from './button';
3
+ export * from './canvas/DrawPad';
4
+ export * from './card';
5
+ export * from './card-list';
6
+ export * from './centered';
7
+ export * from './ColorPickerDialog';
8
+ export * from './date';
9
+ export * from './diagram-picker';
10
+ export * from './divider';
11
+ export * from './dropdown';
12
+ export * from './error-boundary';
13
+ export * from './field-editor';
14
+ export * from './file-upload';
15
+ export * from './horizontal';
16
+ export * from './html-editor/editor';
17
+ export * from './input';
18
+ export * from './kwizoverflow';
19
+ export * from './list';
20
+ export * from './loading';
21
+ export * from './menu';
22
+ export * from './merge-text';
23
+ export * from './please-wait';
24
+ export * from './progress-bar';
25
+ export * from './prompt';
26
+ export * from './qrcode';
27
+ export * from './search';
28
+ export * from './section';
29
+ export * from './svg';
30
+ export * from './toolbar';
31
+ export * from './vertical';
32
+ export * from './vertical-content';
33
+