playbook_ui 15.7.0.pre.alpha.PLAY2675dropdownquickpickcustomquickpickdates13330 → 15.7.0.pre.alpha.play2607setheightofeditor13370

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 (52) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +1 -13
  3. data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +0 -2
  4. data/app/pb_kits/playbook/pb_dropdown/docs/index.js +1 -2
  5. data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +1 -6
  6. data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +0 -121
  7. data/app/pb_kits/playbook/pb_dropdown/quickpick/index.ts +9 -85
  8. data/app/pb_kits/playbook/pb_dropdown/quickpick_helper.rb +2 -83
  9. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.rb +9 -7
  10. data/app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js +3 -8
  11. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/Toolbar.tsx +1 -1
  12. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +8 -3
  13. data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +53 -0
  14. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_height.jsx +71 -0
  15. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_height.md +1 -0
  16. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_min_heigh.md +1 -0
  17. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_min_height.jsx +71 -0
  18. data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +2 -0
  19. data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +3 -1
  20. data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +41 -3
  21. data/app/pb_kits/playbook/pb_text_input/docs/_text_input_emoji_mask.html.erb +7 -0
  22. data/app/pb_kits/playbook/pb_text_input/docs/_text_input_emoji_mask.jsx +24 -0
  23. data/app/pb_kits/playbook/pb_text_input/docs/_text_input_emoji_mask.md +2 -0
  24. data/app/pb_kits/playbook/pb_text_input/docs/example.yml +2 -0
  25. data/app/pb_kits/playbook/pb_text_input/docs/index.js +1 -0
  26. data/app/pb_kits/playbook/pb_text_input/index.js +49 -8
  27. data/app/pb_kits/playbook/pb_text_input/text_input.rb +5 -1
  28. data/app/pb_kits/playbook/pb_text_input/text_input.test.js +53 -0
  29. data/app/pb_kits/playbook/pb_textarea/_textarea.tsx +38 -2
  30. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_emoji_mask.html.erb +5 -0
  31. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_emoji_mask.jsx +24 -0
  32. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_emoji_mask.md +1 -0
  33. data/app/pb_kits/playbook/pb_textarea/docs/example.yml +2 -0
  34. data/app/pb_kits/playbook/pb_textarea/docs/index.js +1 -0
  35. data/app/pb_kits/playbook/pb_textarea/index.ts +62 -5
  36. data/app/pb_kits/playbook/pb_textarea/textarea.html.erb +1 -0
  37. data/app/pb_kits/playbook/pb_textarea/textarea.rb +8 -0
  38. data/app/pb_kits/playbook/pb_textarea/textarea.test.js +57 -2
  39. data/app/pb_kits/playbook/utilities/emojiMask.ts +42 -0
  40. data/dist/chunks/{_typeahead-Ckz1ce-2.js → _typeahead-D0GNUBXn.js} +2 -2
  41. data/dist/chunks/{lib-DxDBrGZX.js → lib-DxCgrqqG.js} +1 -1
  42. data/dist/chunks/vendor.js +3 -3
  43. data/dist/playbook-rails-react-bindings.js +1 -1
  44. data/dist/playbook-rails.js +1 -1
  45. data/dist/playbook.css +1 -1
  46. data/lib/playbook/forms/builder/form_field_builder.rb +2 -0
  47. data/lib/playbook/version.rb +1 -1
  48. metadata +15 -8
  49. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_custom.jsx +0 -56
  50. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_custom.md +0 -10
  51. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_custom_rails.html.erb +0 -64
  52. data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_custom_rails.md +0 -10
@@ -1,5 +1,5 @@
1
- import React from "react"
2
- import { render, screen } from "../utilities/test-utils"
1
+ import React, { useState } from "react"
2
+ import { render, screen, fireEvent } from "../utilities/test-utils"
3
3
 
4
4
  import Textarea from "./_textarea"
5
5
 
