@crystallize/design-system 1.12.0 → 1.13.2

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 (82) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/draggable-block-menu-KKHDNKJA.svg +1 -0
  3. package/dist/index.css +565 -1025
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +3295 -3431
  6. package/dist/index.mjs +3199 -3335
  7. package/package.json +6 -7
  8. package/src/button/Button.stories.tsx +1 -0
  9. package/src/card/card.stories.tsx +1 -0
  10. package/src/checkbox/checkbox.stories.tsx +1 -1
  11. package/src/checkbox/checkbox.tsx +1 -1
  12. package/src/colors/Colors.stories.tsx +3 -3
  13. package/src/dialog/config.tsx +1 -1
  14. package/src/dialog/index.tsx +1 -1
  15. package/src/dropdown-menu/dropdown-menu-item.tsx +2 -2
  16. package/src/dropdown-menu/dropdown-menu-label.tsx +1 -1
  17. package/src/icon-button/IconButton.stories.tsx +1 -0
  18. package/src/iconography/Icon.stories.tsx +1 -0
  19. package/src/inline-radio/inline-radio.stories.tsx +3 -3
  20. package/src/inline-radio/inline-radio.tsx +2 -2
  21. package/src/input/input.tsx +1 -1
  22. package/src/input-with-label/input-with-label.tsx +1 -1
  23. package/src/label/label.stories.tsx +1 -0
  24. package/src/progress/Progress.stories.tsx +2 -1
  25. package/src/progress/progress.tsx +1 -1
  26. package/src/radio/radio.stories.tsx +1 -1
  27. package/src/radio/radio.tsx +1 -1
  28. package/src/rich-text-editor/i18n/translations/en.ts +2 -2
  29. package/src/rich-text-editor/plugins/ActionsPlugin/index.css +3 -0
  30. package/src/rich-text-editor/plugins/ActionsPlugin/index.tsx +1 -2
  31. package/src/rich-text-editor/plugins/AutoLinkPlugin/index.tsx +1 -1
  32. package/src/rich-text-editor/plugins/CodeActionMenuPlugin/components/CopyButton/index.tsx +6 -2
  33. package/src/rich-text-editor/plugins/CodeActionMenuPlugin/components/PrettierButton/index.tsx +10 -6
  34. package/src/rich-text-editor/plugins/CodeActionMenuPlugin/index.css +32 -17
  35. package/src/rich-text-editor/plugins/CodeActionMenuPlugin/index.tsx +3 -4
  36. package/src/rich-text-editor/plugins/DimensionsDetectorPlugin/index.tsx +49 -0
  37. package/src/rich-text-editor/plugins/DraggableBlockPlugin/index.css +14 -14
  38. package/src/rich-text-editor/plugins/DraggableBlockPlugin/index.tsx +4 -4
  39. package/src/rich-text-editor/plugins/FloatingLinkEditorPlugin/index.css +87 -21
  40. package/src/rich-text-editor/plugins/FloatingLinkEditorPlugin/index.tsx +11 -17
  41. package/src/rich-text-editor/plugins/FloatingTextFormatToolbarPlugin/index.css +10 -2
  42. package/src/rich-text-editor/plugins/FloatingTextFormatToolbarPlugin/index.tsx +17 -17
  43. package/src/rich-text-editor/plugins/LinkPlugin/index.tsx +1 -1
  44. package/src/rich-text-editor/plugins/ListMaxIndentLevelPlugin/index.ts +10 -21
  45. package/src/rich-text-editor/plugins/TableActionMenuPlugin/index.css +6 -0
  46. package/src/rich-text-editor/plugins/TableActionMenuPlugin/index.tsx +2 -2
  47. package/src/rich-text-editor/plugins/ToolbarPlugin/index.css +115 -0
  48. package/src/rich-text-editor/plugins/ToolbarPlugin/index.tsx +57 -78
  49. package/src/rich-text-editor/plugins/ToolbarPlugin/insert-table.tsx +5 -5
  50. package/src/rich-text-editor/rich-text-editor-icons.css +213 -0
  51. package/src/rich-text-editor/rich-text-editor.css +33 -913
  52. package/src/rich-text-editor/rich-text-editor.stories.tsx +11 -0
  53. package/src/rich-text-editor/rich-text-editor.tsx +13 -27
  54. package/src/rich-text-editor/themes/CrystallizeRTEditorTheme.ts +1 -1
  55. package/src/rich-text-editor/ui/LinkPreview.tsx +7 -8
  56. package/src/rich-text-editor/utils/getSelectedNode.ts +4 -5
  57. package/src/rich-text-editor/utils/point.ts +4 -7
  58. package/src/rich-text-editor/utils/rect.ts +18 -41
  59. package/src/rich-text-editor/utils/url.ts +1 -2
  60. package/src/select/select-root.tsx +1 -1
  61. package/src/select/select.stories.tsx +1 -1
  62. package/src/select/select.ts +0 -1
  63. package/src/slider/Slider.stories.tsx +2 -1
  64. package/src/slider/slider.tsx +2 -2
  65. package/src/spinner/Spinner.stories.tsx +1 -0
  66. package/src/spinner/index.tsx +1 -1
  67. package/src/tag/Tag.stories.tsx +1 -0
  68. package/dist/camera-CR7D2PNH.svg +0 -1
  69. package/dist/clipboard-OSEFDF25.svg +0 -1
  70. package/dist/gear-ICMT4NTP.svg +0 -1
  71. package/dist/journal-code-XUT44HDV.svg +0 -1
  72. package/dist/lock-WCYOZOHW.svg +0 -1
  73. package/dist/lock-fill-JZSKOSHK.svg +0 -1
  74. package/dist/pencil-fill-STFSC26F.svg +0 -1
  75. package/dist/plug-HGGGEVS3.svg +0 -1
  76. package/dist/plug-fill-OTG3U4TN.svg +0 -1
  77. package/src/rich-text-editor/hooks/useReport.ts +0 -64
  78. package/src/rich-text-editor/plugins/CodeActionMenuPlugin/components/PrettierButton/index.css +0 -14
  79. package/src/rich-text-editor/ui/LinkPreview.css +0 -57
  80. package/src/rich-text-editor/utils/isMobileWidth.ts +0 -7
  81. package/src/rich-text-editor/utils/joinClasses.ts +0 -13
  82. package/src/rich-text-editor/utils/swipe.ts +0 -127
