@douyinfe/semi-foundation 2.63.1 → 2.64.0-beta.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 (90) hide show
  1. package/calendar/foundation.ts +20 -0
  2. package/chat/foundation.ts +18 -23
  3. package/colorPicker/AlphaSliderFoundation.ts +62 -0
  4. package/colorPicker/ColorChooseAreaFoundation.ts +86 -0
  5. package/colorPicker/ColorSliderFoundation.ts +61 -0
  6. package/colorPicker/DataPartFoundation.ts +113 -0
  7. package/colorPicker/colorPicker.scss +113 -0
  8. package/colorPicker/constants.ts +11 -0
  9. package/colorPicker/foundation.ts +206 -0
  10. package/colorPicker/interface.ts +51 -0
  11. package/colorPicker/utils/convert.ts +228 -0
  12. package/colorPicker/utils/round.ts +3 -0
  13. package/colorPicker/utils/split.ts +40 -0
  14. package/colorPicker/variables.scss +28 -0
  15. package/datePicker/foundation.ts +1 -1
  16. package/image/image.scss +6 -1
  17. package/image/previewImageFoundation.ts +233 -150
  18. package/image/previewInnerFoundation.ts +11 -6
  19. package/lib/cjs/calendar/foundation.js +18 -0
  20. package/lib/cjs/chat/foundation.d.ts +1 -2
  21. package/lib/cjs/chat/foundation.js +2 -7
  22. package/lib/cjs/colorPicker/AlphaSliderFoundation.d.ts +27 -0
  23. package/lib/cjs/colorPicker/AlphaSliderFoundation.js +40 -0
  24. package/lib/cjs/colorPicker/ColorChooseAreaFoundation.d.ts +42 -0
  25. package/lib/cjs/colorPicker/ColorChooseAreaFoundation.js +62 -0
  26. package/lib/cjs/colorPicker/ColorSliderFoundation.d.ts +26 -0
  27. package/lib/cjs/colorPicker/ColorSliderFoundation.js +40 -0
  28. package/lib/cjs/colorPicker/DataPartFoundation.d.ts +28 -0
  29. package/lib/cjs/colorPicker/DataPartFoundation.js +115 -0
  30. package/lib/cjs/colorPicker/colorPicker.css +84 -0
  31. package/lib/cjs/colorPicker/colorPicker.scss +113 -0
  32. package/lib/cjs/colorPicker/constants.d.ts +4 -0
  33. package/lib/cjs/colorPicker/constants.js +11 -0
  34. package/lib/cjs/colorPicker/foundation.d.ts +66 -0
  35. package/lib/cjs/colorPicker/foundation.js +150 -0
  36. package/lib/cjs/colorPicker/interface.d.ts +40 -0
  37. package/lib/cjs/colorPicker/interface.js +5 -0
  38. package/lib/cjs/colorPicker/utils/convert.d.ts +28 -0
  39. package/lib/cjs/colorPicker/utils/convert.js +306 -0
  40. package/lib/cjs/colorPicker/utils/round.d.ts +1 -0
  41. package/lib/cjs/colorPicker/utils/round.js +12 -0
  42. package/lib/cjs/colorPicker/utils/split.d.ts +18 -0
  43. package/lib/cjs/colorPicker/utils/split.js +40 -0
  44. package/lib/cjs/colorPicker/variables.scss +28 -0
  45. package/lib/cjs/datePicker/foundation.js +1 -1
  46. package/lib/cjs/image/image.css +5 -1
  47. package/lib/cjs/image/image.scss +6 -1
  48. package/lib/cjs/image/previewImageFoundation.d.ts +46 -13
  49. package/lib/cjs/image/previewImageFoundation.js +207 -181
  50. package/lib/cjs/image/previewInnerFoundation.d.ts +4 -3
  51. package/lib/cjs/image/previewInnerFoundation.js +5 -2
  52. package/lib/cjs/upload/foundation.d.ts +1 -0
  53. package/lib/cjs/upload/foundation.js +30 -14
  54. package/lib/es/calendar/foundation.js +18 -0
  55. package/lib/es/chat/foundation.d.ts +1 -2
  56. package/lib/es/chat/foundation.js +2 -7
  57. package/lib/es/colorPicker/AlphaSliderFoundation.d.ts +27 -0
  58. package/lib/es/colorPicker/AlphaSliderFoundation.js +33 -0
  59. package/lib/es/colorPicker/ColorChooseAreaFoundation.d.ts +42 -0
  60. package/lib/es/colorPicker/ColorChooseAreaFoundation.js +55 -0
  61. package/lib/es/colorPicker/ColorSliderFoundation.d.ts +26 -0
  62. package/lib/es/colorPicker/ColorSliderFoundation.js +33 -0
  63. package/lib/es/colorPicker/DataPartFoundation.d.ts +28 -0
  64. package/lib/es/colorPicker/DataPartFoundation.js +108 -0
  65. package/lib/es/colorPicker/colorPicker.css +84 -0
  66. package/lib/es/colorPicker/colorPicker.scss +113 -0
  67. package/lib/es/colorPicker/constants.d.ts +4 -0
  68. package/lib/es/colorPicker/constants.js +6 -0
  69. package/lib/es/colorPicker/foundation.d.ts +66 -0
  70. package/lib/es/colorPicker/foundation.js +143 -0
  71. package/lib/es/colorPicker/interface.d.ts +40 -0
  72. package/lib/es/colorPicker/interface.js +1 -0
  73. package/lib/es/colorPicker/utils/convert.d.ts +28 -0
  74. package/lib/es/colorPicker/utils/convert.js +277 -0
  75. package/lib/es/colorPicker/utils/round.d.ts +1 -0
  76. package/lib/es/colorPicker/utils/round.js +5 -0
  77. package/lib/es/colorPicker/utils/split.d.ts +18 -0
  78. package/lib/es/colorPicker/utils/split.js +34 -0
  79. package/lib/es/colorPicker/variables.scss +28 -0
  80. package/lib/es/datePicker/foundation.js +1 -1
  81. package/lib/es/image/image.css +5 -1
  82. package/lib/es/image/image.scss +6 -1
  83. package/lib/es/image/previewImageFoundation.d.ts +46 -13
  84. package/lib/es/image/previewImageFoundation.js +207 -181
  85. package/lib/es/image/previewInnerFoundation.d.ts +4 -3
  86. package/lib/es/image/previewInnerFoundation.js +5 -2
  87. package/lib/es/upload/foundation.d.ts +1 -0
  88. package/lib/es/upload/foundation.js +30 -14
  89. package/package.json +3 -3
  90. package/upload/foundation.ts +19 -3