@@ -211,3 +211,58 @@ describe("TextArea Kit Props", () => {
211
211
  expect(textarea.required).toBeTruthy()
212
212
  })
213
213
  })
214
+
215
+ describe("Textarea Emoji Mask", () => {
216
+ const TextareaEmojiMask = (props) => {
217
+ const [value, setValue] = useState('')
218
+ const handleOnChange = ({ target }) => {
219
+ setValue(target.value)
220
+ }
221
+
222
+ return (
223
+ <Textarea
224
+ emojiMask
225
+ onChange={handleOnChange}
226
+ value={value}
227
+ {...props}
228
+ />
229
+ )
230
+ }
231
+
232
+ test("removes emoji characters when emojiMask is enabled", () => {
233
+ render(
234
+ <TextareaEmojiMask
235
+ data={{ testid: testId }}
236
+ />
237
+ )
238
+
239
+ const kit = screen.getByTestId(testId)
240
+ const textarea = kit.querySelector("textarea")
241
+
242
+ fireEvent.change(textarea, { target: { value: 'Hello 👋 World 🌍' } })
243
+ expect(textarea.value).toBe('Hello World ')
244
+
245
+ fireEvent.change(textarea, { target: { value: '😀😂🎉' } })
246
+ expect(textarea.value).toBe('')
247
+
248
+ fireEvent.change(textarea, { target: { value: 'Hello World' } })
249
+ expect(textarea.value).toBe('Hello World')
250
+ })
251
+
252
+ test("allows accented characters when emojiMask is enabled", () => {
253
+ render(
254
+ <TextareaEmojiMask
255
+ data={{ testid: testId }}
256
+ />
257
+ )
258
+
259
+ const kit = screen.getByTestId(testId)
260
+ const textarea = kit.querySelector("textarea")
261
+
262
+ fireEvent.change(textarea, { target: { value: 'Café résumé naïve' } })
263
+ expect(textarea.value).toBe('Café résumé naïve')
264
+
265
+ fireEvent.change(textarea, { target: { value: 'àëǒüñ' } })
266
+ expect(textarea.value).toBe('àëǒüñ')
267
+ })
268
+ })
@@ -0,0 +1,42 @@
1
+ // Regex to match emoji/pictographic characters
2
+ // With modifiers: Zero Width Joiner, Variation Selectors, Skin Tone Modifiers
3
+ export const EMOJI_REGEX = /\p{Extended_Pictographic}|\u200D|\uFE0F|[\u{1F3FB}-\u{1F3FF}]/gu
4
+
5
+ // Utility function to strip emojis from text when typing emojis
6
+ export const stripEmojisForTyping = (text: string): string => {
7
+ return text.replace(EMOJI_REGEX, '')
8
+ }
9
+
10
+ // Utility function to strip emojis and clean up whitespace when pasting emojis
11
+ export const stripEmojisForPaste = (text: string): string => {
12
+ return stripEmojisForTyping(text)
13
+ .replace(/\s+/g, ' ')
14
+ .trim()
15
+ }
16
+
17
+ type EmojiMaskResult = {
18
+ value: string
19
+ cursor: number | null
20
+ }
21
+
22
+ // Union type for elements that support emoji masking
23
+ type TextInputElement = HTMLInputElement | HTMLTextAreaElement
24
+
25
+ export const applyEmojiMask = (
26
+ element: TextInputElement
27
+ ): EmojiMaskResult => {
28
+ const cursor = element.selectionStart
29
+ const original = element.value
30
+ const filtered = stripEmojisForTyping(original)
31
+
32
+ if (original !== filtered) {
33
+ const beforeCursor = original.slice(0, cursor || 0)
34
+ const newCursor = stripEmojisForTyping(beforeCursor).length
35
+ element.value = filtered
36
+ element.selectionStart = element.selectionEnd = newCursor
37
+ return { value: filtered, cursor: newCursor }
38
+ }
39
+ return { value: original, cursor }
40
+ }
41
+
42
+