@xiping/react-components 0.0.72 → 1.0.0

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 (43) hide show
  1. package/dist/cjs/components/dock/Duck.d.ts +27 -0
  2. package/dist/cjs/components/dock/Duck.js +1 -0
  3. package/dist/cjs/components/dock/index.d.ts +1 -0
  4. package/dist/cjs/components/pinch-content/PinchContent.js +1 -1
  5. package/dist/cjs/components/txt-editor/TxtEditor.d.ts +52 -0
  6. package/dist/cjs/components/txt-editor/TxtEditor.js +1 -0
  7. package/dist/cjs/components/txt-editor/index.d.ts +3 -0
  8. package/dist/cjs/index.d.ts +2 -0
  9. package/dist/cjs/index.js +1 -1
  10. package/dist/cjs/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/_virtual/_rollupPluginBabelHelpers.js +2 -0
  11. package/dist/cjs/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/config/index.js +1 -0
  12. package/dist/cjs/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/loader/index.js +1 -0
  13. package/dist/cjs/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/utils/compose.js +1 -0
  14. package/dist/cjs/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/utils/curry.js +1 -0
  15. package/dist/cjs/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/utils/deepMerge.js +1 -0
  16. package/dist/cjs/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/utils/isObject.js +1 -0
  17. package/dist/cjs/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/utils/makeCancelable.js +1 -0
  18. package/dist/cjs/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/validators/index.js +10 -0
  19. package/dist/cjs/node_modules/.pnpm/@monaco-editor_react@4.7.0_monaco-editor@0.52.2_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@monaco-editor/react/dist/index.js +1 -0
  20. package/dist/cjs/node_modules/.pnpm/state-local@1.0.7/node_modules/state-local/lib/es/state-local.js +1 -0
  21. package/dist/cjs/react-components.css +1 -1
  22. package/dist/es/components/dock/Duck.d.ts +27 -0
  23. package/dist/es/components/dock/Duck.js +85 -0
  24. package/dist/es/components/dock/index.d.ts +1 -0
  25. package/dist/es/components/pinch-content/PinchContent.js +1 -1
  26. package/dist/es/components/txt-editor/TxtEditor.d.ts +52 -0
  27. package/dist/es/components/txt-editor/TxtEditor.js +54 -0
  28. package/dist/es/components/txt-editor/index.d.ts +3 -0
  29. package/dist/es/index.d.ts +2 -0
  30. package/dist/es/index.js +21 -15
  31. package/dist/es/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/_virtual/_rollupPluginBabelHelpers.js +99 -0
  32. package/dist/es/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/config/index.js +8 -0
  33. package/dist/es/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/loader/index.js +101 -0
  34. package/dist/es/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/utils/compose.js +12 -0
  35. package/dist/es/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/utils/curry.js +14 -0
  36. package/dist/es/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/utils/deepMerge.js +9 -0
  37. package/dist/es/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/utils/isObject.js +6 -0
  38. package/dist/es/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/utils/makeCancelable.js +18 -0
  39. package/dist/es/node_modules/.pnpm/@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/validators/index.js +37 -0
  40. package/dist/es/node_modules/.pnpm/@monaco-editor_react@4.7.0_monaco-editor@0.52.2_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@monaco-editor/react/dist/index.js +169 -0
  41. package/dist/es/node_modules/.pnpm/state-local@1.0.7/node_modules/state-local/lib/es/state-local.js +131 -0
  42. package/dist/es/react-components.css +1 -1
  43. package/package.json +41 -38
