@apple-pie/slice 0.1.20 → 0.1.22
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/README.md +25 -1
- package/dist/cjs/chunks/{Button-DXvjvGtY.js → Button-KGA0e9-0.js} +1 -1
- package/dist/cjs/chunks/{ButtonBar-BZ6sme27.js → ButtonBar-RSBwFaU-.js} +1 -1
- package/dist/cjs/chunks/{Camera-rVC4KI4v.js → Camera-CLm3aQR8.js} +6 -2
- package/dist/cjs/chunks/{CheckBox-DQRLqTAK.js → CheckBox-DDINn56u.js} +1 -1
- package/dist/cjs/chunks/{Chip-Pv9-KTnh.js → Chip-DRSg6kLh.js} +1 -1
- package/dist/cjs/chunks/{DrggablePanel-CkhCXqKv.js → DrggablePanel-CERavfv3.js} +6 -2
- package/dist/cjs/chunks/{DropDown-C3AZ5b_b.js → DropDown-CJH-Y6Z5.js} +1 -1
- package/dist/cjs/chunks/{ErrorSummary-BTgAd3sK.js → ErrorSummary-BfVHS893.js} +6 -2
- package/dist/cjs/chunks/{FileIcon-CZLe2S2l.js → FileIcon-xoD-xIme.js} +2 -2
- package/dist/cjs/chunks/{FileList-BHwBIics.js → FileList-CIRALfrW.js} +1 -1
- package/dist/cjs/chunks/{Grouper-D4yyHHkM.js → Grouper-RYRxazG9.js} +1 -1
- package/dist/cjs/chunks/{Icon-D1EB8S5r.js → Icon-BB-t50Yt.js} +6 -2
- package/dist/cjs/chunks/{IconButton-B07Ttxbr.js → IconButton-BUw3YUsI.js} +1 -1
- package/dist/cjs/chunks/{Label-CTzvGcds.js → Label-NzMpkZo2.js} +1 -1
- package/dist/cjs/chunks/MdStreamBuffer-DObxjnAm.js +381 -0
- package/dist/cjs/chunks/{ProgressIndicator-BGqIwycX.js → ProgressIndicator-DETWiASA.js} +6 -2
- package/dist/cjs/chunks/{PromptInput-z6TuhHsG.js → PromptInput-DUxwal3V.js} +2 -2
- package/dist/cjs/chunks/{RadioButton-DuIsM4lu.js → RadioButton-Cvqum7dU.js} +1 -1
- package/dist/cjs/chunks/{RadioButtonList-bu11ILyw.js → RadioButtonList-CPHTioGa.js} +1 -1
- package/dist/cjs/chunks/{TabBar-Bcq_n4Mk.js → TabBar-CnD3E-qa.js} +1 -1
- package/dist/cjs/chunks/{TextArea-BSKbDOEt.js → TextArea-mSespe9z.js} +6 -6
- package/dist/cjs/chunks/{TextField-BNacOZVx.js → TextField-Cz2lh-fP.js} +20 -22
- package/dist/cjs/chunks/{Toast-CZzAWG0S.js → Toast-D2fpwdjF.js} +6 -2
- package/dist/cjs/chunks/{UploadArea-CKuE4rtg.js → UploadArea-CtvvqLU7.js} +1 -1
- package/dist/cjs/chunks/{_types-BSLc-fNi.js → _types-Sa2RAJ2U.js} +3 -3
- package/dist/cjs/components/Button/index.js +4 -4
- package/dist/cjs/components/ButtonBar/index.js +2 -2
- package/dist/cjs/components/Camera/index.js +4 -4
- package/dist/cjs/components/CheckBox/index.js +2 -2
- package/dist/cjs/components/Chip/index.js +2 -2
- package/dist/cjs/components/DraggablePanel/index.js +3 -3
- package/dist/cjs/components/DropDown/index.js +2 -2
- package/dist/cjs/components/ErrorSummary/index.js +2 -2
- package/dist/cjs/components/FileIcon/index.js +3 -4
- package/dist/cjs/components/FileList/index.js +4 -4
- package/dist/cjs/components/FlexDiv/index.js +1 -1
- package/dist/cjs/components/Grouper/index.js +2 -2
- package/dist/cjs/components/Icon/index.js +3 -3
- package/dist/cjs/components/IconButton/index.js +4 -4
- package/dist/cjs/components/Label/index.js +1 -1
- package/dist/cjs/components/Progress/index.js +5 -5
- package/dist/cjs/components/PromptInput/index.js +7 -7
- package/dist/cjs/components/RadioButton/index.js +2 -2
- package/dist/cjs/components/RadioButtonList/index.js +3 -3
- package/dist/cjs/components/TabBar/index.js +3 -3
- package/dist/cjs/components/TextArea/index.js +4 -4
- package/dist/cjs/components/Textfield/index.js +5 -5
- package/dist/cjs/components/Toast/index.js +2 -2
- package/dist/cjs/components/UploadArea/index.js +5 -5
- package/dist/cjs/hooks/useMdStreamBuffer.js +41 -0
- package/dist/cjs/hooks.js +3 -2
- package/dist/cjs/index.js +12 -11
- package/dist/cjs/providers/ThemeProvider.js +9 -7
- package/dist/cjs/utils/index.js +3 -2
- package/dist/cjs/utils/objects/index.js +3 -2
- package/dist/esm/chunks/{Button-daLv0i7S.mjs → Button-Bp51g5jC.mjs} +2 -2
- package/dist/esm/chunks/{ButtonBar-DXK8meQq.mjs → ButtonBar-BK-uB7oe.mjs} +1 -1
- package/dist/esm/chunks/{Camera-BqmVsVKy.mjs → Camera-BYi_Aqbl.mjs} +3 -3
- package/dist/esm/chunks/{CheckBox-BsaYFNC6.mjs → CheckBox-BB5olQbT.mjs} +1 -1
- package/dist/esm/chunks/{Chip-BRZeD1OX.mjs → Chip-CxqFCtT6.mjs} +1 -1
- package/dist/esm/chunks/{DropDown-DOJvg96J.mjs → DropDown-CK-sPjsQ.mjs} +1 -1
- package/dist/esm/chunks/{FileList-5LElsgoE.mjs → FileList-CyUhkk-m.mjs} +3 -3
- package/dist/esm/chunks/{Grouper-DR14qDXP.mjs → Grouper-Daz1o_Ai.mjs} +1 -1
- package/dist/esm/chunks/{IconButton-DG69Vlhj.mjs → IconButton-BKZD9jsp.mjs} +1 -1
- package/dist/esm/chunks/{Label-CRsE7o3D.mjs → Label-QTsUvGme.mjs} +1 -1
- package/dist/esm/chunks/MdStreamBuffer-DNXE4XbN.mjs +381 -0
- package/dist/esm/chunks/{ProgressIndicator-D7paCpgY.mjs → ProgressIndicator-Cg7CCrAE.mjs} +3 -3
- package/dist/esm/chunks/{PromptInput-CpxUcInZ.mjs → PromptInput-DJInpjRX.mjs} +4 -2
- package/dist/esm/chunks/{RadioButton-B5ZF5oJ_.mjs → RadioButton-CYp8RkDK.mjs} +1 -1
- package/dist/esm/chunks/{RadioButtonList-D9ZAZgkK.mjs → RadioButtonList-BSzV9Zz-.mjs} +1 -1
- package/dist/esm/chunks/{TabBar-BK7OcjPl.mjs → TabBar-Dd5-VZcG.mjs} +2 -2
- package/dist/esm/chunks/{TextArea-BmsEj6IA.mjs → TextArea-C_2D7sZV.mjs} +6 -6
- package/dist/esm/chunks/{TextField-DWPpevsj.mjs → TextField-RG1AsLTh.mjs} +19 -25
- package/dist/esm/chunks/{Toast-DPHLwDES.mjs → Toast-BfuKRAns.mjs} +3 -3
- package/dist/esm/chunks/{UploadArea-DPiOaNpc.mjs → UploadArea-ByvnUxhr.mjs} +3 -3
- package/dist/esm/chunks/{_types-B2h3MtOM.mjs → _types-CPrEyJX9.mjs} +3 -3
- package/dist/esm/components/Button/index.mjs +5 -5
- package/dist/esm/components/ButtonBar/index.mjs +2 -2
- package/dist/esm/components/Camera/index.mjs +4 -4
- package/dist/esm/components/CheckBox/index.mjs +2 -2
- package/dist/esm/components/Chip/index.mjs +2 -2
- package/dist/esm/components/DraggablePanel/index.mjs +3 -3
- package/dist/esm/components/DropDown/index.mjs +2 -2
- package/dist/esm/components/ErrorSummary/index.mjs +3 -3
- package/dist/esm/components/FileIcon/index.mjs +3 -3
- package/dist/esm/components/FileList/index.mjs +4 -4
- package/dist/esm/components/FlexDiv/index.mjs +1 -1
- package/dist/esm/components/Grouper/index.mjs +2 -2
- package/dist/esm/components/Icon/index.mjs +3 -3
- package/dist/esm/components/IconButton/index.mjs +4 -4
- package/dist/esm/components/Label/index.mjs +1 -1
- package/dist/esm/components/Progress/index.mjs +4 -4
- package/dist/esm/components/PromptInput/index.mjs +8 -8
- package/dist/esm/components/RadioButton/index.mjs +2 -2
- package/dist/esm/components/RadioButtonList/index.mjs +3 -3
- package/dist/esm/components/TabBar/index.mjs +3 -3
- package/dist/esm/components/TextArea/index.mjs +6 -6
- package/dist/esm/components/Textfield/index.mjs +7 -7
- package/dist/esm/components/Toast/index.mjs +4 -4
- package/dist/esm/components/UploadArea/index.mjs +5 -5
- package/dist/esm/hooks/useMdStreamBuffer.mjs +42 -0
- package/dist/esm/hooks.mjs +6 -0
- package/dist/esm/index.mjs +28 -24
- package/dist/esm/providers/ThemeProvider.mjs +9 -7
- package/dist/esm/utils/index.mjs +2 -0
- package/dist/esm/utils/objects/index.mjs +2 -0
- package/dist/types/components/FlexDiv/FlexDiv.d.ts +2 -2
- package/dist/types/components/FlexDiv/_types.d.ts +1 -1
- package/dist/types/components/Textfield/_types.d.ts +1 -3
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/useMdStreamBuffer/useMdStreamBuffer.d.ts +10 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/providers/ThemeProvider.d.ts +1 -0
- package/dist/types/utils/index.d.ts +2 -2
- package/dist/types/utils/objects/MDStreamBuffer/MdStreamBuffer.d.ts +63 -0
- package/dist/types/utils/objects/MDStreamBuffer/_defaults.d.ts +3 -0
- package/dist/types/utils/objects/MDStreamBuffer/_types.d.ts +25 -0
- package/dist/types/utils/objects/index.d.ts +2 -0
- package/package.json +5 -3
- package/dist/esm/chunks/{DrggablePanel-Ddi0vPRp.mjs → DrggablePanel-BfBCRXa8.mjs} +2 -2
- package/dist/esm/chunks/{ErrorSummary-CHLkvdHk.mjs → ErrorSummary-BNdjCQbn.mjs} +2 -2
- package/dist/esm/chunks/{FileIcon-ePouoJpT.mjs → FileIcon-BXKnFJBn.mjs} +2 -2
- package/dist/esm/chunks/{Icon-CUSQtytG.mjs → Icon-CbwaBi0l.mjs} +2 -2
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
const DEFAULT_WATCHED_MARKERS = [ {
|
|
2
|
+
name: "fenced code block",
|
|
3
|
+
open: "```",
|
|
4
|
+
close: "```"
|
|
5
|
+
}, {
|
|
6
|
+
name: "bold",
|
|
7
|
+
open: "**",
|
|
8
|
+
close: "**"
|
|
9
|
+
}, {
|
|
10
|
+
name: "double underscore emphasis",
|
|
11
|
+
open: "__",
|
|
12
|
+
close: "__"
|
|
13
|
+
}, {
|
|
14
|
+
name: "strikethrough",
|
|
15
|
+
open: "~~",
|
|
16
|
+
close: "~~"
|
|
17
|
+
}, {
|
|
18
|
+
name: "inline code",
|
|
19
|
+
open: "`",
|
|
20
|
+
close: "`"
|
|
21
|
+
}, {
|
|
22
|
+
name: "italic",
|
|
23
|
+
open: "*",
|
|
24
|
+
close: "*"
|
|
25
|
+
}, {
|
|
26
|
+
name: "underscore emphasis",
|
|
27
|
+
open: "_",
|
|
28
|
+
close: "_"
|
|
29
|
+
}, {
|
|
30
|
+
name: "heading - ie #, ##, etc.",
|
|
31
|
+
open: "",
|
|
32
|
+
close: "\n",
|
|
33
|
+
mode: "line",
|
|
34
|
+
linePattern: /^#{1,6}\s+\S.*/,
|
|
35
|
+
partialLinePattern: /^#{1,6}\s*$/
|
|
36
|
+
}, {
|
|
37
|
+
name: "blockquote",
|
|
38
|
+
open: "",
|
|
39
|
+
close: "\n",
|
|
40
|
+
mode: "line",
|
|
41
|
+
linePattern: /^>\s+\S.*/,
|
|
42
|
+
partialLinePattern: /^>\s*$/
|
|
43
|
+
}, {
|
|
44
|
+
name: 'horizontal rule with "-"',
|
|
45
|
+
open: "",
|
|
46
|
+
close: "\n",
|
|
47
|
+
mode: "line",
|
|
48
|
+
linePattern: /^-{3,}\s*$/,
|
|
49
|
+
partialLinePattern: /^-{1,2}\s*$/
|
|
50
|
+
}, {
|
|
51
|
+
name: "task list",
|
|
52
|
+
open: "",
|
|
53
|
+
close: "\n",
|
|
54
|
+
mode: "line",
|
|
55
|
+
linePattern: /^[-*+]\s+\[(?: |x|X)\]\s+\S.*/,
|
|
56
|
+
partialLinePattern: /^[-*+]\s+\[(?:\s|x|X)?\]?\s*$/
|
|
57
|
+
}, {
|
|
58
|
+
name: 'unordered list "-"',
|
|
59
|
+
open: "",
|
|
60
|
+
close: "\n",
|
|
61
|
+
mode: "line",
|
|
62
|
+
linePattern: /^-\s+\S.*/,
|
|
63
|
+
partialLinePattern: /^-\s*$/
|
|
64
|
+
}, {
|
|
65
|
+
name: 'unordered list with "*"',
|
|
66
|
+
open: "",
|
|
67
|
+
close: "\n",
|
|
68
|
+
mode: "line",
|
|
69
|
+
linePattern: /^\*\s+\S.*/,
|
|
70
|
+
partialLinePattern: /^\*\s*$/
|
|
71
|
+
}, {
|
|
72
|
+
name: 'unordered list with "+"',
|
|
73
|
+
open: "",
|
|
74
|
+
close: "\n",
|
|
75
|
+
mode: "line",
|
|
76
|
+
linePattern: /^\+\s+\S.*/,
|
|
77
|
+
partialLinePattern: /^\+\s*$/
|
|
78
|
+
}, {
|
|
79
|
+
name: "ordered list",
|
|
80
|
+
open: "",
|
|
81
|
+
close: "\n",
|
|
82
|
+
mode: "line",
|
|
83
|
+
linePattern: /^\d+\.\s+\S.*/,
|
|
84
|
+
partialLinePattern: /^\d+\.\s*$/
|
|
85
|
+
} ];
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Buffer streamed Markdown and emit parser-safe snapshots on animation frames.
|
|
89
|
+
*/ class MdBuffer {
|
|
90
|
+
constructor(options) {
|
|
91
|
+
var _a, _b, _c, _d, _e, rules;
|
|
92
|
+
this.committedRaw = "", this.activeRaw = "", this.frameHandle = null, this.completeSignal = !1,
|
|
93
|
+
this.endOfStreamToken = null == options ? void 0 : options.endOfStreamToken, this.htmlHandling = null !== (_a = null == options ? void 0 : options.htmlHandling) && void 0 !== _a ? _a : "ignore",
|
|
94
|
+
this.includeLinksAndImages = null !== (_b = null == options ? void 0 : options.includeLinksAndImages) && void 0 !== _b && _b,
|
|
95
|
+
this.onFlush = null == options ? void 0 : options.onFlush, this.requestFrame = null !== (_c = null == options ? void 0 : options.requestFrame) && void 0 !== _c ? _c : function() {
|
|
96
|
+
if ("undefined" != typeof globalThis && "function" == typeof globalThis.requestAnimationFrame) return globalThis.requestAnimationFrame.bind(globalThis);
|
|
97
|
+
return callback => globalThis.setTimeout(() => callback(Date.now()), 16);
|
|
98
|
+
}(), this.cancelFrame = null !== (_d = null == options ? void 0 : options.cancelFrame) && void 0 !== _d ? _d : function() {
|
|
99
|
+
if ("undefined" != typeof globalThis && "function" == typeof globalThis.cancelAnimationFrame) return globalThis.cancelAnimationFrame.bind(globalThis);
|
|
100
|
+
return handle => globalThis.clearTimeout(handle);
|
|
101
|
+
}(), this.watchedMarkers = (rules = null !== (_e = null == options ? void 0 : options.watchedMarkers) && void 0 !== _e ? _e : DEFAULT_WATCHED_MARKERS,
|
|
102
|
+
[ ...rules ].sort((left, right) => right.open.length - left.open.length));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The raw Markdown accumulated so far.
|
|
106
|
+
*/ get raw() {
|
|
107
|
+
return `${this.committedRaw}${this.activeRaw}`;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The current parser-safe preview derived from the raw buffer.
|
|
111
|
+
*/ get healthy() {
|
|
112
|
+
return this.buildHealthyOutput();
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Append a streamed Markdown token and schedule a frame flush.
|
|
116
|
+
*/ append(chunk) {
|
|
117
|
+
const eosSnapshot = this.handleEndOfStreamToken(chunk);
|
|
118
|
+
if (eosSnapshot) return eosSnapshot;
|
|
119
|
+
chunk && (this.activeRaw += chunk, this.commitStableLines(), this.scheduleFlush());
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Emit the current snapshot immediately.
|
|
123
|
+
*/ flush(reason = "manual") {
|
|
124
|
+
var _a;
|
|
125
|
+
const snapshot = {
|
|
126
|
+
raw: this.committedRaw + this.activeRaw,
|
|
127
|
+
healthy: this.buildHealthyOutput(),
|
|
128
|
+
reason: reason,
|
|
129
|
+
isComplete: this.completeSignal
|
|
130
|
+
};
|
|
131
|
+
return null === (_a = this.onFlush) || void 0 === _a || _a.call(this, snapshot),
|
|
132
|
+
snapshot;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Mark the stream as complete and flush one final snapshot.
|
|
136
|
+
*/ complete() {
|
|
137
|
+
return null !== this.frameHandle && (this.cancelFrame(this.frameHandle), this.frameHandle = null),
|
|
138
|
+
this.completeSignal = !0, this.flush("complete");
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Clear the buffered state and cancel any pending frame.
|
|
142
|
+
*/ reset() {
|
|
143
|
+
null !== this.frameHandle && (this.cancelFrame(this.frameHandle), this.frameHandle = null),
|
|
144
|
+
this.committedRaw = "", this.activeRaw = "", this.completeSignal = !1;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Cancel future work and release the retained state.
|
|
148
|
+
*/ dispose() {
|
|
149
|
+
this.reset();
|
|
150
|
+
}
|
|
151
|
+
handleEndOfStreamToken(chunk) {
|
|
152
|
+
if (!this.endOfStreamToken) return null;
|
|
153
|
+
if (!chunk.includes(this.endOfStreamToken)) return null;
|
|
154
|
+
const [beforeToken] = chunk.split(this.endOfStreamToken);
|
|
155
|
+
beforeToken && (this.activeRaw += beforeToken, this.commitStableLines());
|
|
156
|
+
const snapshot = this.complete();
|
|
157
|
+
return this.dispose(), snapshot;
|
|
158
|
+
}
|
|
159
|
+
scheduleFlush() {
|
|
160
|
+
null === this.frameHandle && (this.frameHandle = this.requestFrame(() => {
|
|
161
|
+
this.frameHandle = null, this.flush("raf");
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
commitStableLines() {
|
|
165
|
+
if (this.buildHealthyTail(this.activeRaw) !== this.activeRaw) return;
|
|
166
|
+
const lastNewlineIndex = this.activeRaw.lastIndexOf("\n");
|
|
167
|
+
if (-1 === lastNewlineIndex) return;
|
|
168
|
+
const stablePrefix = this.activeRaw.slice(0, lastNewlineIndex + 1);
|
|
169
|
+
this.committedRaw += stablePrefix, this.activeRaw = this.activeRaw.slice(lastNewlineIndex + 1);
|
|
170
|
+
}
|
|
171
|
+
buildHealthyOutput() {
|
|
172
|
+
return `${this.committedRaw}${this.buildHealthyTail(this.activeRaw)}`;
|
|
173
|
+
}
|
|
174
|
+
buildHealthyTail(value) {
|
|
175
|
+
const withHtmlHandling = "strip" === this.htmlHandling ? function(value) {
|
|
176
|
+
let stripped = value.replaceAll(/<\/?[a-zA-Z][^>]*>/g, "");
|
|
177
|
+
const lastOpenTag = stripped.lastIndexOf("<"), lastCloseBracket = stripped.lastIndexOf(">");
|
|
178
|
+
if (lastOpenTag > lastCloseBracket) {
|
|
179
|
+
const trailingSegment = stripped.slice(lastOpenTag);
|
|
180
|
+
/^<\/?[a-zA-Z][^>]*$/.test(trailingSegment) && (stripped = stripped.slice(0, lastOpenTag));
|
|
181
|
+
}
|
|
182
|
+
return stripped;
|
|
183
|
+
}(value) : value, withLinksAndImages = this.includeLinksAndImages ? this.closeLinksAndImages(withHtmlHandling) : withHtmlHandling;
|
|
184
|
+
return this.closeInlineMarkdown(withLinksAndImages);
|
|
185
|
+
}
|
|
186
|
+
closeInlineMarkdown(value) {
|
|
187
|
+
const counts = function(value, rules) {
|
|
188
|
+
var _a;
|
|
189
|
+
const counts = {}, tokens = new Set;
|
|
190
|
+
for (const rule of rules) tokens.add(rule.open), tokens.add(rule.close);
|
|
191
|
+
const sortedTokens = [ ...tokens ].sort((left, right) => right.length - left.length);
|
|
192
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
193
|
+
if (isEscaped(value, index)) continue;
|
|
194
|
+
const matchedToken = sortedTokens.find(token => token.length > 0 && value.slice(index, index + token.length) === token);
|
|
195
|
+
matchedToken && (shouldIgnoreSymmetricToken(value, matchedToken, index) || "*" === matchedToken && isStarListMarker(value, index) || (counts[matchedToken] = (null !== (_a = counts[matchedToken]) && void 0 !== _a ? _a : 0) + 1,
|
|
196
|
+
index += matchedToken.length - 1));
|
|
197
|
+
}
|
|
198
|
+
return counts;
|
|
199
|
+
}(value, this.getPairedRules()), withSymmetricClosers = this.closeSymmetricPairedMarkers(value), withAsymmetricClosers = this.closeAsymmetricPairedMarkers(withSymmetricClosers, counts);
|
|
200
|
+
return this.closeLineMarkers(withAsymmetricClosers);
|
|
201
|
+
}
|
|
202
|
+
closeLinksAndImages(value) {
|
|
203
|
+
const withImageSignalHandled = this.closeTrailingImageSignal(value);
|
|
204
|
+
if (withImageSignalHandled !== value) return withImageSignalHandled;
|
|
205
|
+
const trailingImage = this.findTrailingImage(value);
|
|
206
|
+
if (trailingImage) return this.closeTrailingImage(value, trailingImage);
|
|
207
|
+
const trailingLink = this.findTrailingLink(value);
|
|
208
|
+
return trailingLink ? this.closeTrailingLink(value, trailingLink) : value;
|
|
209
|
+
}
|
|
210
|
+
getPairedRules() {
|
|
211
|
+
return this.watchedMarkers.filter(rule => {
|
|
212
|
+
var _a;
|
|
213
|
+
return "paired" === (null !== (_a = rule.mode) && void 0 !== _a ? _a : "paired");
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
closeSymmetricPairedMarkers(value) {
|
|
217
|
+
let nextValue = value;
|
|
218
|
+
const suppressedCharacters = new Set, symmetricRules = this.getPairedRules().filter(rule => rule.open === rule.close);
|
|
219
|
+
for (const rule of symmetricRules) {
|
|
220
|
+
const repeatedCharacter = getRepeatedTokenCharacter(rule.open);
|
|
221
|
+
if (repeatedCharacter && suppressedCharacters.has(repeatedCharacter)) continue;
|
|
222
|
+
const unmatchedOpenIndex = findLastUnmatchedSymmetricOpen(nextValue, rule.open);
|
|
223
|
+
if (-1 !== unmatchedOpenIndex) if (hasMeaningfulInlineContent(nextValue.slice(unmatchedOpenIndex + rule.open.length), repeatedCharacter)) {
|
|
224
|
+
if (repeatedCharacter) {
|
|
225
|
+
const trailingRunLength = countTrailingRepeatedCharacter(nextValue, repeatedCharacter), remainingCharacters = Math.max(rule.close.length - trailingRunLength, 0);
|
|
226
|
+
nextValue += repeatedCharacter.repeat(remainingCharacters);
|
|
227
|
+
} else nextValue += rule.close;
|
|
228
|
+
repeatedCharacter && suppressedCharacters.add(repeatedCharacter);
|
|
229
|
+
} else nextValue = nextValue.slice(0, unmatchedOpenIndex), repeatedCharacter && suppressedCharacters.add(repeatedCharacter);
|
|
230
|
+
}
|
|
231
|
+
return nextValue;
|
|
232
|
+
}
|
|
233
|
+
closeAsymmetricPairedMarkers(value, counts) {
|
|
234
|
+
var _a, _b;
|
|
235
|
+
let nextValue = value;
|
|
236
|
+
const asymmetricRules = this.getPairedRules().filter(rule => rule.open !== rule.close);
|
|
237
|
+
for (const rule of asymmetricRules) {
|
|
238
|
+
const openCount = null !== (_a = counts[rule.open]) && void 0 !== _a ? _a : 0, closeCount = null !== (_b = counts[rule.close]) && void 0 !== _b ? _b : 0;
|
|
239
|
+
openCount > closeCount && (nextValue += rule.close.repeat(openCount - closeCount));
|
|
240
|
+
}
|
|
241
|
+
return nextValue;
|
|
242
|
+
}
|
|
243
|
+
closeLineMarkers(value) {
|
|
244
|
+
var _a, _b, _c, _d;
|
|
245
|
+
let nextValue = value;
|
|
246
|
+
const trailingLine = null !== (_a = nextValue.split("\n").at(-1)) && void 0 !== _a ? _a : "";
|
|
247
|
+
if (0 === trailingLine.trim().length) return nextValue;
|
|
248
|
+
const trailingLineStart = nextValue.length - trailingLine.length, lineRules = this.watchedMarkers.filter(rule => {
|
|
249
|
+
var _a;
|
|
250
|
+
return "line" === (null !== (_a = rule.mode) && void 0 !== _a ? _a : "paired");
|
|
251
|
+
});
|
|
252
|
+
for (const rule of lineRules) {
|
|
253
|
+
if (rule.linePattern) {
|
|
254
|
+
if (!rule.linePattern.test(trailingLine)) continue;
|
|
255
|
+
nextValue += rule.close;
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
if (rule.requiresLineStart && !trailingLine.startsWith(rule.open)) continue;
|
|
259
|
+
const remaining = trailingLine.slice(rule.open.length).trim();
|
|
260
|
+
if (!(null === (_b = rule.requiresContent) || void 0 === _b || _b) || 0 !== remaining.length) {
|
|
261
|
+
nextValue += rule.close;
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
for (const rule of lineRules) {
|
|
266
|
+
if (null === (_c = rule.partialLinePattern) || void 0 === _c ? void 0 : _c.test(trailingLine)) return nextValue.slice(0, trailingLineStart);
|
|
267
|
+
if (!rule.requiresLineStart || !trailingLine.startsWith(rule.open)) continue;
|
|
268
|
+
if (null !== (_d = rule.requiresContent) && void 0 !== _d && !_d) continue;
|
|
269
|
+
if (0 === trailingLine.slice(rule.open.length).trim().length) return nextValue.slice(0, trailingLineStart);
|
|
270
|
+
}
|
|
271
|
+
return nextValue;
|
|
272
|
+
}
|
|
273
|
+
closeTrailingLink(value, construct) {
|
|
274
|
+
if (!construct.labelClosed) return value.slice(0, construct.start);
|
|
275
|
+
if (construct.parenOpened) {
|
|
276
|
+
const linkPreview = `${value.slice(construct.start, construct.labelEnd + 1)}()`;
|
|
277
|
+
return `${value.slice(0, construct.start)}${linkPreview}`;
|
|
278
|
+
}
|
|
279
|
+
return construct.labelEnd === value.length - 1 ? value.slice(0, construct.start) : value;
|
|
280
|
+
}
|
|
281
|
+
closeTrailingImage(value, construct) {
|
|
282
|
+
return construct.labelClosed ? construct.parenOpened || construct.labelEnd === value.length - 1 ? value.slice(0, construct.start) : `${value.slice(0, construct.start)}${value.slice(construct.labelEnd + 1)}` : value.slice(0, construct.start);
|
|
283
|
+
}
|
|
284
|
+
closeTrailingImageSignal(value) {
|
|
285
|
+
const lastBangIndex = value.lastIndexOf("!");
|
|
286
|
+
return -1 === lastBangIndex || lastBangIndex !== value.length - 1 || isEscaped(value, lastBangIndex) ? value : value.slice(0, lastBangIndex);
|
|
287
|
+
}
|
|
288
|
+
findTrailingLink(value) {
|
|
289
|
+
const construct = this.findTrailingInlineConstruct(value, !1);
|
|
290
|
+
return construct ? construct.labelClosed ? construct.parenOpened || construct.labelEnd === value.length - 1 ? construct : null : construct : null;
|
|
291
|
+
}
|
|
292
|
+
findTrailingImage(value) {
|
|
293
|
+
return this.findTrailingInlineConstruct(value, !0);
|
|
294
|
+
}
|
|
295
|
+
findTrailingInlineConstruct(value, isImage) {
|
|
296
|
+
var _a;
|
|
297
|
+
const stack = [];
|
|
298
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
299
|
+
if (isEscaped(value, index)) continue;
|
|
300
|
+
const character = value[index];
|
|
301
|
+
if ("[" === character) {
|
|
302
|
+
const isImage = index > 0 && "!" === value[index - 1] && !isEscaped(value, index - 1);
|
|
303
|
+
stack.push({
|
|
304
|
+
start: isImage ? index - 1 : index,
|
|
305
|
+
isImage: isImage,
|
|
306
|
+
labelClosed: !1,
|
|
307
|
+
labelEnd: -1,
|
|
308
|
+
parenOpened: !1
|
|
309
|
+
});
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
if ("]" === character) {
|
|
313
|
+
const target = [ ...stack ].reverse().find(item => !item.labelClosed);
|
|
314
|
+
if (!target) continue;
|
|
315
|
+
target.labelClosed = !0, target.labelEnd = index;
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
if ("(" === character) {
|
|
319
|
+
const target = [ ...stack ].reverse().find(item => item.labelClosed && !item.parenOpened && item.labelEnd === index - 1);
|
|
320
|
+
if (!target) continue;
|
|
321
|
+
target.parenOpened = !0;
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
if (")" === character) {
|
|
325
|
+
const targetIndex = null === (_a = [ ...stack ].map((item, stackIndex) => ({
|
|
326
|
+
item: item,
|
|
327
|
+
stackIndex: stackIndex
|
|
328
|
+
})).reverse().find(({item: item}) => item.parenOpened)) || void 0 === _a ? void 0 : _a.stackIndex;
|
|
329
|
+
"number" == typeof targetIndex && stack.splice(targetIndex, 1);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
const trailingConstruct = stack.findLast(item => item.isImage === isImage);
|
|
333
|
+
return null != trailingConstruct ? trailingConstruct : null;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function isEscaped(value, index) {
|
|
338
|
+
let slashCount = 0;
|
|
339
|
+
for (let cursor = index - 1; cursor >= 0 && "\\" === value[cursor]; cursor -= 1) slashCount += 1;
|
|
340
|
+
return slashCount % 2 != 0;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function isStarListMarker(value, index) {
|
|
344
|
+
return (0 === index || "\n" === value[index - 1]) && " " === value[index + 1];
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function getRepeatedTokenCharacter(token) {
|
|
348
|
+
return 0 === token.length ? null : token.split("").every(character => character === token[0]) ? token[0] : null;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function countTrailingRepeatedCharacter(value, character) {
|
|
352
|
+
let count = 0;
|
|
353
|
+
for (let index = value.length - 1; index >= 0 && value[index] === character; index -= 1) count += 1;
|
|
354
|
+
return count;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function shouldIgnoreSymmetricToken(value, token, index) {
|
|
358
|
+
var _a, _b;
|
|
359
|
+
if (!token.includes("_")) return !1;
|
|
360
|
+
const previousCharacter = null !== (_a = value[index - 1]) && void 0 !== _a ? _a : "", nextCharacter = null !== (_b = value[index + token.length]) && void 0 !== _b ? _b : "";
|
|
361
|
+
return isWordCharacter(previousCharacter) || isWordCharacter(nextCharacter);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function isWordCharacter(value) {
|
|
365
|
+
return /[A-Za-z0-9]/.test(value);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function findLastUnmatchedSymmetricOpen(value, token) {
|
|
369
|
+
let occurrenceCount = 0, lastIndex = -1;
|
|
370
|
+
for (let index = 0; index <= value.length - token.length; index += 1) isEscaped(value, index) || value.slice(index, index + token.length) === token && (shouldIgnoreSymmetricToken(value, token, index) || (occurrenceCount += 1,
|
|
371
|
+
lastIndex = index, index += token.length - 1));
|
|
372
|
+
return occurrenceCount % 2 == 0 ? -1 : lastIndex;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function hasMeaningfulInlineContent(value, repeatedCharacter) {
|
|
376
|
+
if (0 === value.trim().length) return !1;
|
|
377
|
+
if (!repeatedCharacter) return !0;
|
|
378
|
+
return value.replaceAll(repeatedCharacter, "").trim().length > 0;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export { MdBuffer as M };
|
|
@@ -6,11 +6,11 @@ import { useTheme } from "../hooks/useTheme.mjs";
|
|
|
6
6
|
|
|
7
7
|
import "../theme/colors.mjs";
|
|
8
8
|
|
|
9
|
-
import "../hooks/useWindow.mjs";
|
|
10
|
-
|
|
11
9
|
import { _ as __rest } from "./tslib.es6-c-7TIv71.mjs";
|
|
12
10
|
|
|
13
|
-
import
|
|
11
|
+
import "../hooks/useWindow.mjs";
|
|
12
|
+
|
|
13
|
+
import { I as Icon } from "./Icon-CbwaBi0l.mjs";
|
|
14
14
|
|
|
15
15
|
import { s as styleInject } from "./style-inject.es-D0BjEaN8.mjs";
|
|
16
16
|
|
|
@@ -6,11 +6,13 @@ import { useTheme } from "../hooks/useTheme.mjs";
|
|
|
6
6
|
|
|
7
7
|
import "../theme/colors.mjs";
|
|
8
8
|
|
|
9
|
+
import "./tslib.es6-c-7TIv71.mjs";
|
|
10
|
+
|
|
9
11
|
import "../hooks/useWindow.mjs";
|
|
10
12
|
|
|
11
|
-
import { B as Button } from "./Button-
|
|
13
|
+
import { B as Button } from "./Button-Bp51g5jC.mjs";
|
|
12
14
|
|
|
13
|
-
import { F as FileList } from "./FileList-
|
|
15
|
+
import { F as FileList } from "./FileList-CyUhkk-m.mjs";
|
|
14
16
|
|
|
15
17
|
import { s as styleInject } from "./style-inject.es-D0BjEaN8.mjs";
|
|
16
18
|
|
|
@@ -6,7 +6,7 @@ import React, { useState, useEffect, useCallback, useMemo } from "react";
|
|
|
6
6
|
|
|
7
7
|
import { s as setStyle } from "./misc-N8KLjOXc.mjs";
|
|
8
8
|
|
|
9
|
-
import { I as Icon } from "./Icon-
|
|
9
|
+
import { I as Icon } from "./Icon-CbwaBi0l.mjs";
|
|
10
10
|
|
|
11
11
|
import { s as styleInject } from "./style-inject.es-D0BjEaN8.mjs";
|
|
12
12
|
|
|
@@ -6,7 +6,7 @@ import React, { useId, useState, useEffect, useCallback, useMemo } from "react";
|
|
|
6
6
|
|
|
7
7
|
import { s as setStyle } from "./misc-N8KLjOXc.mjs";
|
|
8
8
|
|
|
9
|
-
import { R as RadioButton } from "./RadioButton-
|
|
9
|
+
import { R as RadioButton } from "./RadioButton-CYp8RkDK.mjs";
|
|
10
10
|
|
|
11
11
|
import { s as styleInject } from "./style-inject.es-D0BjEaN8.mjs";
|
|
12
12
|
|
|
@@ -12,9 +12,9 @@ import "../hooks/useWindow.mjs";
|
|
|
12
12
|
|
|
13
13
|
import { B as Badge } from "./Badge-DyICxZP2.mjs";
|
|
14
14
|
|
|
15
|
-
import { I as Icon } from "./Icon-
|
|
15
|
+
import { I as Icon } from "./Icon-CbwaBi0l.mjs";
|
|
16
16
|
|
|
17
|
-
import { I as IconButton } from "./IconButton-
|
|
17
|
+
import { I as IconButton } from "./IconButton-BKZD9jsp.mjs";
|
|
18
18
|
|
|
19
19
|
import { T as ToolTipType } from "./sharedTypes-tn9-uJvb.mjs";
|
|
20
20
|
|
|
@@ -4,7 +4,7 @@ import { jsxs, jsx } from "react/jsx-runtime";
|
|
|
4
4
|
|
|
5
5
|
import React, { useState, useRef, useCallback, useEffect, useMemo } from "react";
|
|
6
6
|
|
|
7
|
-
import { B as Button } from "./Button-
|
|
7
|
+
import { B as Button } from "./Button-Bp51g5jC.mjs";
|
|
8
8
|
|
|
9
9
|
import { s as styleInject } from "./style-inject.es-D0BjEaN8.mjs";
|
|
10
10
|
|
|
@@ -28,16 +28,16 @@ const TextArea = React.memo(props => {
|
|
|
28
28
|
}, [ onChange ]), handleFocus = useCallback(() => {
|
|
29
29
|
var _a, _b;
|
|
30
30
|
(null == ref ? void 0 : ref.current) && ref.current.focus(), setIsFocused(!0), onFocus(null !== (_b = null === (_a = ref.current) || void 0 === _a ? void 0 : _a.value) && void 0 !== _b ? _b : "");
|
|
31
|
-
}, [ onFocus ]), handleBlur = useCallback(
|
|
31
|
+
}, [ onFocus ]), handleBlur = useCallback(() => {
|
|
32
32
|
var _a, _b;
|
|
33
|
-
|
|
34
|
-
}, [
|
|
33
|
+
setIsFocused(!1), onBlur(null !== (_b = null === (_a = ref.current) || void 0 === _a ? void 0 : _a.value) && void 0 !== _b ? _b : "");
|
|
34
|
+
}, [ onBlur ]), handleSubmit = useCallback(e => {
|
|
35
35
|
null == e || e.preventDefault(), handleFocus(), onSubmit(text), submitClears && setText(""),
|
|
36
36
|
(null == ref ? void 0 : ref.current) && (ref.current.value = ""), handleResize();
|
|
37
37
|
}, [ handleFocus, onSubmit, text, submitClears, handleResize ]), handleKeyDownWrapper = useCallback(e => {
|
|
38
38
|
returnSubmits && "Enter" === e.key && (e.preventDefault(), e.stopPropagation(),
|
|
39
39
|
handleSubmit(void 0)), onKeyDown(e);
|
|
40
|
-
}, [ returnSubmits, handleSubmit, onKeyDown ]), setStyleValue = useCallback(value => "string" == typeof value ? value : `${value}px`, []), setBorderColor = useMemo(() => isFocused ? "var(--core-link-primary)" : error ? "var(--feedback-warning)" : border ? "var(--core-outline-primary)" : "transparent", [ isFocused, error, border ]), textClassName = useMemo(() => "xs" === textSize ? css_xs : "l" === textSize ? css_l : "m" === textSize ? css_m : css_s, [ textSize ]), cssVars = useMemo(() => ({
|
|
40
|
+
}, [ returnSubmits, handleSubmit, onKeyDown ]), setStyleValue = useCallback(value => "string" == typeof value ? value : `${value}px`, []), setBorderColor = useMemo(() => border && isFocused ? "var(--core-link-primary)" : border && error ? "var(--feedback-warning)" : border ? "var(--core-outline-primary)" : "transparent", [ isFocused, error, border ]), textClassName = useMemo(() => "xs" === textSize ? css_xs : "l" === textSize ? css_l : "m" === textSize ? css_m : css_s, [ textSize ]), cssVars = useMemo(() => ({
|
|
41
41
|
"--ta-border-radius": `${borderRadius}px`,
|
|
42
42
|
"--ta-width": `${setStyleValue(width)}`,
|
|
43
43
|
"--ta-min-width": minWidth ? `${minWidth}px` : "unset",
|
|
@@ -53,7 +53,7 @@ const TextArea = React.memo(props => {
|
|
|
53
53
|
id: divId,
|
|
54
54
|
className: `${css_wrapper}${divClass}`,
|
|
55
55
|
style: Object.assign(Object.assign({}, divStyle), cssVars),
|
|
56
|
-
onBlur: () => handleBlur(
|
|
56
|
+
onBlur: () => handleBlur(),
|
|
57
57
|
onFocus: () => handleFocus()
|
|
58
58
|
}, rest, {
|
|
59
59
|
children: [ hasSend && jsx("div", {
|
|
@@ -10,15 +10,15 @@ import { useTheme } from "../hooks/useTheme.mjs";
|
|
|
10
10
|
|
|
11
11
|
import "../theme/colors.mjs";
|
|
12
12
|
|
|
13
|
-
import "../hooks/useWindow.mjs";
|
|
14
|
-
|
|
15
13
|
import { s as setStyle } from "./misc-N8KLjOXc.mjs";
|
|
16
14
|
|
|
17
|
-
import
|
|
15
|
+
import "../hooks/useWindow.mjs";
|
|
16
|
+
|
|
17
|
+
import { B as Button } from "./Button-Bp51g5jC.mjs";
|
|
18
18
|
|
|
19
|
-
import { I as Icon } from "./Icon-
|
|
19
|
+
import { I as Icon } from "./Icon-CbwaBi0l.mjs";
|
|
20
20
|
|
|
21
|
-
import { I as IconButton } from "./IconButton-
|
|
21
|
+
import { I as IconButton } from "./IconButton-BKZD9jsp.mjs";
|
|
22
22
|
|
|
23
23
|
import { s as styleInject } from "./style-inject.es-D0BjEaN8.mjs";
|
|
24
24
|
|
|
@@ -54,32 +54,26 @@ const MOTION_CONFIG = {
|
|
|
54
54
|
duration: .25
|
|
55
55
|
}
|
|
56
56
|
}, TextField = React.memo(props => {
|
|
57
|
-
const theme = useTheme(), {name: name = "input_name", value: value = "", label: label = "", labelSize: labelSize = "m", textSize: textSize = "m", placeholder: placeholder = "placeholder", focused: focused = !1, onSubmit: onSubmit = () => null, onChange: onChange = () => null, onBlur: onBlur = () => null, onFocus: onFocus = () => null, onKeydown: onKeydown = () => null, onAction: onAction = () => null, onPaste: onPaste = () => null, onClear: onClear = () => null,
|
|
57
|
+
const theme = useTheme(), {name: name = "input_name", value: value = "", label: label = "", labelSize: labelSize = "m", textSize: textSize = "m", placeholder: placeholder = "placeholder", focused: focused = !1, onSubmit: onSubmit = () => null, onChange: onChange = () => null, onBlur: onBlur = () => null, onFocus: onFocus = () => null, onKeydown: onKeydown = () => null, onAction: onAction = () => null, onPaste: onPaste = () => null, onClear: onClear = () => null, actionButton: actionButton = !1, maxLength: maxLength, size: size = {
|
|
58
58
|
width: "100%",
|
|
59
59
|
height: "auto"
|
|
60
|
-
}, padding: padding, borderRadius: borderRadius = 8, editable: editable = !0, textAlign: textAlign = "left",
|
|
60
|
+
}, padding: padding, borderRadius: borderRadius = 8, editable: editable = !0, textAlign: textAlign = "left", inline: inline = !1, noShow: noShow = !1, borderType: borderType = "box", error: error = !1, borderColorFocused: borderColorFocused = "var(--core-link-primary)", borderColorBlurred: borderColorBlurred = "var(--core-outline-primary)", borderColorError: borderColorError = "var(--feedback-warning)", backgroundColorFocused: backgroundColorFocused = "var(--core-surface-secondary)", backgroundColorBlurred: backgroundColorBlurred = "var(--core-surface-secondary)", textColorFocused: textColorFocused = "var(--core-text-primary)", textColorBlurred: textColorBlurred = "var(--core-text-primary)", textColorError: textColorError = "var(--feedback-warning)", textColorPlaceholder: textColorPlaceholder = "var(--core-text-disabled)", textColorDisabled: textColorDisabled = "var(--core-text-disabled)", labelColor: labelColor = "var(--core-text-primary)", iconLeft: iconLeft = null, clearButton: clearButton = {
|
|
61
61
|
size: 20
|
|
62
|
-
}, clearBlurs: clearBlurs = !1, disabled: disabled = !1, inputType: inputType = "text"} = props, divAttributes = __rest(props, [ "name", "value", "label", "labelSize", "textSize", "placeholder", "focused", "onSubmit", "onChange", "onBlur", "onFocus", "onKeydown", "onAction", "onPaste", "onClear", "
|
|
62
|
+
}, clearBlurs: clearBlurs = !1, disabled: disabled = !1, inputType: inputType = "text"} = props, divAttributes = __rest(props, [ "name", "value", "label", "labelSize", "textSize", "placeholder", "focused", "onSubmit", "onChange", "onBlur", "onFocus", "onKeydown", "onAction", "onPaste", "onClear", "actionButton", "maxLength", "size", "padding", "borderRadius", "editable", "textAlign", "inline", "noShow", "borderType", "error", "borderColorFocused", "borderColorBlurred", "borderColorError", "backgroundColorFocused", "backgroundColorBlurred", "textColorFocused", "textColorBlurred", "textColorError", "textColorPlaceholder", "textColorDisabled", "labelColor", "iconLeft", "clearButton", "clearBlurs", "disabled", "inputType" ]), {id: divId, className: className, style: style} = divAttributes, rest = __rest(divAttributes, [ "id", "className", "style" ]), divStyle = null != style ? style : {}, divClass = className ? ` ${className}` : "", input = useRef(null), [text, setText] = useState(value), [isFocused, setIsFocused] = useState(focused), [show, setShow] = useState(!1);
|
|
63
63
|
useEffect(() => {
|
|
64
64
|
input.current && (focused ? input.current.focus() : input.current.blur(), setIsFocused(focused));
|
|
65
65
|
}, [ focused ]), useEffect(() => {
|
|
66
66
|
setText(value);
|
|
67
|
-
}, [ value ])
|
|
68
|
-
|
|
69
|
-
}, [ isValid ]);
|
|
70
|
-
const textIsValid = useCallback(entry => {
|
|
71
|
-
if (!validate) return;
|
|
72
|
-
const ok = entry.length > 1 || "" === entry;
|
|
73
|
-
setValid(ok), valid !== ok && onValidate(ok);
|
|
74
|
-
}, [ onValidate, valid, validate ]), handleClearTextField = useCallback(() => {
|
|
67
|
+
}, [ value ]);
|
|
68
|
+
const handleClearTextField = useCallback(() => {
|
|
75
69
|
var _a;
|
|
76
70
|
disabled || "" === (null === (_a = input.current) || void 0 === _a ? void 0 : _a.value) || ((null == input ? void 0 : input.current) && (clearBlurs || input.current.focus(),
|
|
77
|
-
setText("")
|
|
78
|
-
}, [ disabled, clearBlurs, onChange, onClear
|
|
79
|
-
disabled || (setText(newValue), onChange(newValue)
|
|
80
|
-
}, [ onChange,
|
|
81
|
-
disabled || (
|
|
82
|
-
}, [ text, onBlur,
|
|
71
|
+
setText("")), onChange(""), onClear());
|
|
72
|
+
}, [ disabled, clearBlurs, onChange, onClear ]), handleValueChange = useCallback(newValue => {
|
|
73
|
+
disabled || (setText(newValue), onChange(newValue));
|
|
74
|
+
}, [ onChange, disabled ]), handleBlur = useCallback(() => {
|
|
75
|
+
disabled || (setIsFocused(!1), onBlur(text));
|
|
76
|
+
}, [ text, onBlur, disabled ]), handleKeyDown = useCallback(e => {
|
|
83
77
|
var _a;
|
|
84
78
|
if (!disabled) {
|
|
85
79
|
if ("Enter" === e.key && (handleBlur(), onSubmit(text), null === (_a = input.current) || void 0 === _a || _a.blur()),
|
|
@@ -98,8 +92,8 @@ const MOTION_CONFIG = {
|
|
|
98
92
|
minHeight: clearButton.size
|
|
99
93
|
} : void 0, [ clearButton ]), setBackgroundColor = useMemo(() => inline ? "unset" : isFocused ? null != backgroundColorFocused ? backgroundColorFocused : "transparent" : null != backgroundColorBlurred ? backgroundColorBlurred : "transparent", [ inline, isFocused, backgroundColorFocused, backgroundColorBlurred ]), setBorderColor = useMemo(() => {
|
|
100
94
|
var _a, _b;
|
|
101
|
-
return "none" === borderType ? "transparent" :
|
|
102
|
-
}, [ borderType,
|
|
95
|
+
return "none" === borderType ? "transparent" : error ? null !== (_a = null != borderColorError ? borderColorError : borderColorBlurred) && void 0 !== _a ? _a : "transparent" : isFocused ? null !== (_b = null != borderColorFocused ? borderColorFocused : borderColorBlurred) && void 0 !== _b ? _b : "transparent" : null != borderColorBlurred ? borderColorBlurred : "transparent";
|
|
96
|
+
}, [ borderType, error, isFocused, borderColorError, borderColorFocused, borderColorBlurred ]), setBoxShadow = useMemo(() => "none" === borderType ? "unset" : "underline" === borderType ? `0 1px 0 0 ${setBorderColor}` : `0 0 0 1px ${setBorderColor}`, [ borderType, setBorderColor ]), textColor = useMemo(() => error ? null != textColorError ? textColorError : "var(--core-text-primary)" : isFocused ? null != textColorFocused ? textColorFocused : "var(--core-text-primary)" : null != textColorBlurred ? textColorBlurred : "var(--core-text-primary)", [ isFocused, error, textColorError, textColorFocused, textColorBlurred ]), setTextAlign = useMemo(() => null != textAlign ? textAlign : "left", [ textAlign ]), setShowOpacity = useMemo(() => "password" !== inputType ? "0" : isFocused ? "1" : "0.5", [ inputType, isFocused ]), setPaddingRight = useMemo(() => {
|
|
103
97
|
const defaultPadding = clearButton ? 8 : 16;
|
|
104
98
|
if (!padding) return defaultPadding;
|
|
105
99
|
if ("string" == typeof padding) {
|
|
@@ -204,7 +198,7 @@ const MOTION_CONFIG = {
|
|
|
204
198
|
}) ]
|
|
205
199
|
}) ]
|
|
206
200
|
}));
|
|
207
|
-
}, (prevProps, nextProps) => prevProps.value === nextProps.value && prevProps.borderType === nextProps.borderType && prevProps.borderRadius === nextProps.borderRadius && prevProps.borderColorFocused === nextProps.borderColorFocused && prevProps.borderColorBlurred === nextProps.borderColorBlurred && prevProps.borderColorError === nextProps.borderColorError && prevProps.backgroundColorFocused === nextProps.backgroundColorFocused && prevProps.backgroundColorBlurred === nextProps.backgroundColorBlurred && prevProps.textColorFocused === nextProps.textColorFocused && prevProps.textColorBlurred === nextProps.textColorBlurred && prevProps.textColorError === nextProps.textColorError && prevProps.textColorPlaceholder === nextProps.textColorPlaceholder && prevProps.textColorDisabled === nextProps.textColorDisabled && prevProps.labelColor === nextProps.labelColor && prevProps.labelSize === nextProps.labelSize && prevProps.focused === nextProps.focused && prevProps.
|
|
201
|
+
}, (prevProps, nextProps) => prevProps.value === nextProps.value && prevProps.borderType === nextProps.borderType && prevProps.borderRadius === nextProps.borderRadius && prevProps.borderColorFocused === nextProps.borderColorFocused && prevProps.borderColorBlurred === nextProps.borderColorBlurred && prevProps.borderColorError === nextProps.borderColorError && prevProps.backgroundColorFocused === nextProps.backgroundColorFocused && prevProps.backgroundColorBlurred === nextProps.backgroundColorBlurred && prevProps.textColorFocused === nextProps.textColorFocused && prevProps.textColorBlurred === nextProps.textColorBlurred && prevProps.textColorError === nextProps.textColorError && prevProps.textColorPlaceholder === nextProps.textColorPlaceholder && prevProps.textColorDisabled === nextProps.textColorDisabled && prevProps.labelColor === nextProps.labelColor && prevProps.labelSize === nextProps.labelSize && prevProps.focused === nextProps.focused && prevProps.error === nextProps.error && prevProps.disabled === nextProps.disabled && prevProps.label === nextProps.label && prevProps.inputType === nextProps.inputType && prevProps.textSize === nextProps.textSize && prevProps.padding === nextProps.padding && prevProps.textAlign === nextProps.textAlign && prevProps.placeholder === nextProps.placeholder);
|
|
208
202
|
|
|
209
203
|
TextField.displayName = "TextField";
|
|
210
204
|
|
|
@@ -10,11 +10,11 @@ import { useTheme } from "../hooks/useTheme.mjs";
|
|
|
10
10
|
|
|
11
11
|
import "../theme/colors.mjs";
|
|
12
12
|
|
|
13
|
-
import "../hooks/useWindow.mjs";
|
|
14
|
-
|
|
15
13
|
import { s as setStyle, f as filterClasses, a as accessibleKeyDown } from "./misc-N8KLjOXc.mjs";
|
|
16
14
|
|
|
17
|
-
import
|
|
15
|
+
import "../hooks/useWindow.mjs";
|
|
16
|
+
|
|
17
|
+
import { I as Icon } from "./Icon-CbwaBi0l.mjs";
|
|
18
18
|
|
|
19
19
|
import { s as styleInject } from "./style-inject.es-D0BjEaN8.mjs";
|
|
20
20
|
|
|
@@ -4,11 +4,11 @@ import React, { useState, useRef, useId, useCallback, useMemo } from "react";
|
|
|
4
4
|
|
|
5
5
|
import { s as setStyle, a as accessibleKeyDown } from "./misc-N8KLjOXc.mjs";
|
|
6
6
|
|
|
7
|
-
import { F as FileList } from "./FileList-
|
|
7
|
+
import { F as FileList } from "./FileList-CyUhkk-m.mjs";
|
|
8
8
|
|
|
9
|
-
import { I as Icon } from "./Icon-
|
|
9
|
+
import { I as Icon } from "./Icon-CbwaBi0l.mjs";
|
|
10
10
|
|
|
11
|
-
import { P as ProgressIndicator } from "./ProgressIndicator-
|
|
11
|
+
import { P as ProgressIndicator } from "./ProgressIndicator-Cg7CCrAE.mjs";
|
|
12
12
|
|
|
13
13
|
import { s as styleInject } from "./style-inject.es-D0BjEaN8.mjs";
|
|
14
14
|
|