@5ive-souls/controls 0.0.1 → 0.0.3

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 (59) hide show
  1. package/dist/5ive-souls-controls-0.0.3.tgz +0 -0
  2. package/dist/Section-Bw_kuHpK.js +754 -0
  3. package/dist/components/ClassNames.js +7 -0
  4. package/dist/components/DynamicForm/Builder/DynamicFormBuilder.js +64 -0
  5. package/dist/components/DynamicForm/Builder/Field/FieldBuilder.js +53 -0
  6. package/dist/components/DynamicForm/Builder/Section/SectionBuilder.js +16 -0
  7. package/dist/components/DynamicForm/Builder/index.js +8 -0
  8. package/dist/components/DynamicForm/DynamicForm.js +197 -0
  9. package/dist/components/DynamicForm/Interfaces/IField.js +0 -0
  10. package/dist/components/DynamicForm/Interfaces/IFieldGroup.js +0 -0
  11. package/dist/components/DynamicForm/Interfaces/IFormMetaData.js +0 -0
  12. package/dist/components/DynamicForm/Interfaces/IFormSection.js +0 -0
  13. package/dist/components/DynamicForm/Interfaces/index.js +0 -0
  14. package/dist/components/DynamicForm/index.js +10 -0
  15. package/dist/components/FiveSoulsProvider/FiveSouls.Types.js +4 -0
  16. package/dist/components/FiveSoulsProvider/FiveSoulsProvider.js +20 -0
  17. package/dist/components/FiveSoulsProvider/deviceContext.js +5 -0
  18. package/dist/components/FiveSoulsProvider/index.js +10 -0
  19. package/dist/components/FiveSoulsProvider/useDevice.js +10 -0
  20. package/dist/components/FlexBox/FlexBox.js +75 -0
  21. package/dist/components/FlexBox/FlexBoxItem/FlexBoxItem.js +15 -0
  22. package/dist/components/FlexBox/FlexBoxItem/index.js +4 -0
  23. package/dist/components/FlexBox/FlexBoxItemResizer/FlexBoxItemResizer.js +80 -0
  24. package/dist/components/FlexBox/FlexBoxItemResizer/index.js +4 -0
  25. package/dist/components/FlexBox/FlexBoxUtils.js +13 -0
  26. package/dist/components/FlexBox/ResizeUtils.js +31 -0
  27. package/dist/components/FlexBox/index.js +8 -0
  28. package/dist/components/Grid/Grid.js +97 -0
  29. package/dist/components/Grid/GridCell/GridCell.js +16 -0
  30. package/dist/components/Grid/GridCell/index.js +4 -0
  31. package/dist/components/Grid/GridContext.js +5 -0
  32. package/dist/components/Grid/GridUtils.js +10 -0
  33. package/dist/components/Grid/ResizableGridCell/ResizableGridCell.js +72 -0
  34. package/dist/components/Grid/ResizableGridCell/index.js +4 -0
  35. package/dist/components/Grid/index.js +12 -0
  36. package/dist/components/IComponentProps.js +0 -0
  37. package/dist/components/JumpList/JumpList.js +178 -0
  38. package/dist/components/JumpList/index.js +4 -0
  39. package/dist/components/RichText/RichText.js +32 -0
  40. package/dist/components/RichText/index.js +4 -0
  41. package/dist/components/Section/Section.js +12 -0
  42. package/dist/components/Section/SectionUtils.js +15 -0
  43. package/dist/components/Section/index.js +4 -0
  44. package/dist/components/ThemePicker/ThemePicker.js +92 -0
  45. package/dist/components/ThemePicker/Themes/Cornflower/Cornflower.js +32 -0
  46. package/dist/components/ThemePicker/Themes/Crimson/Crimson.js +32 -0
  47. package/dist/components/ThemePicker/Themes/Forest/Forest.js +32 -0
  48. package/dist/components/ThemePicker/Themes/Royal/Royal.js +32 -0
  49. package/dist/components/ThemePicker/Themes/index.js +18 -0
  50. package/dist/components/ThemePicker/index.js +20 -0
  51. package/dist/components/Wizard/Wizard.js +99 -0
  52. package/dist/components/Wizard/WizardPanel/WizardPanel.js +14 -0
  53. package/dist/components/Wizard/WizardPanel/index.js +4 -0
  54. package/dist/components/Wizard/index.js +6 -0
  55. package/dist/components/index.js +61 -0
  56. package/dist/createFluentIcon-CwLxkjIW.js +503 -0
  57. package/dist/main.d.ts +637 -0
  58. package/dist/main.js +61 -0
  59. package/package.json +75 -64