@@ -248,7 +248,27 @@ export default class CalendarFoundation<P = Record<string, any>, S = Record<stri
248
248
  if (!parsed.day) {
249
249
  parsed.day = [];
250
250
  }
251
+
251
252
  parsed.day = parsed.day.map(item => renderDailyEvent(item));
253
+ // 将 startPos & endPos 完全相同的事件编为一组
254
+ const sameTimeRangeGroup = parsed.day.reduce((acc, item) => {
255
+ const key = `${item.startPos}-${item.endPos}`;
256
+ if (!acc[key]) {
257
+ acc[key] = [];
258
+ }
259
+ acc[key].push(item);
260
+ return acc;
261
+ }, {});
262
+
263
+ // 计算每个 item 的 left 值,
264
+ const eventCountMap = {};
265
+ parsed.day = parsed.day.map(item => {
266
+ const key = `${item.startPos}-${item.endPos}`;
267
+ let curCount = eventCountMap[key];
268
+ eventCountMap[key] = curCount === undefined ? 0 : ++curCount;
269
+ item.left = curCount !== 0 ? `${(curCount / sameTimeRangeGroup[key].length * 100)}%` : 0;
270
+ return item;
271
+ });
252
272
  return parsed;
253
273
  }
254
274
 
@@ -5,14 +5,14 @@ import { debounce } from "lodash";
5
5
  import { getUuidv4 } from "../utils/uuid";