@@ -1,127 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- type Force = [number, number];
10
- type Listener = (force: Force, e: TouchEvent) => void;
11
- type ElementValues = {
12
- start: null | Force;
13
- listeners: Set<Listener>;
14
- handleTouchstart: (e: TouchEvent) => void;
15
- handleTouchend: (e: TouchEvent) => void;
16
- };
17
-
18
- const elements = new WeakMap<HTMLElement, ElementValues>();
19
-
20
- function readTouch(e: TouchEvent): [number, number] | null {
21
- const touch = e.changedTouches[0];
22
- if (touch === undefined) {
23
- return null;
24
- }
25
- return [touch.clientX, touch.clientY];
26
- }
27
-
28
- function addListener(element: HTMLElement, cb: Listener): () => void {
29
- let elementValues = elements.get(element);
30
- if (elementValues === undefined) {
31
- const listeners = new Set<Listener>();
32
- const handleTouchstart = (e: TouchEvent) => {
33
- if (elementValues !== undefined) {
34
- elementValues.start = readTouch(e);
35
- }
36
- };
37
- const handleTouchend = (e: TouchEvent) => {
38
- if (elementValues === undefined) {
39
- return;
40
- }
41
- const start = elementValues.start;
42
- if (start === null) {
43
- return;
44
- }
45
- const end = readTouch(e);
46
- for (const listener of listeners) {
47
- if (end !== null) {
48
- listener([end[0] - start[0], end[1] - start[1]], e);
49
- }
50
- }
51
- };
52
- element.addEventListener('touchstart', handleTouchstart);
53
- element.addEventListener('touchend', handleTouchend);
54
-
55
- elementValues = {
56
- handleTouchend,
57
- handleTouchstart,
58
- listeners,
59
- start: null,
60
- };
61
- elements.set(element, elementValues);
62
- }
63
- elementValues.listeners.add(cb);
64
- return () => deleteListener(element, cb);
65
- }
66
-
67
- function deleteListener(element: HTMLElement, cb: Listener): void {
68
- const elementValues = elements.get(element);
69
- if (elementValues === undefined) {
70
- return;
71
- }
72
- const listeners = elementValues.listeners;
73
- listeners.delete(cb);
74
- if (listeners.size === 0) {
75
- elements.delete(element);
76
- element.removeEventListener('touchstart', elementValues.handleTouchstart);
77
- element.removeEventListener('touchend', elementValues.handleTouchend);
78
- }
79
- }
80
-
81
- export function addSwipeLeftListener(
82
- element: HTMLElement,
83
- cb: (_force: number, e: TouchEvent) => void,
84
- ) {
85
- return addListener(element, (force, e) => {
86
- const [x, y] = force;
87
- if (x < 0 && -x > Math.abs(y)) {
88
- cb(x, e);
89
- }
90
- });
91
- }
92
-
93
- export function addSwipeRightListener(
94
- element: HTMLElement,
95
- cb: (_force: number, e: TouchEvent) => void,
96
- ) {
97
- return addListener(element, (force, e) => {
98
- const [x, y] = force;
99
- if (x > 0 && x > Math.abs(y)) {
100
- cb(x, e);
101
- }
102
- });
103
- }
104
-
105
- export function addSwipeUpListener(
106
- element: HTMLElement,
107
- cb: (_force: number, e: TouchEvent) => void,
108
- ) {
109
- return addListener(element, (force, e) => {
110
- const [x, y] = force;
111
- if (y < 0 && -y > Math.abs(x)) {
112
- cb(x, e);
113
- }
114
- });
115
- }
116
-
117
- export function addSwipeDownListener(
118
- element: HTMLElement,
119
- cb: (_force: number, e: TouchEvent) => void,
120
- ) {
121
- return addListener(element, (force, e) => {
122
- const [x, y] = force;
123
- if (y > 0 && y > Math.abs(x)) {
124
- cb(x, e);
125
- }
126
- });
127
- }