@kwiz/fluentui 1.0.9 → 1.0.10
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/package.json
CHANGED
package/src/controls/button.tsx
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Button, ButtonProps, CompoundButton, compoundButtonClassNames, CompoundButtonProps, makeStyles, mergeClasses, tokens, Tooltip } from '@fluentui/react-components';
|
2
2
|
import { capitalizeFirstLetter, isFunction, isNullOrEmptyString, isNullOrUndefined, isString, PushNoDuplicate } from '@kwiz/common';
|
3
3
|
import React from 'react';
|
4
|
-
import {
|
4
|
+
import { useKWIZFluentContext } from '../helpers/context';
|
5
5
|
import { useCommonStyles, widthMedium } from '../styles/styles';
|
6
6
|
|
7
7
|
interface IProps {
|
@@ -105,7 +105,7 @@ export const ButtonEX = React.forwardRef<HTMLButtonElement, (ButtonEXProps)>((pr
|
|
105
105
|
);
|
106
106
|
});
|
107
107
|
export const ButtonEXSecondary = React.forwardRef<HTMLButtonElement, (ButtonEXProps)>((props, ref) => {
|
108
|
-
const ctx =
|
108
|
+
const ctx = useKWIZFluentContext();
|
109
109
|
return (
|
110
110
|
<ButtonEX ref={ref} appearance='secondary' shape={ctx.buttonShape} {...props}></ButtonEX>
|
111
111
|
);
|
@@ -152,7 +152,7 @@ export const CompoundButtonEX = React.forwardRef<HTMLButtonElement, (CompoundBut
|
|
152
152
|
);
|
153
153
|
});
|
154
154
|
export const CompoundButtonEXSecondary = React.forwardRef<HTMLButtonElement, (CompoundButtonEXProps)>((props, ref) => {
|
155
|
-
const ctx =
|
155
|
+
const ctx = useKWIZFluentContext();
|
156
156
|
return (
|
157
157
|
<CompoundButtonEX ref={ref} appearance='secondary' shape={ctx.buttonShape} {...props}></CompoundButtonEX>
|
158
158
|
);
|
package/src/controls/date.tsx
CHANGED
@@ -2,7 +2,7 @@ import { DatePicker, DatePickerProps } from '@fluentui/react-datepicker-compat';
|
|
2
2
|
import { CalendarCancelRegular } from '@fluentui/react-icons';
|
3
3
|
import { isDate, isFunction, isNullOrEmptyString } from '@kwiz/common';
|
4
4
|
import * as React from 'react';
|
5
|
-
import {
|
5
|
+
import { useKWIZFluentContext } from '../helpers/context';
|
6
6
|
|
7
7
|
|
8
8
|
interface IProps extends DatePickerProps {
|
@@ -10,7 +10,7 @@ interface IProps extends DatePickerProps {
|
|
10
10
|
onCancel?: () => void;
|
11
11
|
}
|
12
12
|
export const DatePickerEx: React.FunctionComponent<React.PropsWithChildren<IProps>> = (props) => {
|
13
|
-
const ctx =
|
13
|
+
const ctx = useKWIZFluentContext();
|
14
14
|
const [showClear, setShowClear] = React.useState(isDate(props.value));
|
15
15
|
const reset = React.useCallback(() => {
|
16
16
|
setShowClear(false);
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Dropdown, DropdownProps, Option } from '@fluentui/react-components';
|
2
2
|
import { filterEmptyEntries, firstOrNull, isNullOrUndefined } from '@kwiz/common';
|
3
3
|
import React from 'react';
|
4
|
-
import {
|
4
|
+
import { useKWIZFluentContext } from '../helpers/context';
|
5
5
|
|
6
6
|
type ForwardProps = Omit<DropdownProps, "onSelect" | "selectedOptions" | "clearable">;
|
7
7
|
|
@@ -21,7 +21,7 @@ interface IProps<dataType, keyType extends string = string> extends ForwardProps
|
|
21
21
|
}
|
22
22
|
|
23
23
|
function $DropdownEX<keyType extends string = string, dataType = never>(props: IProps<dataType, keyType>, ref: React.ForwardedRef<HTMLButtonElement>) {
|
24
|
-
const ctx =
|
24
|
+
const ctx = useKWIZFluentContext();
|
25
25
|
const selected: keyType[] = Array.isArray(props.selected) ? props.selected : isNullOrUndefined(props.selected) ? [] : [props.selected];
|
26
26
|
|
27
27
|
//sometimes control will lose value when re-rendered
|
package/src/controls/input.tsx
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { GriffelStyle, Input, InputProps, makeStyles, mergeClasses, Textarea, TextareaProps } from '@fluentui/react-components';
|
2
2
|
import { isFunction } from '@kwiz/common';
|
3
3
|
import React from 'react';
|
4
|
-
import {
|
4
|
+
import { useKWIZFluentContext } from '../helpers/context';
|
5
5
|
|
6
6
|
|
7
7
|
interface IProps extends InputProps {
|
@@ -9,7 +9,7 @@ interface IProps extends InputProps {
|
|
9
9
|
onCancel?: () => void;
|
10
10
|
}
|
11
11
|
export const InputEx: React.FunctionComponent<React.PropsWithChildren<IProps>> = (props) => {
|
12
|
-
const ctx =
|
12
|
+
const ctx = useKWIZFluentContext();
|
13
13
|
return (
|
14
14
|
<Input appearance={ctx.inputAppearance} {...props}
|
15
15
|
onKeyDown={isFunction(props.onOK) || isFunction(props.onCancel)
|
package/src/controls/prompt.tsx
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Dialog, DialogActions, DialogBody, DialogContent, DialogSurface, DialogTitle, DialogTrigger } from '@fluentui/react-components';
|
2
2
|
import { isNullOrEmptyString } from '@kwiz/common';
|
3
3
|
import React from 'react';
|
4
|
-
import {
|
4
|
+
import { useKWIZFluentContext } from '../helpers/context';
|
5
5
|
import { ButtonEXProps, ButtonEXSecondary } from './button';
|
6
6
|
|
7
7
|
export interface IPrompterProps {
|
@@ -18,7 +18,7 @@ export interface IPrompterProps {
|
|
18
18
|
children?: JSX.Element;
|
19
19
|
}
|
20
20
|
export const Prompter: React.FunctionComponent<React.PropsWithChildren<IPrompterProps>> = (props) => {
|
21
|
-
const ctx =
|
21
|
+
const ctx = useKWIZFluentContext();
|
22
22
|
|
23
23
|
let okProps: ButtonEXProps = {
|
24
24
|
...(props.okButtonProps as any || {}),
|
package/src/helpers/context.ts
CHANGED
@@ -29,7 +29,7 @@ export interface iKWIZFluentContext {
|
|
29
29
|
//create context
|
30
30
|
export const KWIZFluentContext = React.createContext<iKWIZFluentContext>(null);
|
31
31
|
//use context from within controls
|
32
|
-
export function
|
32
|
+
export function useKWIZFluentContext() {
|
33
33
|
let ctx = React.useContext(KWIZFluentContext) || {};
|
34
34
|
//set defaults
|
35
35
|
if (isNullOrUndefined(ctx.inputAppearance))
|