@antscorp/antsomi-ui 1.3.3-beta.90 → 1.3.3-beta.92

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.
@@ -107,7 +107,12 @@ export const convertHtmlText = (htmlText, format = 'raw', state, objectWidgetInp
107
107
  else if (found[0] === 'productTemplate') {
108
108
  bgColor = '#9238b5';
109
109
  }
110
- else if (found[0] === 'promotion_code' || foundLink[0] === 'nontrackurl') {
110
+ else if (foundLink[0] === 'nontrackurl' ||
111
+ foundLink[0] === 'shortlink' ||
112
+ foundLink[0] === 'shortlink_static') {
113
+ bgColor = '#cae5fe';
114
+ }
115
+ else if (found[0] === 'promotion_code') {
111
116
  bgColor = '#6750A7';
112
117
  }
113
118
  else if (found[0] === 'custom') {
@@ -22,6 +22,7 @@ import { DatePickerCustomInput, DatePickerHeader, DropdownContent, DropdownHeade
22
22
  // Constants
23
23
  import { CALCULATION_DATES, CALCULATION_TYPES, DATE_TYPES, DEFAULT_DATE_FORMAT, VALUE_TYPES, ADVANCED_PICKER_TYPE, WEEK_ARR, QUARTER_PLACEHOLDER, WEEK_PLACEHOLDER, DAY_LABEL_SHORT, MONTH_LABEL_FULL, DAY_OF_MONTH, ANCHOR_LEAP_YEAR, GRANULARITY_MAPPING, } from './constants';
24
24
  import { THEME } from '@antscorp/antsomi-ui/es/constants';
25
+ import { useOutsideClick } from '@antscorp/antsomi-ui/es/hooks/useOutsideClick';
25
26
  const PATH = '@antscorp/antsomi-ui/es/components/molecules/DatePicker/components/Advanced/DatePickerAdvanced.tsx';
26
27
  const { useToken } = theme;
27
28
  const { Text } = Typography;
@@ -177,9 +178,11 @@ export const AdvancedPicker = props => {
177
178
  date: newDate,
178
179
  option: {
179
180
  dateType: newDateType.value,
180
- calculationDate: newDateType.value === 'fix' ? '' : newCalculationDate.value,
181
- calculationType: newDateType.value === 'fix' ? '' : newCalculationType.value,
182
- value: newDateType.value === 'fix' ? 0 : value,
181
+ calculationDate: newDateType.value === 'fixed' ? '' : newCalculationDate.value,
182
+ calculationType: newDateType.value === 'fixed'
183
+ ? ''
184
+ : newCalculationType.value,
185
+ value: newDateType.value === 'fixed' ? 0 : value,
183
186
  },
184
187
  });
185
188
  }
@@ -196,9 +199,11 @@ export const AdvancedPicker = props => {
196
199
  }, [propsOption, newCalculationDates, propsDate, format]);
197
200
  // Handlers
198
201
  const disableDate = current => current > dayjs(disableAfterDate, format) || current < dayjs(disableBeforeDate, format);
199
- const toggleOpenDropdown = () => {
202
+ const toggleOpenDropdown = (isOpen) => {
200
203
  try {
201
- setState(() => (Object.assign(Object.assign({}, state), { isOpen: !state.isOpen })));
204
+ setState(() => (Object.assign(Object.assign({}, state), {
205
+ // isOpen: !state.isOpen,
206
+ isOpen: isOpen != null ? isOpen : !state.isOpen })));
202
207
  }
203
208
  catch (error) {
204
209
  handleError(error, {
@@ -208,6 +213,7 @@ export const AdvancedPicker = props => {
208
213
  });
209
214
  }
210
215
  };
216
+ const { ref } = useOutsideClick(() => toggleOpenDropdown(false));
211
217
  const onClickApply = () => {
212
218
  try {
213
219
  const draftOption = {
@@ -253,9 +259,9 @@ export const AdvancedPicker = props => {
253
259
  React.createElement(DropdownFooter, null,
254
260
  React.createElement(Space, null,
255
261
  React.createElement(Button, { type: "primary", onClick: () => onClickApply() }, "Apply"),
256
- React.createElement(Button, { type: "default", onClick: () => toggleOpenDropdown() }, "Cancel")),
262
+ React.createElement(Button, { type: "default", onClick: () => toggleOpenDropdown(false) }, "Cancel")),
257
263
  option.dateType.value === 'fixed' && React.createElement(Button, { onClick: () => onClickNow() }, "Now"))));
258
- const renderDateTypeOptions = () => (React.createElement(Select, { options: newDateTypes, value: option.dateType.value, onChange: value => {
264
+ const renderDateTypeOptions = () => (React.createElement(Select, { getPopupContainer: triggerNode => triggerNode.parentNode, options: newDateTypes, value: option.dateType.value, onChange: value => {
259
265
  const dateType = newDateTypes.find(dateType => dateType.value === value);
260
266
  onChangeOption({ dateType });
261
267
  // toggleOpenDropdown(true);
@@ -299,9 +305,9 @@ export const AdvancedPicker = props => {
299
305
  return dayjs(date);
300
306
  }
301
307
  };
302
- return (React.createElement("div", { style: contentStyle },
308
+ return (React.createElement("div", { style: contentStyle, ref: ref },
303
309
  React.createElement(DropdownHeader, { className: "dropdown-header" },
304
- React.createElement(DropdownLabel, { valueType: valueType, date: date, format: format, type: type, showTime: showTime, operatorKey: operatorKey, formatInputDisplay: formatInputDisplay })),
310
+ React.createElement(DropdownLabel, { valueType: valueType, date: date, format: format, type: type, showTime: showTime, operatorKey: operatorKey, formatInputDisplay: formatInputDisplay, dateType: option.dateType.value })),
305
311
  React.createElement(DropdownContent, { className: "dropdown-content" },
306
312
  renderDateTypeOptions(),
307
313
  option.dateType.value === 'fixed' ? (React.createElement(React.Fragment, null,
@@ -371,7 +377,7 @@ export const AdvancedPicker = props => {
371
377
  onChangeDatePicker(current);
372
378
  } }, getCellRender(current, valueType, info)));
373
379
  }, [valueType, format, date]);
374
- return (React.createElement(Space, { direction: "vertical", size: 5, className: "antsomi-advanced-picker-container" },
380
+ return (React.createElement(Space, { direction: "vertical", size: 5, className: "antsomi-advanced-picker-container", ref: ref },
375
381
  !!label && typeof label === 'string' ? (React.createElement(Text, { style: { color: '#666666' } }, label)) : (label),
376
382
  option.dateType.value === 'fixed' &&
377
383
  !['WEEK', 'DAY_OF_WEEK', 'MONTH_DAY', 'DAY'].includes(valueType) ? (React.createElement(Tooltip, { title: selectedDateTitle },
@@ -400,7 +406,12 @@ export const AdvancedPicker = props => {
400
406
  : undefined, suffixIcon: React.createElement(CalendarIconWrapper, { style: {
401
407
  pointerEvents: disabled ? 'none' : 'all',
402
408
  }, onClick: () => toggleOpenDropdown() },
403
- React.createElement(EventIcon, { width: 20, height: 20, fill: errorMessage ? (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorError : (_b = THEME.token) === null || _b === void 0 ? void 0 : _b.bw10 })), cellRender: cellRender }))) : (React.createElement(Dropdown, { disabled: disabled, open: !disabled && isOpen, dropdownRender: dropdownRender, trigger: ['click'], onOpenChange: () => toggleOpenDropdown(), overlayStyle: { width: 'fit-content', minWidth: 'auto' } },
409
+ React.createElement(EventIcon, { width: 20, height: 20, fill: errorMessage ? (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorError : (_b = THEME.token) === null || _b === void 0 ? void 0 : _b.bw10 })), cellRender: cellRender }))) : (React.createElement(Dropdown, { disabled: disabled, open: !disabled && isOpen, dropdownRender: dropdownRender, trigger: ['click'],
410
+ // onOpenChange={(open, info) => {
411
+ // console.log('🚀🚀🚀 ', 4, { open, info });
412
+ // toggleOpenDropdown();
413
+ // }}
414
+ overlayStyle: { width: 'fit-content', minWidth: 'auto' } },
404
415
  React.createElement(Tooltip, { title: selectedDateTitle },
405
416
  React.createElement(Input, { disabled: disabled, onClick: () => toggleOpenDropdown(), readOnly: true, suffix: React.createElement(CalendarIconWrapper, { style: {
406
417
  pointerEvents: disabled ? 'none' : 'all',
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { TAdvancedType, TOperatorKey, ValueTypes } from '../AdvancedPicker/types';
2
+ import { TAdvancedType, TDateType, TOperatorKey, ValueTypes } from '../AdvancedPicker/types';
3
3
  interface DropdownLabelProps {
4
4
  valueType?: ValueTypes;
5
5
  date?: string;
@@ -8,6 +8,7 @@ interface DropdownLabelProps {
8
8
  showTime?: boolean;
9
9
  operatorKey?: TOperatorKey;
10
10
  formatInputDisplay?: string;
11
+ dateType?: TDateType;
11
12
  }
12
13
  export declare const DropdownLabel: React.FC<DropdownLabelProps>;
13
14
  export {};
@@ -8,7 +8,7 @@ import { ADVANCED_PICKER_TYPE, DEFAULT_DATE_FORMAT, HIDE_TIME_LABEL_ARR, QUARTER
8
8
  // Instance
9
9
  import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
10
10
  import { getFormatDisplay, getLabelQuarterRange } from '../AdvancedPicker/utils';
11
- export const DropdownLabel = React.memo(({ valueType, date, format, type, showTime, operatorKey, formatInputDisplay }) => {
11
+ export const DropdownLabel = React.memo(({ valueType, date, format, type, showTime, operatorKey, formatInputDisplay, dateType }) => {
12
12
  var _a;
13
13
  const { t } = i18nInstance;
14
14
  const title = (_a = Object.values(ADVANCED_PICKER_TYPE).find(({ value }) => value === type)) === null || _a === void 0 ? void 0 : _a.label;
@@ -31,8 +31,10 @@ export const DropdownLabel = React.memo(({ valueType, date, format, type, showTi
31
31
  const dayObj = dayjs(date || new Date(), format).locale('en');
32
32
  // const dayObj = dayjs(date || new Date(), format).locale(locale || 'en');
33
33
  formatLabel = `${WEEK_PLACEHOLDER}W, YYYY`;
34
- subLabel = `${dayjs(dayObj).day(0).format('MMMM DD, YYYY')} - ${dayjs(dayObj)
35
- .day(6)
34
+ subLabel = `${dayjs(dayObj)
35
+ .day(['today', 'first_day_of_week_mon_sun'].includes(dateType || '') ? 1 : 0)
36
+ .format('MMMM DD, YYYY')} - ${dayjs(dayObj)
37
+ .day(['today', 'first_day_of_week_mon_sun'].includes(dateType || '') ? 7 : 6)
36
38
  .format('MMMM DD, YYYY')}`;
37
39
  break;
38
40
  }
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import type { MediaThumbProps } from './MediaThumb';
3
- declare const _default: React.NamedExoticComponent<MediaThumbProps>;
4
- export default _default;
3
+ declare const VideoThumbnail: React.FC<MediaThumbProps>;
4
+ export default VideoThumbnail;
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable jsx-a11y/media-has-caption */
2
2
  // Libraries
3
- import React, { useState, memo, useEffect, useRef } from 'react';
3
+ import React, { useState, useEffect, useRef } from 'react';
4
4
  // Assets
5
5
  import PlaceholderImage from '@antscorp/antsomi-ui/es/assets/images/placeholder-image.png';
6
6
  // Styled
@@ -24,7 +24,10 @@ const VideoThumbnail = props => {
24
24
  setIsShow(true);
25
25
  };
26
26
  video.addEventListener('loadeddata', listener);
27
- video.src = media.url;
27
+ // Set the preload time range
28
+ video.currentTime = 2;
29
+ // Start loading the video from the specified time
30
+ video.load();
28
31
  }
29
32
  }
30
33
  return () => {
@@ -32,8 +35,9 @@ const VideoThumbnail = props => {
32
35
  };
33
36
  }, [media, mode]);
34
37
  return (React.createElement("div", { style: { width: '100%', height: '100%' } },
35
- React.createElement("video", { width: 400, height: 400, ref: videoRef, style: { display: 'none' } }),
38
+ React.createElement("video", { loop: false, muted: true, controls: false, width: 400, height: 400, ref: videoRef, style: { display: 'none' }, preload: "metadata" },
39
+ React.createElement("source", { src: media === null || media === void 0 ? void 0 : media.url, type: "video/mp4" })),
36
40
  React.createElement("canvas", { ref: canvasRef, style: { width: '100%', height: '100%', display: isShow ? 'block' : 'none' } }),
37
41
  React.createElement(Image, { src: PlaceholderImage, alt: "placeholder", style: { display: isShow ? 'none' : 'block' } })));
38
42
  };
39
- export default memo(VideoThumbnail);
43
+ export default VideoThumbnail;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ export declare const useOutsideClick: (callback: any) => {
3
+ ref: import("react").MutableRefObject<any>;
4
+ };
@@ -0,0 +1,18 @@
1
+ import { useEffect, useRef } from 'react';
2
+ export const useOutsideClick = callback => {
3
+ const ref = useRef(null);
4
+ const handleClickOutside = event => {
5
+ if (ref.current && !ref.current.contains(event.target)) {
6
+ if (callback && typeof callback === 'function') {
7
+ callback();
8
+ }
9
+ }
10
+ };
11
+ useEffect(() => {
12
+ document.addEventListener('click', handleClickOutside, true);
13
+ return () => {
14
+ document.removeEventListener('click', handleClickOutside, true);
15
+ };
16
+ });
17
+ return { ref };
18
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.3-beta.90",
3
+ "version": "1.3.3-beta.92",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",