@kwiz/fluentui 1.0.128 → 1.0.130
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/dropdown.d.ts +11 -5
- package/dist/controls/dropdown.js +21 -5
- package/dist/controls/dropdown.js.map +1 -1
- package/dist/controls/index.d.ts +1 -0
- package/dist/controls/index.js +1 -0
- package/dist/controls/index.js.map +1 -1
- package/dist/controls/tabs.d.ts +24 -0
- package/dist/controls/tabs.js +30 -0
- package/dist/controls/tabs.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { DropdownProps } from '@fluentui/react-components';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
type ForwardProps = Omit<DropdownProps, "onSelect" | "selectedOptions" | "clearable">;
|
|
4
|
-
interface
|
|
3
|
+
type ForwardProps = Omit<DropdownProps, "onSelect" | "selectedOptions" | "clearable" | "defaultSelectedOptions">;
|
|
4
|
+
interface iProps<keyType, dataType> extends ForwardProps {
|
|
5
5
|
required?: boolean;
|
|
6
|
-
selected: keyType | keyType[];
|
|
7
6
|
items: {
|
|
8
7
|
key: keyType;
|
|
9
8
|
value: string;
|
|
@@ -25,7 +24,14 @@ interface IProps<keyType, dataType> extends ForwardProps {
|
|
|
25
24
|
data?: dataType;
|
|
26
25
|
}[]) => void;
|
|
27
26
|
}
|
|
28
|
-
|
|
27
|
+
type tProps<keyType, dataType> = iProps<keyType, dataType> & ({
|
|
28
|
+
selected: keyType | keyType[];
|
|
29
|
+
defaultSelected?: never;
|
|
30
|
+
} | {
|
|
31
|
+
selected?: never;
|
|
32
|
+
defaultSelected: keyType | keyType[];
|
|
33
|
+
});
|
|
34
|
+
export declare const DropdownEX: <keyType extends string = string, dataType = never>(props: tProps<keyType, dataType> & React.RefAttributes<HTMLButtonElement>) => React.JSX.Element | null;
|
|
29
35
|
/** @deprecated use normal DropdownEX it is now generic */
|
|
30
|
-
export declare function getDropdownEX<keyType extends string = string, dataType = never>(): (props:
|
|
36
|
+
export declare function getDropdownEX<keyType extends string = string, dataType = never>(): (props: tProps<keyType, dataType> & React.RefAttributes<HTMLButtonElement>) => React.JSX.Element | null;
|
|
31
37
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Dropdown, makeStyles, mergeClasses, Option } from '@fluentui/react-components';
|
|
3
|
-
import { CommonLogger, filterEmptyEntries, firstOrNull, isNotEmptyArray, isNotEmptyString, isNullOrUndefined } from '@kwiz/common';
|
|
4
|
-
import React, { useMemo, useState } from 'react';
|
|
3
|
+
import { CommonLogger, filterEmptyEntries, firstOrNull, isNotEmptyArray, isNotEmptyString, isNullOrUndefined, isUndefined } from '@kwiz/common';
|
|
4
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
5
5
|
import { useKWIZFluentContext } from '../helpers/context-internal';
|
|
6
6
|
const logger = new CommonLogger("DropdownEX");
|
|
7
7
|
const useStyles = makeStyles({
|
|
@@ -17,11 +17,24 @@ const useStyles = makeStyles({
|
|
|
17
17
|
function $DropdownEX(props, ref) {
|
|
18
18
|
const classes = useStyles();
|
|
19
19
|
const ctx = useKWIZFluentContext();
|
|
20
|
-
const
|
|
20
|
+
const [isUnControlled, setIsUnControlled] = useState(!isUndefined(props.defaultSelected));
|
|
21
|
+
const __isUnControlled = !isUndefined(props.defaultSelected);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (__isUnControlled !== isUnControlled) {
|
|
24
|
+
logger.error(`A DropdownEX control was switched from controlled to uncontrolled mode. This is not supported.`);
|
|
25
|
+
setIsUnControlled(__isUnControlled);
|
|
26
|
+
if (!__isUnControlled) {
|
|
27
|
+
setUncontrolledSelected(props.selected);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}, [__isUnControlled, isUnControlled]);
|
|
31
|
+
const [uncontrolledSelected, setUncontrolledSelected] = useState(isUnControlled ? props.defaultSelected : props.selected);
|
|
32
|
+
const selectedValueToUse = isUnControlled ? uncontrolledSelected : props.selected;
|
|
33
|
+
const selected = Array.isArray(selectedValueToUse) ? selectedValueToUse : isNullOrUndefined(selectedValueToUse) ? [] : [selectedValueToUse];
|
|
21
34
|
//sometimes control will lose value when re-rendered
|
|
22
35
|
//use case: public forms when editing other fields after the dropdown was set
|
|
23
36
|
//re-set the text value manually to fix
|
|
24
|
-
let text = filterEmptyEntries((Array.isArray(
|
|
37
|
+
let text = filterEmptyEntries((Array.isArray(selectedValueToUse) ? selectedValueToUse : [selectedValueToUse]).map(s => {
|
|
25
38
|
let v = firstOrNull(props.items, i => i.key === s);
|
|
26
39
|
return v ? v.value : '';
|
|
27
40
|
})).join(', ');
|
|
@@ -49,10 +62,13 @@ function $DropdownEX(props, ref) {
|
|
|
49
62
|
let o = firstOrNull(props.items, i => i.key === data.optionValue);
|
|
50
63
|
if (props.multiselect) {
|
|
51
64
|
let current = data.selectedOptions.map(s => firstOrNull(props.items, i => i.key === s));
|
|
65
|
+
setUncontrolledSelected(current.map(o => o.key));
|
|
52
66
|
props.onSelect(o, current);
|
|
53
67
|
}
|
|
54
|
-
else
|
|
68
|
+
else {
|
|
69
|
+
setUncontrolledSelected(o.key);
|
|
55
70
|
props.onSelect(o);
|
|
71
|
+
}
|
|
56
72
|
}, children: items.map(i => _jsx(Option, { value: i.key, text: i.value, children: i.option ? i.option : i.value }, i.key)) })));
|
|
57
73
|
}
|
|
58
74
|
export const DropdownEX = React.forwardRef($DropdownEX);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.js","sourceRoot":"","sources":["../../src/controls/dropdown.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAiB,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACvG,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,cA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,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AAExD,0DAA0D;AAC1D,MAAM,UAAU,aAAa;IACzB,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,2EAA2E,CAAC,CAAC;IAC3F,OAAO,KAAK,CAAC,UAAU,CAAC,CAAA,WAA8B,CAAA,CAAC,CAAC;AAC5D,CAAC"}
|
package/dist/controls/index.d.ts
CHANGED
package/dist/controls/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/controls/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/controls/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TabListProps, TabProps } from "@fluentui/react-components";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { IStackProps } from "./stack";
|
|
4
|
+
interface iProps<keyType extends string> {
|
|
5
|
+
tabs: {
|
|
6
|
+
key: keyType;
|
|
7
|
+
title: string | JSX.Element;
|
|
8
|
+
children: ReactNode | JSX.Element;
|
|
9
|
+
props?: TabProps;
|
|
10
|
+
}[];
|
|
11
|
+
root?: TabListProps;
|
|
12
|
+
onSelect?: (value: keyType) => void;
|
|
13
|
+
/** default: {direction:"v"} */
|
|
14
|
+
container: IStackProps;
|
|
15
|
+
}
|
|
16
|
+
type tProps<keyType extends string> = iProps<keyType> & ({
|
|
17
|
+
selected: keyType;
|
|
18
|
+
defaultSelected?: never;
|
|
19
|
+
} | {
|
|
20
|
+
selected?: never;
|
|
21
|
+
defaultSelected: keyType;
|
|
22
|
+
});
|
|
23
|
+
export declare function TabsEX<keyType extends string>(props: tProps<keyType>): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Tab, TabList } from "@fluentui/react-components";
|
|
3
|
+
import { CommonLogger, firstOrNull, isUndefined } from "@kwiz/common";
|
|
4
|
+
import { useEffect, useMemo, useState } from "react";
|
|
5
|
+
import { Stack } from "./stack";
|
|
6
|
+
const logger = new CommonLogger("Tabs");
|
|
7
|
+
export function TabsEX(props) {
|
|
8
|
+
const [isUnControlled, setIsUnControlled] = useState(!isUndefined(props.defaultSelected));
|
|
9
|
+
const __isUnControlled = !isUndefined(props.defaultSelected);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (__isUnControlled !== isUnControlled) {
|
|
12
|
+
logger.error(`A TabsEX control was switched from controlled to uncontrolled mode. This is not supported.`);
|
|
13
|
+
setIsUnControlled(__isUnControlled);
|
|
14
|
+
if (!__isUnControlled) {
|
|
15
|
+
setUncontrolledSelected(props.selected);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}, [__isUnControlled, isUnControlled]);
|
|
19
|
+
const [uncontrolledSelected, setUncontrolledSelected] = useState(isUnControlled ? props.defaultSelected : props.selected);
|
|
20
|
+
const selectedValueToUse = isUnControlled ? uncontrolledSelected : props.selected;
|
|
21
|
+
const selectedTab = useMemo(() => {
|
|
22
|
+
return firstOrNull(props.tabs, t => t.key === selectedValueToUse);
|
|
23
|
+
}, [props.tabs, selectedValueToUse]);
|
|
24
|
+
return _jsxs(Stack, Object.assign({}, props.container || { direction: "v" }, { children: [_jsx(TabList, Object.assign({}, props.root, { selectedValue: selectedValueToUse, onTabSelect: (e, data) => {
|
|
25
|
+
var _a;
|
|
26
|
+
setUncontrolledSelected(data.value);
|
|
27
|
+
(_a = props.onSelect) === null || _a === void 0 ? void 0 : _a.call(props, data.value);
|
|
28
|
+
}, children: props.tabs.map(t => _jsx(Tab, { value: t.key, children: t.title }, t.key)) })), selectedTab === null || selectedTab === void 0 ? void 0 : selectedTab.children] }));
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=tabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.js","sourceRoot":"","sources":["../../src/controls/tabs.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,OAAO,EAA0B,MAAM,4BAA4B,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAa,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAe,KAAK,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;AAkBxC,MAAM,UAAU,MAAM,CAAyB,KAAsB;IACjE,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC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