@@ -0,0 +1,169 @@
1
+ import K from "../../../../../@monaco-editor_loader@1.5.0/node_modules/@monaco-editor/loader/lib/es/loader/index.js";
2
+ import b, { memo as q, useState as j, useRef as s, useCallback as $, useEffect as V } from "react";
3
+ var ne = { wrapper: { display: "flex", position: "relative", textAlign: "initial" }, fullWidth: { width: "100%" }, hide: { display: "none" } }, Z = ne, ie = { container: { display: "flex", height: "100%", width: "100%", justifyContent: "center", alignItems: "center" } }, ue = ie;
4
+ function oe({ children: r }) {
5
+ return b.createElement("div", { style: ue.container }, r);
6
+ }
7
+ var ae = oe, le = ae;
8
+ function ce({ width: r, height: u, isEditorReady: l, loading: n, _ref: p, className: h, wrapperProps: w }) {
9
+ return b.createElement("section", { style: { ...Z.wrapper, width: r, height: u }, ...w }, !l && b.createElement(le, null, n), b.createElement("div", { ref: p, style: { ...Z.fullWidth, ...!l && Z.hide }, className: h }));
10
+ }
11
+ var de = ce, T = q(de);
12
+ function se(r) {
13
+ V(r, []);
14
+ }
15
+ var ee = se;
16
+ function ge(r, u, l = !0) {
17
+ let n = s(!0);
18
+ V(n.current || !l ? () => {
19
+ n.current = !1;
20
+ } : r, u);
21
+ }
22
+ var m = ge;
23
+ function I() {
24
+ }
25
+ function P(r, u, l, n) {
26
+ return fe(r, n) || pe(r, u, l, n);
27
+ }
28
+ function fe(r, u) {
29
+ return r.editor.getModel(re(r, u));
30
+ }
31
+ function pe(r, u, l, n) {
32
+ return r.editor.createModel(u, l, n ? re(r, n) : void 0);
33
+ }
34
+ function re(r, u) {
35
+ return r.Uri.parse(u);
36
+ }
37
+ function he({ original: r, modified: u, language: l, originalLanguage: n, modifiedLanguage: p, originalModelPath: h, modifiedModelPath: w, keepCurrentOriginalModel: C = !1, keepCurrentModifiedModel: A = !1, theme: L = "light", loading: R = "Loading...", options: E = {}, height: B = "100%", width: G = "100%", className: J, wrapperProps: Q = {}, beforeMount: X = I, onMount: Y = I }) {
38
+ let [M, N] = j(!1), [k, d] = j(!0), g = s(null), c = s(null), D = s(null), f = s(Y), i = s(X), y = s(!1);
39
+ ee(() => {
40
+ let e = K.init();
41
+ return e.then((o) => (c.current = o) && d(!1)).catch((o) => (o == null ? void 0 : o.type) !== "cancelation" && console.error("Monaco initialization: error:", o)), () => g.current ? U() : e.cancel();
42
+ }), m(() => {
43
+ if (g.current && c.current) {
44
+ let e = g.current.getOriginalEditor(), o = P(c.current, r || "", n || l || "text", h || "");
45
+ o !== e.getModel() && e.setModel(o);
46
+ }
47
+ }, [h], M), m(() => {
48
+ if (g.current && c.current) {
49
+ let e = g.current.getModifiedEditor(), o = P(c.current, u || "", p || l || "text", w || "");
50
+ o !== e.getModel() && e.setModel(o);
51
+ }
52
+ }, [w], M), m(() => {
53
+ let e = g.current.getModifiedEditor();
54
+ e.getOption(c.current.editor.EditorOption.readOnly) ? e.setValue(u || "") : u !== e.getValue() && (e.executeEdits("", [{ range: e.getModel().getFullModelRange(), text: u || "", forceMoveMarkers: !0 }]), e.pushUndoStop());
55
+ }, [u], M), m(() => {
56
+ var e, o;
57
+ (o = (e = g.current) == null ? void 0 : e.getModel()) == null || o.original.setValue(r || "");
58
+ }, [r], M), m(() => {
59
+ let { original: e, modified: o } = g.current.getModel();
60
+ c.current.editor.setModelLanguage(e, n || l || "text"), c.current.editor.setModelLanguage(o, p || l || "text");
61
+ }, [l, n, p], M), m(() => {
62
+ var e;
63
+ (e = c.current) == null || e.editor.setTheme(L);
64
+ }, [L], M), m(() => {
65
+ var e;
66
+ (e = g.current) == null || e.updateOptions(E);
67
+ }, [E], M);
68
+ let z = $(() => {
69
+ var O;
70
+ if (!c.current) return;
71
+ i.current(c.current);
72
+ let e = P(c.current, r || "", n || l || "text", h || ""), o = P(c.current, u || "", p || l || "text", w || "");
73
+ (O = g.current) == null || O.setModel({ original: e, modified: o });
74
+ }, [l, u, p, r, n, h, w]), H = $(() => {
75
+ var e;
76
+ !y.current && D.current && (g.current = c.current.editor.createDiffEditor(D.current, { automaticLayout: !0, ...E }), z(), (e = c.current) == null || e.editor.setTheme(L), N(!0), y.current = !0);
77
+ }, [E, L, z]);
78
+ V(() => {
79
+ M && f.current(g.current, c.current);
80
+ }, [M]), V(() => {
81
+ !k && !M && H();
82
+ }, [k, M, H]);
83
+ function U() {
84
+ var o, O, S, _;
85
+ let e = (o = g.current) == null ? void 0 : o.getModel();
86
+ C || ((O = e == null ? void 0 : e.original) == null || O.dispose()), A || ((S = e == null ? void 0 : e.modified) == null || S.dispose()), (_ = g.current) == null || _.dispose();
87
+ }
88
+ return b.createElement(T, { width: G, height: B, isEditorReady: M, loading: R, _ref: D, className: J, wrapperProps: Q });
89
+ }
90
+ var Me = he;
91
+ q(Me);
92
+ function ve(r) {
93
+ let u = s();
94
+ return V(() => {
95
+ u.current = r;
96
+ }, [r]), u.current;
97
+ }
98
+ var me = ve, W = /* @__PURE__ */ new Map();
99
+ function we({ defaultValue: r, defaultLanguage: u, defaultPath: l, value: n, language: p, path: h, theme: w = "light", line: C, loading: A = "Loading...", options: L = {}, overrideServices: R = {}, saveViewState: E = !0, keepCurrentModel: B = !1, width: G = "100%", height: J = "100%", className: Q, wrapperProps: X = {}, beforeMount: Y = I, onMount: M = I, onChange: N, onValidate: k = I }) {
100
+ let [d, g] = j(!1), [c, D] = j(!0), f = s(null), i = s(null), y = s(null), z = s(M), H = s(Y), U = s(), e = s(n), o = me(h), O = s(!1), S = s(!1);
101
+ ee(() => {
102
+ let t = K.init();
103
+ return t.then((a) => (f.current = a) && D(!1)).catch((a) => (a == null ? void 0 : a.type) !== "cancelation" && console.error("Monaco initialization: error:", a)), () => i.current ? te() : t.cancel();
104
+ }), m(() => {
105
+ var a, v, F, x;
106
+ let t = P(f.current, r || n || "", u || p || "", h || l || "");
107
+ t !== ((a = i.current) == null ? void 0 : a.getModel()) && (E && W.set(o, (v = i.current) == null ? void 0 : v.saveViewState()), (F = i.current) == null || F.setModel(t), E && ((x = i.current) == null || x.restoreViewState(W.get(h))));
108
+ }, [h], d), m(() => {
109
+ var t;
110
+ (t = i.current) == null || t.updateOptions(L);
111
+ }, [L], d), m(() => {
112
+ !i.current || n === void 0 || (i.current.getOption(f.current.editor.EditorOption.readOnly) ? i.current.setValue(n) : n !== i.current.getValue() && (S.current = !0, i.current.executeEdits("", [{ range: i.current.getModel().getFullModelRange(), text: n, forceMoveMarkers: !0 }]), i.current.pushUndoStop(), S.current = !1));
113
+ }, [n], d), m(() => {
114
+ var a, v;
115
+ let t = (a = i.current) == null ? void 0 : a.getModel();
116
+ t && p && ((v = f.current) == null || v.editor.setModelLanguage(t, p));
117
+ }, [p], d), m(() => {
118
+ var t;
119
+ C !== void 0 && ((t = i.current) == null || t.revealLine(C));
120
+ }, [C], d), m(() => {
121
+ var t;
122
+ (t = f.current) == null || t.editor.setTheme(w);
123
+ }, [w], d);
124
+ let _ = $(() => {
125
+ var t;
126
+ if (!(!y.current || !f.current) && !O.current) {
127
+ H.current(f.current);
128
+ let a = h || l, v = P(f.current, n || r || "", u || p || "", a || "");
129
+ i.current = (t = f.current) == null ? void 0 : t.editor.create(y.current, { model: v, automaticLayout: !0, ...L }, R), E && i.current.restoreViewState(W.get(a)), f.current.editor.setTheme(w), C !== void 0 && i.current.revealLine(C), g(!0), O.current = !0;
130
+ }
131
+ }, [r, u, l, n, p, h, L, R, E, w, C]);
132
+ V(() => {
133
+ d && z.current(i.current, f.current);
134
+ }, [d]), V(() => {
135
+ !c && !d && _();
136
+ }, [c, d, _]), e.current = n, V(() => {
137
+ var t, a;
138
+ d && N && ((t = U.current) == null || t.dispose(), U.current = (a = i.current) == null ? void 0 : a.onDidChangeModelContent((v) => {
139
+ S.current || N(i.current.getValue(), v);
140
+ }));
141
+ }, [d, N]), V(() => {
142
+ if (d) {
143
+ let t = f.current.editor.onDidChangeMarkers((a) => {
144
+ var F;
145
+ let v = (F = i.current.getModel()) == null ? void 0 : F.uri;
146
+ if (v && a.find((x) => x.path === v.path)) {
147
+ let x = f.current.editor.getModelMarkers({ resource: v });
148
+ k == null || k(x);
149
+ }
150
+ });
151
+ return () => {
152
+ t == null || t.dispose();
153
+ };
154
+ }
155
+ return () => {
156
+ };
157
+ }, [d, k]);
158
+ function te() {
159
+ var t, a;
160
+ (t = U.current) == null || t.dispose(), B ? E && W.set(h, i.current.saveViewState()) : (a = i.current.getModel()) == null || a.dispose(), i.current.dispose();
161
+ }
162
+ return b.createElement(T, { width: G, height: J, isEditorReady: d, loading: A, _ref: y, className: Q, wrapperProps: X });
163
+ }
164
+ var Ee = we, Le = q(Ee), Oe = Le;
165
+ export {
166
+ Le as Editor,
167
+ Oe as default,
168
+ K as loader
169
+ };
@@ -0,0 +1,131 @@
1
+ function O(e, t, n) {
2
+ return t in e ? Object.defineProperty(e, t, {
3
+ value: n,
4
+ enumerable: !0,
5
+ configurable: !0,
6
+ writable: !0
7
+ }) : e[t] = n, e;
8
+ }
9
+ function g(e, t) {
10
+ var n = Object.keys(e);
11
+ if (Object.getOwnPropertySymbols) {
12
+ var r = Object.getOwnPropertySymbols(e);
13
+ t && (r = r.filter(function(i) {
14
+ return Object.getOwnPropertyDescriptor(e, i).enumerable;
15
+ })), n.push.apply(n, r);
16
+ }
17
+ return n;
18
+ }
19
+ function v(e) {
20
+ for (var t = 1; t < arguments.length; t++) {
21
+ var n = arguments[t] != null ? arguments[t] : {};
22
+ t % 2 ? g(Object(n), !0).forEach(function(r) {
23
+ O(e, r, n[r]);
24
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : g(Object(n)).forEach(function(r) {
25
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(n, r));
26
+ });
27
+ }
28
+ return e;
29
+ }
30
+ function y() {
31
+ for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
32
+ t[n] = arguments[n];
33
+ return function(r) {
34
+ return t.reduceRight(function(i, a) {
35
+ return a(i);
36
+ }, r);
37
+ };
38
+ }
39
+ function c(e) {
40
+ return function t() {
41
+ for (var n = this, r = arguments.length, i = new Array(r), a = 0; a < r; a++)
42
+ i[a] = arguments[a];
43
+ return i.length >= e.length ? e.apply(this, i) : function() {
44
+ for (var f = arguments.length, s = new Array(f), o = 0; o < f; o++)
45
+ s[o] = arguments[o];
46
+ return t.apply(n, [].concat(i, s));
47
+ };
48
+ };
49
+ }
50
+ function h(e) {
51
+ return {}.toString.call(e).includes("Object");
52
+ }
53
+ function m(e) {
54
+ return !Object.keys(e).length;
55
+ }
56
+ function l(e) {
57
+ return typeof e == "function";
58
+ }
59
+ function j(e, t) {
60
+ return Object.prototype.hasOwnProperty.call(e, t);
61
+ }
62
+ function w(e, t) {
63
+ return h(t) || u("changeType"), Object.keys(t).some(function(n) {
64
+ return !j(e, n);
65
+ }) && u("changeField"), t;
66
+ }
67
+ function P(e) {
68
+ l(e) || u("selectorType");
69
+ }
70
+ function T(e) {
71
+ l(e) || h(e) || u("handlerType"), h(e) && Object.values(e).some(function(t) {
72
+ return !l(t);
73
+ }) && u("handlersType");
74
+ }
75
+ function S(e) {
76
+ e || u("initialIsRequired"), h(e) || u("initialType"), m(e) && u("initialContent");
77
+ }
78
+ function E(e, t) {
79
+ throw new Error(e[t] || e.default);
80
+ }
81
+ var D = {
82
+ initialIsRequired: "initial state is required",
83
+ initialType: "initial state should be an object",
84
+ initialContent: "initial state shouldn't be an empty object",
85
+ handlerType: "handler should be an object or a function",
86
+ handlersType: "all handlers should be a functions",
87
+ selectorType: "selector should be a function",
88
+ changeType: "provided value of changes should be an object",
89
+ changeField: 'it seams you want to change a field in the state which is not specified in the "initial" state',
90
+ default: "an unknown error accured in `state-local` package"
91
+ }, u = c(E)(D), p = {
92
+ changes: w,
93
+ selector: P,
94
+ handler: T,
95
+ initial: S
96
+ };
97
+ function q(e) {
98
+ var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
99
+ p.initial(e), p.handler(t);
100
+ var n = {
101
+ current: e
102
+ }, r = c(I)(n, t), i = c(F)(n), a = c(p.changes)(e), f = c(C)(n);
103
+ function s() {
104
+ var d = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(b) {
105
+ return b;
106
+ };
107
+ return p.selector(d), d(n.current);
108
+ }
109
+ function o(d) {
110
+ y(r, i, a, f)(d);
111
+ }
112
+ return [s, o];
113
+ }
114
+ function C(e, t) {
115
+ return l(t) ? t(e.current) : t;
116
+ }
117
+ function F(e, t) {
118
+ return e.current = v(v({}, e.current), t), t;
119
+ }
120
+ function I(e, t, n) {
121
+ return l(t) ? t(e.current) : Object.keys(n).forEach(function(r) {
122
+ var i;
123
+ return (i = t[r]) === null || i === void 0 ? void 0 : i.call(t, e.current[r]);
124
+ }), n;
125
+ }
126
+ var R = {
127
+ create: q
128
+ };
129
+ export {
130
+ R as default
131
+ };