6
6
  import { handlePrevent } from "../utils/a11y";
7
7
 
8
- const { PIC_PREFIX, PIC_SUFFIX_ARRAY, ROLE,
8
+ const { PIC_PREFIX, PIC_SUFFIX_ARRAY, ROLE,
9
9
  SCROLL_ANIMATION_TIME, SHOW_SCROLL_GAP
10
10
  } = strings;
11
11
 
12
12
  export interface Content {
13
13
  type: 'text' | 'image_url' | 'file_url';
14
14
  text?: string;
15
- image_url?: {
15
+ image_url?: {
16
16
  url: string;
17
17
  [x: string]: any
18
18
  };
@@ -37,7 +37,7 @@ export interface Message {
37
37
  }
38
38
 
39
39
  export interface ChatAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
40
- getContainerRef: () => React.RefObject<HTMLDivElement>;
40
+ getContainerRef: () => HTMLDivElement;
41
41
  setWheelScroll: (flag: boolean) => void;
42
42
  notifyChatsChange: (chats: Message[]) => void;
43
43
  notifyLikeMessage: (message: Message) => void;
@@ -80,17 +80,15 @@ export default class ChatFoundation <P = Record<string, any>, S = Record<string,
80
80
  }
81
81
 
82
82
  scrollToBottomImmediately = () => {
83
- const containerRef = this._adapter.getContainerRef();
84
- const element = containerRef?.current;
83
+ const element = this._adapter.getContainerRef();
85
84
  if (element) {
86
85
  element.scrollTop = element.scrollHeight;
87
- }
86
+ }
88
87
  }
89
88
 
90
89
  scrollToBottomWithAnimation = () => {
91
90
  const duration = SCROLL_ANIMATION_TIME;
92
- const containerRef = this._adapter.getContainerRef();
93
- const element = containerRef?.current;
91
+ const element = this._adapter.getContainerRef();
94
92
  if (!element) {
95
93
  return;
96
94
  }
@@ -106,18 +104,15 @@ export default class ChatFoundation <P = Record<string, any>, S = Record<string,
106
104
  easing: 'easeInOutCubic'
107
105
  }
108
106
  );
109
-
107
+
110
108
  this.animation.on('frame', ({ scrollTop }: { scrollTop: number }) => {
111
109
  element.scrollTop = scrollTop;
112
110
  });
113
-
111
+
114
112
  this.animation.start();
115
113
  }
116
114
 
117
115
  containerScroll = (e: any) => {
118
- if (e.target !== e.currentTarget) {
119
- return;
120
- }
121
116
  e.persist();
122
117
  const update = () => {
123
118
  this.getScroll(e.target);
@@ -155,7 +150,7 @@ export default class ChatFoundation <P = Record<string, any>, S = Record<string,
155
150
  const newChats = [...chats, dividerMessage];
156
151
  this._adapter.notifyChatsChange(newChats);
157
152
  this._adapter.notifyClearContext();
158
- }
153
+ }
159
154
 
