@tellescope/react-components 1.192.0 → 1.194.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellescope/react-components",
3
- "version": "1.192.0",
3
+ "version": "1.194.0",
4
4
  "description": "",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -47,13 +47,13 @@
47
47
  "@reduxjs/toolkit": "^1.6.2",
48
48
  "@stripe/react-stripe-js": "^2.9.0",
49
49
  "@stripe/stripe-js": "^1.52.1",
50
- "@tellescope/constants": "^1.192.0",
51
- "@tellescope/sdk": "^1.192.0",
52
- "@tellescope/types-client": "^1.192.0",
53
- "@tellescope/types-models": "^1.192.0",
54
- "@tellescope/types-utilities": "^1.192.0",
55
- "@tellescope/utilities": "^1.192.0",
56
- "@tellescope/validation": "^1.192.0",
50
+ "@tellescope/constants": "^1.194.0",
51
+ "@tellescope/sdk": "^1.194.0",
52
+ "@tellescope/types-client": "^1.194.0",
53
+ "@tellescope/types-models": "^1.194.0",
54
+ "@tellescope/types-utilities": "^1.194.0",
55
+ "@tellescope/utilities": "^1.194.0",
56
+ "@tellescope/validation": "^1.194.0",
57
57
  "@typescript-eslint/eslint-plugin": "^4.33.0",
58
58
  "@typescript-eslint/parser": "^4.33.0",
59
59
  "css-to-react-native": "^3.0.0",
@@ -84,7 +84,7 @@
84
84
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
85
85
  "react-native": "^0.65.0 || ^0.66.0 || ^0.67.0 || ^0.68.0 || ^0.71.0"
86
86
  },
87
- "gitHead": "2b5f692acec9d31bd3e7ec8b41a08f2a39278239",
87
+ "gitHead": "aef702a95cf13209de35fc09eb6a628c10db0007",
88
88
  "publishConfig": {
89
89
  "access": "public"
90
90
  }
@@ -1516,14 +1516,14 @@ export const MultipleChoiceInput = ({ field, form, value: _value, onChange }: Fo
1516
1516
  (
1517
1517
  value?.includes(c)
1518
1518
  ? (
1519
- radio
1519
+ (radio || field.options?.radioChoices?.includes(c))
1520
1520
  ? []
1521
1521
  : value.filter(v => v !== c)
1522
1522
  )
1523
1523
  : (
1524
- radio
1524
+ (radio || field.options?.radioChoices?.includes(c))
1525
1525
  ? [c]
1526
- : [...(value ?? []), c]
1526
+ : [...(value ?? []).filter(x => !field.options?.radioChoices?.includes(x)), c]
1527
1527
  )
1528
1528
  ),
1529
1529
  field.id,
package/src/displays.tsx CHANGED
@@ -189,4 +189,118 @@ export const useDisplayInfoForSenderId = (id: string) => {
189
189
 
190
190
  if (session.userInfo.id === id) return session.userInfo
191
191
  return findUser(id) ?? findEnduser(id)
192
+ }
193
+
194
+ const WHITE_SPACE_EXP = /^\s*$/
195
+ const is_whitespace = (str: string) => WHITE_SPACE_EXP.test(str)
196
+ const [ LINK_START, LINK_END, TEXT_START, TEXT_END, STYLE_START, STYLE_END ] = [0, 1, 2, 3, 4, 5]
197
+ const find_link = (text: string, startFrom?: number) => {
198
+ let start = 0
199
+ let state = LINK_START
200
+ let linkChars = []
201
+ const linkTextChars = []
202
+
203
+ for (let i = startFrom || 0; i < text.length; i++) {
204
+ const char = text[i]
205
+ if (state === LINK_START) {
206
+ if (char === '{') {
207
+ start = i;
208
+ state = LINK_END
209
+ }
210
+ }
211
+ else if (state === LINK_END) {
212
+ if (char === '}') {
213
+ state = TEXT_START
214
+ } else {
215
+ linkChars.push(char)
216
+ }
217
+ }
218
+ else if (state === TEXT_START) {
219
+ if (char === '[') {
220
+ state = TEXT_END
221
+ }
222
+ else if (!is_whitespace(char)) { // only allow whitespace between {link} and [linkText]
223
+ start = 0; linkChars = []; state = LINK_START; // start seeking new link
224
+ }
225
+ }
226
+ else {
227
+ if (char === ']') {
228
+ return {
229
+ start,
230
+ end: i,
231
+ link: linkChars.join(''),
232
+ linkText: linkTextChars.join('')
233
+ }
234
+ } else {
235
+ linkTextChars.push(char)
236
+ }
237
+ }
238
+ }
239
+
240
+ return undefined
241
+ }
242
+
243
+ const find_link_style = (text: string, startFrom?: number) => {
244
+ let state = STYLE_START
245
+ const textChars: string[] = []
246
+ const styleChars: string[] = []
247
+
248
+ for (let i = startFrom || 0; i < text.length; i++) {
249
+ const char = text[i]
250
+ if (state === STYLE_START) {
251
+ if (char === '<') {
252
+ state = STYLE_END
253
+ } else {
254
+ textChars.push(char)
255
+ }
256
+ }
257
+ else if (state === STYLE_END) {
258
+ if (char === '>') {
259
+ return {
260
+ unstyledText: textChars.join(''),
261
+ style: styleChars.join(''),
262
+ }
263
+ } else {
264
+ styleChars.push(char)
265
+ }
266
+ }
267
+ }
268
+
269
+ return { unstyledText: text, style: '' }
270
+ }
271
+
272
+ export const replace_links = (html: string) => {
273
+ let foundLink = undefined
274
+ while ((foundLink = find_link(html))) {
275
+ const { link, linkText } = foundLink
276
+ const { unstyledText: _unstyledText, style } = find_link_style(linkText)
277
+ const linkTemplate = `{${link}}[${linkText}]`
278
+
279
+ if (linkText === "$LINK_ONLY") {
280
+ if (html !== undefined && typeof html === 'string') {
281
+ html = html.replace(linkTemplate, link)
282
+ }
283
+
284
+ continue
285
+ }
286
+
287
+ // if _unstyled text is empty, undefined, etc, default to the link itself
288
+ const unstyledText = (
289
+ (typeof _unstyledText === 'string' && !_unstyledText?.trim())
290
+ ? link
291
+ : !_unstyledText
292
+ ? link
293
+ : _unstyledText === 'undefined'
294
+ ? link
295
+ : _unstyledText
296
+ )
297
+
298
+ const replacementHTML = (
299
+ `<a${style ? ` style="${style}"` : ''} href="${link}" target="_blank">${unstyledText}</a>`
300
+ )
301
+
302
+ html = html.replace(linkTemplate, replacementHTML)
303
+ }
304
+
305
+ return <span dangerouslySetInnerHTML={{ __html: html }} />
192
306
  }