@@ -0,0 +1,7 @@
1
+ const t = class t {
2
+ };
3
+ t.FlexBox = "5s-flex-box", t.FlexBoxItem = "5s-flex-box-item", t.FlexBoxItemResizer = "5s-flex-box-item-resizer", t.Section = "5s-section", t.SectionHeader = "5s-section-header", t.SectionContent = "5s-section-content", t.Wizard = "5s-wizard", t.WizardPanel = "5s-wizard-panel", t.DynamicForm = "5s-dynamic-form", t.FormField = "5s-form-field", t.FormFieldGroup = "5s-form-field-group", t.ThemePicker = "5s-theme-picker", t.RichText = "5s-rich-text", t.Grid = "_5s-grid", t.GridCell = "5s-grid-cell", t.GridCellResizer = "5s-grid-cell-resizer", t.JumpList = "5s-jl", t.JumpListMenu = "5s-jlm", t.JumpListHeader = "5s-jlh", t.JumpListItem = "5s-jli";
4
+ let i = t;
5
+ export {
6
+ i as ClassNames
7
+ };
@@ -0,0 +1,64 @@
1
+ import { SectionBuilder as s } from "./Section/SectionBuilder.js";
2
+ import { FieldBuilder as l } from "./Field/FieldBuilder.js";
3
+ class e {
4
+ // #endregion
5
+ // #region Constructor
6
+ constructor(i) {
7
+ this._defaultValues = {}, this._formData = {
8
+ title: i,
9
+ sections: [],
10
+ results: this._defaultValues
11
+ };
12
+ }
13
+ // #endregion
14
+ // #region Public Properties
15
+ get Section() {
16
+ if (!this._sectionBuilder)
17
+ throw new Error("You must call AddSection before you can access the SectionBuilder");
18
+ return this._sectionBuilder;
19
+ }
20
+ get Field() {
21
+ if (!this._fieldBuilder)
22
+ throw new Error("Must call AddField before you can access the FieldBuilder");
23
+ return this._fieldBuilder;
24
+ }
25
+ // #endregion
26
+ // #region Public Methods
27
+ static Start(i) {
28
+ return new e(i);
29
+ }
30
+ Finish() {
31
+ if (this._line)
32
+ throw new Error("Can not call Finish while in the context of a AddLine.");
33
+ return this._formData;
34
+ }
35
+ AddSection(i) {
36
+ if (this._line)
37
+ throw new Error("Can not call AddSection while in the context of a AddLine.");
38
+ return this._line = null, this._field = null, this._fieldBuilder = null, this._section = {
39
+ title: i,
40
+ fields: []
41
+ }, this._sectionBuilder = new s(this, this._section), this._formData.sections.push(this._section), this;
42
+ }
43
+ AddLine(i) {
44
+ if (!this._section)
45
+ throw new Error("Must call AddSection before you can call AddLine");
46
+ if (this._line)
47
+ throw new Error("Already in an AddLine context.");
48
+ return this._line = {
49
+ fields: []
50
+ }, this._section.fields.push(this._line), i(this), this._line = null, this;
51
+ }
52
+ AddField(i, t) {
53
+ if (!this._section)
54
+ throw new Error("Before calling AddField you must either call add Section or add line");
55
+ return this._field = {
56
+ key: i,
57
+ label: t
58
+ }, this._line ? this._line.fields.push(this._field) : this._section.fields.push(this._field), this._fieldBuilder = new l(this, this._field, this._defaultValues), this;
59
+ }
60
+ // #endregion
61
+ }
62
+ export {
63
+ e as DynamicFormBuilder
64
+ };
@@ -0,0 +1,53 @@
1
+ class l {
2
+ // #endregion
3
+ // #region Constructor
4
+ constructor(e, i, t) {
5
+ this._formBuilder = e, this._field = i, this._defaultValues = t;
6
+ }
7
+ // #endregion
8
+ // #region Public Methods
9
+ SetType(e) {
10
+ return this._field.type = e, this._formBuilder;
11
+ }
12
+ IsMultiLined() {
13
+ return this._field.multiLine = !0, this._formBuilder;
14
+ }
15
+ IsRequired() {
16
+ return this._field.required = !0, this._formBuilder;
17
+ }
18
+ SetOptions(e) {
19
+ return this._field.options = e, this._formBuilder;
20
+ }
21
+ AsRadiogroup() {
22
+ return this._field.asRadioGroup = !0, this._formBuilder;
23
+ }
24
+ SetValidation(e) {
25
+ return this._field.validationMessage = e, this._formBuilder;
26
+ }
27
+ SetHint(e) {
28
+ return this._field.hint = e, this._formBuilder;
29
+ }
30
+ IsBoolean() {
31
+ return this._field.isBoolean = !0, this._formBuilder;
32
+ }
33
+ DoesNotFill() {
34
+ return this._field.doNotFill = !0, this._formBuilder;
35
+ }
36
+ WithDefaultValue(e) {
37
+ return this._defaultValues[this._field.key] = e, this._formBuilder;
38
+ }
39
+ /**
40
+ * Marks the current field dependant on the value of another field.
41
+ * @param key The key of the field this one is dependant on.
42
+ * @param value The expected value of the field. Can either be !=NULL for any value, true or false for a boolean field, or any string value.
43
+ * @param type What aspect of this field is controlled by the other fields value? Either visibility or enabled.
44
+ * @returns
45
+ */
46
+ WithDependency(e, i, t) {
47
+ return this._field.dependantOn = e, this._field.dependantValue = i, this._field.dependencyType = t, this._formBuilder;
48
+ }
49
+ // #endregion
50
+ }
51
+ export {
52
+ l as FieldBuilder
53
+ };
@@ -0,0 +1,16 @@
1
+ class i {
2
+ // #endregion
3
+ // #region Constructor
4
+ constructor(e, s) {
5
+ this._formBuilder = e, this._section = s;
6
+ }
7
+ // #endregion
8
+ // #region Public Methods
9
+ SetMessage(e) {
10
+ return this._section.message = e, this._formBuilder;
11
+ }
12
+ // #endregion
13
+ }
14
+ export {
15
+ i as SectionBuilder
16
+ };
@@ -0,0 +1,8 @@
1
+ import { DynamicFormBuilder as o } from "./DynamicFormBuilder.js";
2
+ import { FieldBuilder as m } from "./Field/FieldBuilder.js";
3
+ import { SectionBuilder as l } from "./Section/SectionBuilder.js";
4
+ export {
5
+ o as DynamicFormBuilder,
6
+ m as FieldBuilder,
7
+ l as SectionBuilder
8
+ };
@@ -0,0 +1,197 @@
1
+ import { jsx as i, jsxs as D } from "react/jsx-runtime";
2
+ import c from "react";
3
+ import { Wizard as j } from "../Wizard/Wizard.js";
4
+ import { WizardPanel as U } from "../Wizard/WizardPanel/WizardPanel.js";
5
+ import { makeStyles as H, tokens as k, Text as $, Divider as A, mergeClasses as J, Textarea as K, RadioGroup as Q, Radio as X, Dropdown as Y, Option as Z, Checkbox as ee, Input as ne, Field as te } from "@fluentui/react-components";
6
+ import { Device as ae } from "../FiveSoulsProvider/FiveSouls.Types.js";
7
+ import "../FiveSoulsProvider/deviceContext.js";
8
+ import { useDevice as ie } from "../FiveSoulsProvider/useDevice.js";
9
+ import { FlexBox as v } from "../FlexBox/FlexBox.js";
10
+ import { FlexBoxItem as se } from "../FlexBox/FlexBoxItem/FlexBoxItem.js";
11
+ import "../FlexBox/FlexBoxItemResizer/FlexBoxItemResizer.js";
12
+ import { ClassNames as b } from "../ClassNames.js";
13
+ const oe = H({
14
+ root: {
15
+ width: "100%",
16
+ boxSizing: "border-box"
17
+ },
18
+ radio: {
19
+ flexGrow: 1,
20
+ flexBasis: "0px"
21
+ }
22
+ }), be = (M) => {
23
+ const { metaData: F, readonly: d, onSubmit: x, className: R, ref: E, action: m, target: O, strings: f, wizardStrings: V, onFieldChanged: z, id: _ } = M, { sections: u, results: o } = F, S = oe(), l = c.useReducer((e) => e + 1, 0)[1], I = ie(), p = c.useRef({}), h = c.useCallback((e, n) => {
24
+ const a = p.current;
25
+ if (!(e in a))
26
+ return;
27
+ const t = a[e];
28
+ let s = !1;
29
+ switch (t.dependantValue) {
30
+ case "!=NULL": {
31
+ s = n && n.length > 0;
32
+ break;
33
+ }
34
+ default:
35
+ s = t.dependantValue == n;
36
+ }
37
+ switch (t.dependencyType) {
38
+ case "visibility": {
39
+ const L = window.document.getElementById("field-" + t.key);
40
+ L.style.display = s ? "block" : "none";
41
+ break;
42
+ }
43
+ case "enabled": {
44
+ t.disabled = !s, l();
45
+ break;
46
+ }
47
+ }
48
+ }, [l]);
49
+ c.useEffect(() => {
50
+ const e = p.current;
51
+ for (const n in e) {
52
+ const a = e[n];
53
+ a && h(n, o[a.dependantOn]);
54
+ }
55
+ }, [h, o]);
56
+ const q = (e) => "key" in e, r = (e, n) => {
57
+ const a = o[e.key];
58
+ o[e.key] = n, h(e.key, n), z && z(e.key, a, n);
59
+ };
60
+ let C = 0;
61
+ const B = (e) => (C++, /* @__PURE__ */ i(
62
+ v,
63
+ {
64
+ className: b.FormFieldGroup,
65
+ horizontal: I != ae.Mobile,
66
+ childrenGap: k.spacingHorizontalM,
67
+ alignItems: "start",
68
+ children: e.fields.map((n) => w(n))
69
+ },
70
+ "field-group-" + C
71
+ )), w = (e) => {
72
+ let n;
73
+ e.dependantOn && (p.current[e.dependantOn] = e);
74
+ const a = d || e.disabled;
75
+ return e.multiLine ? n = /* @__PURE__ */ i(
76
+ K,
77
+ {
78
+ resize: "vertical",
79
+ name: e.key,
80
+ size: "large",
81
+ disabled: a,
82
+ value: o[e.key],
83
+ onChange: (t, s) => r(e, s.value)
84
+ }
85
+ ) : e.options && e.options.length > 0 ? e.asRadioGroup ? n = /* @__PURE__ */ i(
86
+ Q,
87
+ {
88
+ layout: "horizontal",
89
+ name: e.key,
90
+ defaultValue: o[e.key],
91
+ disabled: a,
92
+ onChange: (t, s) => r(e, s.value),
93
+ children: e.options.map((t) => /* @__PURE__ */ i(
94
+ X,
95
+ {
96
+ readOnly: d,
97
+ label: t,
98
+ value: t,
99
+ className: S.radio
100
+ },
101
+ t
102
+ ))
103
+ }
104
+ ) : n = /* @__PURE__ */ i(
105
+ Y,
106
+ {
107
+ defaultValue: o[e.key],
108
+ name: e.key,
109
+ disabled: a,
110
+ onOptionSelect: (t, s) => r(e, s.optionText),
111
+ children: e.options.map((t) => /* @__PURE__ */ i(Z, { children: t }, t))
112
+ }
113
+ ) : e.isBoolean ? n = /* @__PURE__ */ i(
114
+ ee,
115
+ {
116
+ size: "large",
117
+ name: e.key,
118
+ disabled: a,
119
+ checked: o[e.key],
120
+ onChange: (t, s) => r(e, s.checked.valueOf().toString())
121
+ }
122
+ ) : n = /* @__PURE__ */ i(
123
+ ne,
124
+ {
125
+ "aria-label": e.label,
126
+ name: e.key,
127
+ disabled: a,
128
+ type: e.type,
129
+ value: o[e.key],
130
+ onChange: (t) => r(e, t.target.value)
131
+ }
132
+ ), /* @__PURE__ */ i(
133
+ se,
134
+ {
135
+ id: `field-${e.key}`,
136
+ className: b.FormField,
137
+ grow: e.doNotFill ? 0 : 1,
138
+ children: /* @__PURE__ */ i(
139
+ te,
140
+ {
141
+ label: e.label ?? " ",
142
+ hint: e.hint,
143
+ required: e.required,
144
+ validationMessage: e.validationMessage,
145
+ children: n
146
+ }
147
+ )
148
+ },
149
+ e.key
150
+ );
151
+ }, T = (e, n, a) => {
152
+ u.forEach((t) => {
153
+ g(t, e, n, a);
154
+ });
155
+ }, g = (e, n, a, t) => {
156
+ e.fields.forEach((s) => {
157
+ q(s) ? n(s, t) : a(s, t);
158
+ });
159
+ }, y = (e, n) => {
160
+ if (e.required && o[e.key] === void 0) {
161
+ if (e.validationMessage = f ? f.fieldRequired : "This field is required.", n) {
162
+ const a = n;
163
+ a.missingFields++;
164
+ }
165
+ } else
166
+ e.validationMessage = "";
167
+ }, G = (e, n) => {
168
+ e.fields.forEach((a) => {
169
+ y(a, n);
170
+ });
171
+ }, W = (e, n) => {
172
+ const a = u[e], t = { missingFields: 0 };
173
+ return g(a, y, G, t), l(), t.missingFields <= 0;
174
+ }, P = () => {
175
+ const e = { missingFields: 0 };
176
+ T(y, G, e), e.missingFields > 0 ? l() : x && !m && x(F.results);
177
+ }, N = [];
178
+ return u.forEach((e, n) => {
179
+ const a = [];
180
+ g(e, (t) => {
181
+ a.push(w(t));
182
+ }, (t) => {
183
+ a.push(B(t));
184
+ }), N.push(
185
+ /* @__PURE__ */ i(U, { title: e.title, children: /* @__PURE__ */ D(v, { fill: !0, childrenGap: k.spacingVerticalM, children: [
186
+ e.message && /* @__PURE__ */ D("div", { children: [
187
+ /* @__PURE__ */ i($, { children: e.message }),
188
+ /* @__PURE__ */ i(A, { appearance: "brand" })
189
+ ] }),
190
+ /* @__PURE__ */ i(v, { fill: !0, childrenGap: k.spacingVerticalM, children: a })
191
+ ] }) }, "WizardPanel-" + n)
192
+ );
193
+ }), /* @__PURE__ */ i("div", { id: _, className: J(b.DynamicForm, S.root, R), ref: E, children: /* @__PURE__ */ i("form", { action: m, target: O, children: /* @__PURE__ */ i(j, { onSubmit: P, onNavigatePanel: W, readonly: d, asForm: m != null, strings: V, children: N }) }) });
194
+ };
195
+ export {
196
+ be as DynamicForm
197
+ };
@@ -0,0 +1,10 @@
1
+ import { DynamicForm as e } from "./DynamicForm.js";
2
+ import { DynamicFormBuilder as i } from "./Builder/DynamicFormBuilder.js";
3
+ import { FieldBuilder as d } from "./Builder/Field/FieldBuilder.js";
4
+ import { SectionBuilder as l } from "./Builder/Section/SectionBuilder.js";
5
+ export {
6
+ e as DynamicForm,
7
+ i as DynamicFormBuilder,
8
+ d as FieldBuilder,
9
+ l as SectionBuilder
10
+ };
@@ -0,0 +1,4 @@
1
+ var o = /* @__PURE__ */ ((t) => (t[t.Desktop = 0] = "Desktop", t[t.Tablet = 1] = "Tablet", t[t.Mobile = 2] = "Mobile", t))(o || {});
2
+ export {
3
+ o as Device
4
+ };
@@ -0,0 +1,20 @@
1
+ import { jsx as l } from "react/jsx-runtime";
2
+ import o from "react";
3
+ import { deviceContext as u } from "./deviceContext.js";
4
+ import { Device as r } from "./FiveSouls.Types.js";
5
+ import { FluentProvider as p } from "@fluentui/react-components";
6
+ const E = (c) => {
7
+ const { children: m, mobileThreshold: n, tabletThreshold: s, theme: v, className: a } = c, [t, f] = o.useState(), i = o.useCallback(() => {
8
+ const d = window.innerWidth;
9
+ let e;
10
+ d < (n ?? 768) ? e = r.Mobile : d < (s ?? 1024) ? e = r.Tablet : e = r.Desktop, t !== e && f(e);
11
+ }, [t, n, s]);
12
+ o.useEffect(() => (i(), window.addEventListener("resize", i), () => window.removeEventListener("resize", i)), [i]);
13
+ const h = {
14
+ device: t
15
+ };
16
+ return /* @__PURE__ */ l(u.Provider, { value: h, children: /* @__PURE__ */ l(p, { theme: v, className: a, children: m }) });
17
+ };
18
+ export {
19
+ E as FiveSoulsProvider
20
+ };
@@ -0,0 +1,5 @@
1
+ import t from "react";
2
+ const o = t.createContext(void 0);
3
+ export {
4
+ o as deviceContext
5
+ };
@@ -0,0 +1,10 @@
1
+ import { Device as r } from "./FiveSouls.Types.js";
2
+ import { FiveSoulsProvider as i } from "./FiveSoulsProvider.js";
3
+ import { deviceContext as x } from "./deviceContext.js";
4
+ import { useDevice as m } from "./useDevice.js";
5
+ export {
6
+ r as Device,
7
+ i as FiveSoulsProvider,
8
+ x as deviceContext,
9
+ m as useDevice
10
+ };
@@ -0,0 +1,10 @@
1
+ import t from "react";
2
+ import { deviceContext as o } from "./deviceContext.js";
3
+ import { Device as r } from "./FiveSouls.Types.js";
4
+ const p = () => {
5
+ const e = t.useContext(o);
6
+ return e ? e.device : r.Desktop;
7
+ };
8
+ export {
9
+ p as useDevice
10
+ };
@@ -0,0 +1,75 @@
1
+ import { jsx as u } from "react/jsx-runtime";
2
+ import { makeStyles as g, mergeClasses as r } from "@fluentui/react-components";
3
+ import { ClassNames as o } from "../ClassNames.js";
4
+ import { FlexBoxUtils as v } from "./FlexBoxUtils.js";
5
+ const j = g({
6
+ root: {
7
+ display: "flex",
8
+ boxSizing: "border-box"
9
+ },
10
+ vertical: {
11
+ flexDirection: "column"
12
+ },
13
+ verticalReverse: {
14
+ flexDirection: "column-reverse"
15
+ },
16
+ horizontal: {
17
+ flexDirection: "row"
18
+ },
19
+ horizontalReverse: {
20
+ flexDirection: "row-reverse"
21
+ },
22
+ alignStart: {
23
+ alignItems: "start"
24
+ },
25
+ alignCenter: {
26
+ alignItems: "center"
27
+ },
28
+ alignEnd: {
29
+ alignItems: "end"
30
+ },
31
+ justifyStart: {
32
+ justifyContent: "start"
33
+ },
34
+ justifyCenter: {
35
+ justifyContent: "center"
36
+ },
37
+ justifyEnd: {
38
+ justifyContent: "end"
39
+ },
40
+ wrap: {
41
+ flexWrap: "wrap"
42
+ }
43
+ }), C = (a) => {
44
+ const { children: c, horizontal: f, alignItems: s, wrap: m, justifyContent: l, reverse: i, className: n, ref: x, id: y } = a, t = j(), d = v.buildFlexBoxStyles(a);
45
+ let e = f ? r(o.FlexBox, t.root, n, i ? t.horizontalReverse : t.horizontal) : r(o.FlexBox, t.root, n, i ? t.verticalReverse : t.vertical);
46
+ if (s)
47
+ switch (s) {
48
+ case "start":
49
+ e = r(e, t.alignStart);
50
+ break;
51
+ case "center":
52
+ e = r(e, t.alignCenter);
53
+ break;
54
+ case "end":
55
+ e = r(e, t.alignEnd);
56
+ break;
57
+ }
58
+ if (l)
59
+ switch (l) {
60
+ case "start":
61
+ e = r(e, t.justifyStart);
62
+ break;
63
+ case "center":
64
+ e = r(e, t.justifyCenter);
65
+ break;
66
+ case "end":
67
+ e = r(e, t.justifyEnd);
68
+ break;
69
+ }
70
+ return m && (e = r(e, t.wrap)), /* @__PURE__ */ u("div", { id: y, className: e, style: d, ref: x, role: a.role, children: c });
71
+ };
72
+ C.displayName = "FlexBox";
73
+ export {
74
+ C as FlexBox
75
+ };
@@ -0,0 +1,15 @@
1
+ import { jsx as m } from "react/jsx-runtime";
2
+ import { makeStyles as i, mergeClasses as x } from "@fluentui/react-components";
3
+ import { ClassNames as c } from "../../ClassNames.js";
4
+ import { FlexBoxUtils as a } from "../FlexBoxUtils.js";
5
+ const n = i({
6
+ root: {
7
+ boxSizing: "border-box"
8
+ }
9
+ }), b = (e) => {
10
+ const { className: o, ref: s, id: t } = e, l = n(), r = a.buildFlexBoxItemStyles(e);
11
+ return /* @__PURE__ */ m("div", { id: t, className: x(c.FlexBoxItem, l.root, o), style: r, ref: s, children: e.children });
12
+ };
13
+ export {
14
+ b as FlexBoxItem
15
+ };
@@ -0,0 +1,4 @@
1
+ import { FlexBoxItem as x } from "./FlexBoxItem.js";
2
+ export {
3
+ x as FlexBoxItem
4
+ };
@@ -0,0 +1,80 @@
1
+ import { jsx as b } from "react/jsx-runtime";
2
+ import x from "react";
3
+ import { makeStyles as I, tokens as c, mergeClasses as k } from "@fluentui/react-components";
4
+ import { ResizeUtils as r } from "../ResizeUtils.js";
5
+ import { ClassNames as a } from "../../ClassNames.js";
6
+ const G = I({
7
+ root: {
8
+ backgroundColor: c.colorBrandBackground,
9
+ borderRadius: c.borderRadiusMedium,
10
+ ":hover": {
11
+ backgroundColor: c.colorBrandBackgroundHover
12
+ }
13
+ },
14
+ horizontal: {
15
+ cursor: "col-resize",
16
+ width: c.spacingHorizontalXS,
17
+ height: "100%"
18
+ },
19
+ vertical: {
20
+ cursor: "row-resize",
21
+ height: c.spacingVerticalXS,
22
+ width: "100%"
23
+ }
24
+ }), H = (f) => {
25
+ const { horizontal: p, className: B, id: w } = f, m = G(), l = x.useRef(), [t, h] = x.useState(p), [n, z] = x.useState();
26
+ x.useEffect(() => {
27
+ const i = l.current, o = i.parentElement, e = i.previousSibling;
28
+ if (!o.classList.contains(a.FlexBox))
29
+ throw new Error("Flex Box Resizer must be defined as a child of the Flex Box component");
30
+ if (e === void 0 || !(e.classList.contains(a.FlexBox) || e.classList.contains(a.FlexBoxItem) || e.classList.contains(a.Section)))
31
+ throw new Error("Flex Box Resizer must be defined after a Flex Box, Flex Box Item, or Section.");
32
+ window.getComputedStyle(o).flexDirection === "row" && h(!0);
33
+ }, []);
34
+ const y = (i) => {
35
+ const o = l.current, e = o.parentElement, s = o.previousElementSibling;
36
+ e && e.classList.add("unselectable");
37
+ const u = window.getComputedStyle(s);
38
+ z({
39
+ resizer: o,
40
+ flexBox: e,
41
+ flexBoxItem: s,
42
+ minsize: r.GetMinSize(u, t),
43
+ maxSize: r.GetMaxSize(u, t)
44
+ }), o.setPointerCapture(i.pointerId);
45
+ }, C = (i) => {
46
+ }, F = (i) => {
47
+ if (!n)
48
+ return;
49
+ const { flexBoxItem: o } = n;
50
+ r.CheckForFlexGrow(o, t);
51
+ const s = r.GetClientSize(o, t) + r.GetMouseDelta(i, t);
52
+ n.minsize > 0 && n.minsize > s || n.maxSize > 0 && n.maxSize < s || r.SetSize(o.style, t, s);
53
+ }, g = (i) => {
54
+ const o = l.current;
55
+ n && n.flexBox && n.flexBox.classList.remove("unselectable"), o.releasePointerCapture(i.pointerId), z(void 0);
56
+ }, v = (i) => {
57
+ const e = l.current.previousSibling, s = window.getComputedStyle(e), u = r.GetClientSize(e, t), S = r.GetMinSize(s, t), d = r.GetMaxSize(s, t);
58
+ if (u === S && d > 0) {
59
+ r.CheckForFlexGrow(e, t), r.SetSize(e.style, t, d);
60
+ return;
61
+ }
62
+ S > 0 && (r.CheckForFlexGrow(e, t), r.SetSize(e.style, t, S));
63
+ };
64
+ return /* @__PURE__ */ b(
65
+ "div",
66
+ {
67
+ id: w,
68
+ ref: l,
69
+ className: k(a.FlexBoxItemResizer, m.root, t ? m.horizontal : m.vertical, B),
70
+ onTouchStart: C,
71
+ onDoubleClick: v,
72
+ onPointerDown: y,
73
+ onMouseMove: F,
74
+ onPointerUp: g
75
+ }
76
+ );
77
+ };
78
+ export {
79
+ H as FlexBoxItemResizer
80
+ };
@@ -0,0 +1,4 @@
1
+ import { FlexBoxItemResizer as r } from "./FlexBoxItemResizer.js";
2
+ export {
3
+ r as FlexBoxItemResizer
4
+ };
@@ -0,0 +1,13 @@
1
+ const r = class r {
2
+ };
3
+ r.buildFlexBoxItemStyles = (e, t) => {
4
+ const { grow: s, shrink: f, basis: n, padding: h, minSize: a, maxSize: d } = e, i = t ?? {};
5
+ return s && (i.flexGrow = s, i.flexBasis = "0px"), f && (i.flexShrink = f), h && (i.boxSizing = "border-box", i.padding = h), n && (i.flexBasis = n), a && (i.minWidth = a + "px", i.minHeight = a + "px"), d && (i.maxWidth = a + "px", i.maxHeight = a + "px"), Object.assign({}, e.style, i);
6
+ }, r.buildFlexBoxStyles = (e) => {
7
+ const t = {}, { childrenGap: s, fill: f, itemProps: n } = e;
8
+ return s && (t.gap = s), f && (t.width = "100%", t.height = "100%"), n && r.buildFlexBoxItemStyles(n, t), Object.assign({}, t, e.style);
9
+ };
10
+ let x = r;
11
+ export {
12
+ x as FlexBoxUtils
13
+ };
@@ -0,0 +1,31 @@
1
+ const s = class s {
2
+ static GetGridTemplate(t, e, i, n) {
3
+ const r = (i ? t.style.gridTemplateColumns : t.style.gridTemplateRows).split(" ")[n - 1];
4
+ if (r.endsWith("fr") || r == "auto") {
5
+ const m = s.GetClientSize(e, i);
6
+ return this.UpdateLayoutGrid(t, i, n, m + "px"), m;
7
+ }
8
+ return this.GetNumericalSizeFromCss(r);
9
+ }
10
+ static UpdateLayoutGrid(t, e, i, n) {
11
+ const a = (e ? t.style.gridTemplateColumns : t.style.gridTemplateRows).split(" ");
12
+ a[i - 1] = n;
13
+ const r = a.join(" ");
14
+ e ? t.style.gridTemplateColumns = r : t.style.gridTemplateRows = r;
15
+ }
16
+ };
17
+ s.GetNumericalSizeFromCss = (t) => t === "none" ? -1 : t.endsWith("px") ? Number(t.substring(0, t.length - 2)) : (t.endsWith("%"), -1), s.GetMinSize = (t, e) => {
18
+ const i = e ? t.minWidth : t.minHeight;
19
+ return s.GetNumericalSizeFromCss(i);
20
+ }, s.GetMaxSize = (t, e) => {
21
+ const i = e ? t.maxWidth : t.maxHeight;
22
+ return s.GetNumericalSizeFromCss(i);
23
+ }, s.GetClientSize = (t, e) => e ? t.offsetWidth : t.offsetHeight, s.SetSize = (t, e, i) => {
24
+ e ? t.width = i + "px" : t.height = i + "px";
25
+ }, s.GetMouseDelta = (t, e) => e ? t.movementX : t.movementY, s.CheckForFlexGrow = (t, e) => {
26
+ t.style.flexGrow != "unset" && (s.SetSize(t.style, e, s.GetClientSize(t, e)), t.style.flexGrow = "unset", t.style.flexBasis = "unset");
27
+ };
28
+ let o = s;
29
+ export {
30
+ o as ResizeUtils
31
+ };
@@ -0,0 +1,8 @@
1
+ import { FlexBox as x } from "./FlexBox.js";
2
+ import { FlexBoxItem as m } from "./FlexBoxItem/FlexBoxItem.js";
3
+ import { FlexBoxItemResizer as f } from "./FlexBoxItemResizer/FlexBoxItemResizer.js";
4
+ export {
5
+ x as FlexBox,
6
+ m as FlexBoxItem,
7
+ f as FlexBoxItemResizer
8
+ };