160
155
  onMessageSend = (input: string, attachment: any[]) => {
161
156
  let content;
@@ -169,13 +164,13 @@ export default class ChatFoundation <P = Record<string, any>, S = Record<string,
169
164
  const suffix = name.split('.').pop();
170
165
  const isImg = fileInstance?.type?.startsWith(PIC_PREFIX) || PIC_SUFFIX_ARRAY.includes(suffix);
171
166
  if (isImg) {
172
- content.push({
173
- type: 'image_url',
174
- image_url: { url: url }
167
+ content.push({
168
+ type: 'image_url',
169
+ image_url: { url: url }
175
170
  });
176
171
  } else {
177
- content.push({
178
- type: 'file_url',
172
+ content.push({
173
+ type: 'file_url',
179
174
  file_url: {
180
175
  url: url,
181
176
  name: name,
@@ -238,7 +233,7 @@ export default class ChatFoundation <P = Record<string, any>, S = Record<string,
238
233
  newChats.splice(index, 1, newChat);
239
234
  this._adapter.notifyChatsChange(newChats);
240
235
  }
241
-
236
+
242
237
  dislikeMessage = (message: Message) => {
243
238
  const { chats } = this.getStates();
244
239
  this._adapter.notifyDislikeMessage(message);
@@ -252,7 +247,7 @@ export default class ChatFoundation <P = Record<string, any>, S = Record<string,
252
247
  newChats.splice(index, 1, newChat);
253
248
  this._adapter.notifyChatsChange(newChats);
254
249
  }
255
-
250
+
256
251
  resetMessage = (message: Message) => {
257
252
  const { chats } = this.getStates();
258
253
  const lastMessage = chats[chats.length - 1];
@@ -284,7 +279,7 @@ export default class ChatFoundation <P = Record<string, any>, S = Record<string,
284
279
  //Disable the default implementation, preventing files from being opened
285
280
  handlePrevent(e);
286
281
  }
287
-
282
+
288
283
  handleContainerDragLeave = (e: any) => {
289
284
  handlePrevent(e);
290
285
  // 鼠标移动至 container 的子元素,则不做任何操作
@@ -295,7 +290,7 @@ export default class ChatFoundation <P = Record<string, any>, S = Record<string,
295
290
  }
296
291
  /**
297
292
  * 延迟隐藏 container ,防止父元素的 mouseOver 被触发,导致 container 无法隐藏
298
- * Delay hiding of the container to prevent the parent element's mouseOver from being triggered,
293
+ * Delay hiding of the container to prevent the parent element's mouseOver from being triggered,
299
294
  * causing the container to be unable to be hidden.
300
295
  */
301
296
  setTimeout(() => {
@@ -0,0 +1,62 @@
1
+ import BaseFoundation, { DefaultAdapter } from "../base/foundation";
2
+ import ColorPickerFoundation, { ColorPickerAdapter, ColorPickerProps, ColorPickerState } from "./foundation";
3
+ import { HsvaColor } from "./interface";
4
+
5
+ export interface AlphaSliderBaseProps {
6
+ width: number;
7
+ height: number;
8
+ hsva: HsvaColor;
9
+ handleSize: number;
10
+ foundation: ColorPickerFoundation
11
+ }
12
+
13
+ export interface AlphaSliderBaseState {
14
+ handlePosition: number;
15
+ isHandleGrabbing: boolean
16
+ }
17
+
18
+
19
+ export interface AlphaSliderAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
20
+ handleMouseDown: (e: any) => void;
21
+ handleMouseUp: (e: any) => void;
22
+ getColorPickerFoundation: () => ColorPickerFoundation;
23
+ getDOM: () => HTMLDivElement
24
+ }
25
+
26
+
27
+ class AlphaSliderFoundation extends BaseFoundation<AlphaSliderAdapter<AlphaSliderBaseProps, AlphaSliderBaseState>, AlphaSliderBaseProps, AlphaSliderBaseState> {
28
+
29
+ constructor(adapter: AlphaSliderAdapter<AlphaSliderBaseProps, AlphaSliderBaseState>) {
30
+ super({
31
+ ...adapter
32
+ });
33
+ }
34
+
35
+ handleMouseDown = (e: any) => {
36
+ this._adapter.handleMouseDown(e);
37
+ }
38
+
39
+
40
+ handleMouseUp = (e: any) => {
41
+ this._adapter.handleMouseUp(e);
42
+ }
43
+
44
+
45
+ setHandlePositionByMousePosition = (e: MouseEvent) => {
46
+ const rect = this._adapter.getDOM()?.getBoundingClientRect();
47
+ if (!rect) {
48
+ return;
49
+ }
50
+ const { width, handleSize } = this._adapter.getProps();
51
+ const colorPickerFoundation = this._adapter.getColorPickerFoundation();
52
+ const mousePosition = e.clientX - rect.x;
53
+ const handlePosition = colorPickerFoundation.getAlphaHandlePositionByMousePosition(mousePosition, width, handleSize);
54
+ colorPickerFoundation.handleAlphaChangeByHandle({ a: Number((Math.min(Math.max(mousePosition / width, 0), 1)).toFixed(2)) });
55
+ this.setState({ handlePosition });
56
+ }
57
+
58
+
59
+ }
60
+
61
+
62
+ export default AlphaSliderFoundation;
@@ -0,0 +1,86 @@
1
+ import BaseFoundation, { DefaultAdapter } from "../base/foundation";
2
+ import ColorPickerFoundation from "./foundation";
3
+ import { HsvaColor } from "./interface";
4
+
5
+
6
+ export interface ColorChooseAreaBaseProps {
7
+ hsva: HsvaColor;
8
+ onChange: (newColor: { s: number; v: number }) => void;
9
+ handleSize: number;
10
+ width: number;
11
+ height: number;
12
+ foundation: ColorPickerFoundation
13
+ }
14
+
15
+ export interface ColorChooseAreaBaseState {
16
+ handlePosition: { x: number; y: number };
17
+ isHandleGrabbing: boolean
18
+ }
19
+
20
+
21
+ export interface ColorChooseAreaAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
22
+ getColorPickerFoundation: () => ColorPickerFoundation;
23
+ handleMouseDown: (e: any) => void;
24
+ handleMouseUp: (e: any) => void;
25
+ getDOM: () => HTMLDivElement;
26
+ notifyChange: (newColor: { s: number; v: number }) => void
27
+ }
28
+
29
+
30
+ class ColorChooseAreaFoundation extends BaseFoundation<ColorChooseAreaAdapter<ColorChooseAreaBaseProps, ColorChooseAreaBaseState>, ColorChooseAreaBaseProps, ColorChooseAreaBaseState> {
31
+
32
+ constructor(adapter: ColorChooseAreaAdapter<ColorChooseAreaBaseProps, ColorChooseAreaBaseState>) {
33
+ super({
34
+ ...adapter
35
+ });
36
+ }
37
+
38
+ getHandlePositionByHSVA = () => {
39
+ const { hsva, width, height, handleSize } = this.getProps();
40
+
41
+ return this._adapter.getColorPickerFoundation().getHandlePositionByHSVA(hsva, {
42
+ width: width,
43
+ height: height
44
+ }, handleSize);
45
+
46
+ }
47
+
48
+ handleMouseDown = (e: any) => {
49
+ this._adapter.handleMouseDown(e);
50
+ }
51
+
52
+ handleMouseUp = (e: any) => {
53
+ this._adapter.handleMouseUp(e);
54
+ }
55
+
56
+
57
+ setHandlePositionByMousePosition = (e: globalThis.MouseEvent) => {
58
+ const rect = this._adapter.getDOM()?.getBoundingClientRect();
59
+ if (!rect) {
60
+ return;
61
+ }
62
+ const mousePosition = {
63
+ x: e.clientX - rect.x,
64
+ y: e.clientY - rect.y
65
+ };
66
+ const { width, height, handleSize } = this.getProps();
67
+ const colorPickerFoundation = this._adapter.getColorPickerFoundation();
68
+ const handlePosition = colorPickerFoundation.getHandlePositionByMousePosition(mousePosition, {
69
+ width,
70
+ height
71
+ }, handleSize);
72
+ if (handlePosition) {
73
+ this.setState({ handlePosition });
74
+ this._adapter.notifyChange({
75
+ s: Math.round(mousePosition.x / width * 100),
76
+ v: Math.round(100 - (Math.min(Math.max(mousePosition.y / height, 0), 1)) * 100),
77
+ });
78
+ }
79
+
80
+ }
81
+
82
+
83
+ }
84
+
85
+
86
+ export default ColorChooseAreaFoundation;
@@ -0,0 +1,61 @@
1
+ import BaseFoundation, { DefaultAdapter } from "../base/foundation";
2
+ import ColorPickerFoundation from "./foundation";
3
+
4
+ export interface ColorSliderBaseProps {
5
+ width: number;
6
+ height: number;
7
+ hue: number;
8
+ handleSize: number;
9
+ foundation: ColorPickerFoundation
10
+ }
11
+
12
+ export interface ColorSliderBaseState {
13
+ handlePosition: number;
14
+ isHandleGrabbing: boolean
15
+ }
16
+
17
+
18
+ export interface ColorSliderAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
19
+ handleMouseDown: (e: any) => void;
20
+ handleMouseUp: (e: any) => void;
21
+ getColorPickerFoundation: () => ColorPickerFoundation;
22
+ getDOM: () => HTMLDivElement
23
+ }
24
+
25
+
26
+ class ColorSliderFoundation extends BaseFoundation<ColorSliderAdapter<ColorSliderBaseProps, ColorSliderBaseState>, ColorSliderBaseProps, ColorSliderBaseState> {
27
+
28
+ constructor(adapter: ColorSliderAdapter<ColorSliderBaseProps, ColorSliderBaseState>) {
29
+ super({
30
+ ...adapter
31
+ });
32
+ }
33
+
34
+ handleMouseDown = (e: any) => {
35
+ this._adapter.handleMouseDown(e);
36
+ }
37
+
38
+
39
+ handleMouseUp = (e: any) => {
40
+ this._adapter.handleMouseUp(e);
41
+ }
42
+
43
+
44
+ setHandlePositionByMousePosition = (e: MouseEvent) => {
45
+ const rect = this._adapter.getDOM()?.getBoundingClientRect();
46
+ if (!rect) {
47
+ return;
48
+ }
49
+ const { width, handleSize } = this._adapter.getProps();
50
+ const colorPickerFoundation = this._adapter.getColorPickerFoundation();
51
+ const mousePosition = e.clientX - rect.x;
52
+ colorPickerFoundation.handleColorChangeByHandle({ h: Math.round(Math.min(Math.max(mousePosition / width, 0), 1) * 360) });
53
+ const handlePosition = colorPickerFoundation.getColorHandlePositionByMousePosition(mousePosition, width, handleSize);
54
+ this.setState({ handlePosition });
55
+ }
56
+
57
+
58
+ }
59
+
60
+
61
+ export default ColorSliderFoundation;
@@ -0,0 +1,113 @@
1
+ import BaseFoundation, { DefaultAdapter } from "../base/foundation";
2
+ import ColorPickerFoundation, { ColorPickerProps } from "./foundation";
3
+ import split from "./utils/split";
4
+ import { HsvaColor, RgbaColor } from "./interface";
5
+
6
+
7
+ type Value = ColorPickerProps['value']
8
+
9
+ export interface DataPartBaseProps {
10
+ currentColor: Value;
11
+ defaultFormat: 'hex' | 'rgba' | 'hsva';
12
+ width: number;
13
+ alpha?: boolean;
14
+ foundation: ColorPickerFoundation;
15
+ eyeDropper: boolean
16
+ }
17
+
18
+ export interface DataPartBaseState {
19
+ format: 'hex' | 'rgba' | 'hsva';
20
+ inputValue: string
21
+ }
22
+
23
+
24
+ export interface DataPartAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
25
+ getColorPickerFoundation: () => ColorPickerFoundation
26
+ }
27
+
28
+
29
+ class DataPartFoundation extends BaseFoundation<DataPartAdapter<DataPartBaseProps, DataPartBaseState>, DataPartBaseProps, DataPartBaseState> {
30
+
31
+ constructor(adapter: DataPartAdapter<DataPartBaseProps, DataPartBaseState>) {
32
+ super({
33
+ ...adapter
34
+ });
35
+ }
36
+
37
+ getInputValue = () => {
38
+ const { currentColor } = this._adapter.getProps();
39
+ const { format } = this._adapter.getStates();
40
+ const rgba = currentColor.rgba;
41
+ const hsva = currentColor.hsva;
42
+ const hex = currentColor.hex;
43
+ if (format === 'rgba') {
44
+ return `${rgba.r},${rgba.g},${rgba.b}`;
45
+ } else if (format === 'hsva') {
46
+ return `${hsva.h},${hsva.s},${hsva.v}`;
47
+ } else {
48
+ return hex.slice(0, 7);
49
+ }
50
+ }
51
+
52
+ getValueByInputValue = (value: string) => {
53
+ const { format } = this.getStates();
54
+ if (format === 'rgba') {
55
+ const result = split(value, format);
56
+ if (result) {
57
+ return result as RgbaColor;
58
+ }
59
+
60
+ } else if (format === 'hsva') {
61
+ const result = split(value, format);
62
+ if (result) {
63
+ return result as HsvaColor;
64
+ }
65
+ } else if (format === 'hex') {
66
+ // hack chrome bug, format mismatch with w3c.
67
+ if (!value.startsWith('#')) {
68
+ value = '#' + value;
69
+ }
70
+ if (/#[\d\w]{6,8}/.test(value)) {
71
+ return value;
72
+ }
73
+ }
74
+ return false;
75
+ }
76
+
77
+ handlePickValueWithStraw = async () => {
78
+ const colorPickerFoundation = this._adapter.getColorPickerFoundation();
79
+ if (!window['EyeDropper']) {
80
+ return;
81
+ }
82
+ //@ts-ignore
83
+ const eyeDropper = new EyeDropper();
84
+
85
+ try {
86
+ const result = await eyeDropper.open();
87
+ const color = result['sRGBHex'];
88
+ if (color.startsWith("#")) {
89
+ colorPickerFoundation.handleChange(color, 'hex');
90
+ } else if (color.startsWith('rgba')) {
91
+ const rgba = ColorPickerFoundation.rgbaStringToRgba(color);
92
+ rgba.a = 1;
93
+ colorPickerFoundation.handleChange(rgba, 'rgba');
94
+ }
95
+ } catch (e) {
96
+
97
+ }
98
+ }
99
+
100
+
101
+ handleInputValueChange = (value: string) => {
102
+ this._adapter.setState({ inputValue: value });
103
+ }
104
+
105
+ handleFormatChange = (format: DataPartBaseState['format']) => {
106
+ this._adapter.setState({ format });
107
+ }
108
+
109
+
110
+ }
111
+
112
+
113
+ export default DataPartFoundation;
@@ -0,0 +1,113 @@
1
+ @import "./variables.scss";
2
+
3
+
4
+ $module: #{$prefix}-colorPicker;
5
+
6
+
7
+ .#{$module} {
8
+
9
+ &-colorChooseArea{
10
+
11
+ /**
12
+ * Referrer from https://github.com/web-padawan/vanilla-colorful/blob/5d219ee360ae2f29534864b28ca9e6074233b9ce/src/lib/styles/saturation.css
13
+ */
14
+ box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
15
+ position: relative;
16
+ flex-grow: 1;
17
+ border-color: transparent;
18
+ border-radius: $radius-colorPicker-topLeft $radius-colorPicker-topRight $radius-colorPicker-bottomLeft $radius-colorPicker-bottomRight;
19
+ background-image: linear-gradient(to top, #000, rgba(0, 0, 0, 0)), linear-gradient(to right, #fff, rgba(255, 255, 255, 0));
20
+ }
21
+
22
+
23
+ &-handle{
24
+ border-radius: $radius-colorPicker-handle;
25
+ border: $width-colorPicker_handle-border solid $color-colorPicker_handle-border;
26
+ position: absolute;
27
+ box-sizing: border-box;
28
+ cursor: grab;
29
+ }
30
+
31
+
32
+
33
+
34
+ &-alphaSlider{
35
+ position: relative;
36
+ cursor: pointer;
37
+ margin-top: $spacing-colorPicker_slider-marginTop;
38
+ border-radius: $radius-colorPicker-handle;
39
+ background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><rect x="8" width="8" height="8"/><rect y="8" width="8" height="8"/></svg>');
40
+
41
+
42
+ .#{$module}-alphaSliderInner{
43
+ width: 100%;
44
+ height: 100%;
45
+ border-radius: $radius-colorPicker-alphaSliderInner;
46
+ }
47
+
48
+ .#{$module}-alphaHandle{
49
+ background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><rect x="8" width="8" height="8"/><rect y="8" width="8" height="8"/></svg>');
50
+ border-radius: $radius-colorPicker-handle;
51
+ border: $width-colorPicker_handle-border solid $color-colorPicker_handle-border;
52
+ position: absolute;
53
+ box-sizing: border-box;
54
+ cursor: grab;
55
+
56
+ }
57
+
58
+ }
59
+
60
+ &-colorSlider{
61
+ position: relative;
62
+ cursor: pointer;
63
+ margin-top: $spacing-colorPicker_slider-marginTop;
64
+ border-radius: $radius-colorPicker-handle;
65
+ background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
66
+ }
67
+
68
+
69
+
70
+ &-dataPart{
71
+ margin-top: $spacing-colorPicker_dataPart-marginTop;
72
+ display: flex;
73
+ align-items: center;
74
+ .#{$module}-colorDemoBlock{
75
+ border-radius: $radius-colorPicker-demoBlock;
76
+ }
77
+ .#{$module}-inputGroup{
78
+ margin-left: $spacing-colorPicker_inputGroup-marginLeft;
79
+ width: 100%;
80
+ flex:1;
81
+ flex-wrap: nowrap;
82
+ .#{$module}-colorPickerInput{
83
+ flex: 1;
84
+ }
85
+ .#{$module}-colorPickerInputNumber{
86
+ width: $width-colorPicker-colorPickerInputNumber;
87
+ .#{$module}-inputNumberSuffix{
88
+ font-size: $font-colorPicker_inputNumberSuffix-fontSize;
89
+ padding: $spacing-colorPicker_inputNumberSuffix-vertical $spacing-colorPicker_inputNumberSuffix-horizontal;
90
+ }
91
+ }
92
+ }
93
+ .#{$module}-formatSelect{
94
+ width: $width-colorPicker-formatSelect;
95
+ }
96
+ }
97
+
98
+
99
+ &-popover{
100
+ padding: $spacing-colorPicker_popover-padding;
101
+
102
+ &-defaultChildren{
103
+ width:$width-colorPicker-defaultTrigger;
104
+ height: $width-colorPicker-defaultTrigger;
105
+ border-radius: $radius-colorPicker-defaultTrigger;
106
+ cursor: pointer;
107
+ }
108
+
109
+ }
110
+
111
+
112
+
113
+ }
@@ -0,0 +1,11 @@
1
+ import { BASE_CLASS_PREFIX } from '../base/constants';
2
+
3
+ const cssClasses = {
4
+ PREFIX: `${BASE_CLASS_PREFIX}-colorPicker`,
5
+ };
6
+
7
+ const strings = {
8
+
9
+ };
10
+
11
+ export { cssClasses };