@antscorp/antsomi-ui 1.3.5-beta.34 → 1.3.5-beta.36

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.
@@ -10,7 +10,7 @@ import { initState, resetValue } from './actions';
10
10
  import { useTriggerOut } from './hooks/useTriggerOut';
11
11
  export const CalendarSelection = props => {
12
12
  const initialed = useRef(false);
13
- const { value, popoverProps, rangeLimit = RANGE_LIMIT, timezone = LOCAL_TIMEZONE, timeDisplayProps, onChange, } = props;
13
+ const { value, rangeLimit = RANGE_LIMIT, timezone = LOCAL_TIMEZONE, timeDisplayProps, popoverProps, rangePickerProps, onChange, } = props;
14
14
  const [state, dispatch] = useReducer(reducer, INITIAL_STATE);
15
15
  useLayoutEffect(() => {
16
16
  if (!value)
@@ -30,7 +30,7 @@ export const CalendarSelection = props => {
30
30
  React.createElement(StyledPopoverBody, null,
31
31
  React.createElement(RangeSelectOptions, null),
32
32
  React.createElement(Divider, { type: "vertical", style: { margin: 0, height: 'auto' } }),
33
- React.createElement(CustomPicker, null)),
33
+ React.createElement(CustomPicker, Object.assign({}, rangePickerProps))),
34
34
  React.createElement(Divider, { style: { margin: 0 } }),
35
35
  React.createElement(Footer, null)));
36
36
  // console.log(state.value.current.rangeValue);
@@ -1,3 +1,14 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  /* eslint-disable react/no-array-index-key */
2
13
  import React, { useCallback, useEffect, useRef, useState } from 'react';
3
14
  import { TinyColor } from '@ctrl/tinycolor';
@@ -19,7 +30,8 @@ const generateRangeInputLabel = (idx, label) => {
19
30
  return 'custom';
20
31
  return `custom compare${idx > 1 ? ` ${idx}}` : ''}`;
21
32
  };
22
- export const CustomPicker = () => {
33
+ export const CustomPicker = props => {
34
+ const rest = __rest(props, []);
23
35
  const popupContainer = useRef(null);
24
36
  const { state, action } = useCalendarSelectionContext();
25
37
  const { rangeValue } = state.value.current;
@@ -66,7 +78,7 @@ export const CustomPicker = () => {
66
78
  } },
67
79
  React.createElement("div", { className: "range-input" },
68
80
  React.createElement("div", { className: "range-input-label" }, generateRangeInputLabel(rangeIdx, range.label)),
69
- React.createElement(RangePicker, { open: true, value: [dayjs(range.start), dayjs(range.end)], onClick: () => setActiveRangeIdx(rangeIdx), getPopupContainer: () => popupContainer.current || document.body, panelRender: originalPanel => {
81
+ React.createElement(RangePicker, Object.assign({}, rest, { open: true, value: [dayjs(range.start), dayjs(range.end)], onClick: () => setActiveRangeIdx(rangeIdx), getPopupContainer: () => popupContainer.current || document.body, panelRender: originalPanel => {
70
82
  if (activeRangeIdx !== rangeIdx)
71
83
  return null;
72
84
  return originalPanel;
@@ -90,7 +102,7 @@ export const CustomPicker = () => {
90
102
  end = valueFirst.toISOString();
91
103
  }
92
104
  handleCalendarChange(start, end);
93
- } })))))),
105
+ } }))))))),
94
106
  React.createElement(AutoUpdateTo, null),
95
107
  React.createElement(CalendarContainerStyled, { className: "calendar-container", ref: popupContainer })));
96
108
  };
@@ -1,4 +1,4 @@
1
- import { PopoverProps } from 'antd';
1
+ import { DatePickerProps, PopoverProps } from 'antd';
2
2
  import { Dispatch } from 'react';
3
3
  import { ValueOf } from 'type-fest';
4
4
  import { updateRangeInfo, changeRangeType, updateRangeValue, changeAutoUpdateTo, initState, togglePopover, apply, resetValue } from './actions';
@@ -11,6 +11,7 @@ export type CalendarSelectionProps = Partial<{
11
11
  toDay: Date;
12
12
  value: CalendarSelectionValue;
13
13
  timeDisplayProps: TimeRangeDisplayProps;
14
+ rangePickerProps: DatePickerProps;
14
15
  onChange: (value: CalendarSelectionValue, info: TriggerOutInfo) => void;
15
16
  }>;
16
17
  export type Range = (typeof SELECTION_KEY)[keyof typeof SELECTION_KEY];
@@ -8,6 +8,7 @@ export type UserInfo = {
8
8
  user_type: number;
9
9
  ctime: Date;
10
10
  utime: Date;
11
+ [key: string]: any;
11
12
  };
12
13
  export type UserAccessInfo = {
13
14
  userId: number;
@@ -1,4 +1,4 @@
1
- import { ObjectAccessInfo } from './types';
1
+ import { ObjectAccessInfo, UserInfo } from './types';
2
2
  export declare const mergePermission: (objectPermissionAllow: boolean, menuPermissionValue: number) => boolean;
3
3
  export declare const composeObjectMenuPermissions: (params: {
4
4
  isPublic: boolean;
@@ -36,3 +36,4 @@ export declare const getActionsByUser: (args: {
36
36
  readonly label: "Remove Access";
37
37
  readonly key: "remove_acess";
38
38
  })[];
39
+ export declare const initAccessInfoDefault: (userInfo: UserInfo) => ObjectAccessInfo;
@@ -1,5 +1,6 @@
1
1
  import { MENU_PERMISSION, PEOPLE_ACTIONS, PEOPLE_ACTION_KEYS, PUBLIC_ROLE, ROLE_MAPPING, } from './constants';
2
2
  import { remove } from 'lodash';
3
+ import { snakeCaseToCamelCase } from '@antscorp/antsomi-ui/es/utils';
3
4
  export const mergePermission = (objectPermissionAllow, menuPermissionValue) => {
4
5
  const valueMapping = {
5
6
  [`${MENU_PERMISSION.NONE}_false`]: false,
@@ -55,3 +56,11 @@ export const getActionsByUser = (args) => {
55
56
  }
56
57
  return actions.map(actKey => PEOPLE_ACTIONS[actKey]);
57
58
  };
59
+ export const initAccessInfoDefault = (userInfo) => ({
60
+ ownerId: userInfo.user_id,
61
+ listAccess: [
62
+ Object.assign(Object.assign({}, snakeCaseToCamelCase(userInfo)), { role: ROLE_MAPPING.OWNER, allowView: 1, allowEdit: 1, allowComment: 1 }),
63
+ ],
64
+ publicRole: PUBLIC_ROLE.ONLY_VIEWER,
65
+ isPublic: 0,
66
+ });
@@ -83,8 +83,7 @@ export const usePersistTemplate = (params) => {
83
83
  default:
84
84
  return objectTemplate.create(Object.assign(Object.assign({}, params), { data: omit(params.data, ['template_id']) }));
85
85
  }
86
- }, onSettled(data, error, variables, context) {
87
- console.log('🚀 ~ onSettled ~ variables:', variables);
86
+ }, onSettled(data, error, variables) {
88
87
  queryClientAntsomiUI.invalidateQueries([
89
88
  QUERY_KEYS.GET_OBJECT_TEMPLATE_DETAIL,
90
89
  variables.params.data.template_id,
@@ -57,3 +57,5 @@ export declare function mapNumberToOrdinalText(num: number): string;
57
57
  export declare const searchParamsToObject: (searchParams?: string) => Record<string, unknown>;
58
58
  export declare function asssertCannotReach(x: never): void;
59
59
  export declare const getShuffleArray: <T>(array: T[]) => T[];
60
+ export declare const snakeCaseToCamelCase: <T = Record<string, any>>(object: Record<string, any>, recursive?: boolean) => T;
61
+ export declare const camelCaseToSnakeCase: (object: Record<string, any>, recursive?: boolean) => Record<string, any>;
@@ -386,3 +386,25 @@ export const getShuffleArray = (array) => {
386
386
  }
387
387
  return array;
388
388
  };
389
+ export const snakeCaseToCamelCase = (object, recursive = false) => {
390
+ const newObject = {};
391
+ Object.keys(object).forEach(key => {
392
+ const newKey = key.replace(/_([a-z])/g, g => g[1].toUpperCase());
393
+ newObject[newKey] =
394
+ recursive && typeof object[key] === 'object'
395
+ ? snakeCaseToCamelCase(object[key], true)
396
+ : object[key];
397
+ });
398
+ return newObject;
399
+ };
400
+ export const camelCaseToSnakeCase = (object, recursive = false) => {
401
+ const newObject = {};
402
+ Object.keys(object).forEach(key => {
403
+ const newKey = key.replace(/[A-Z]/g, g => `_${g[0].toLowerCase()}`);
404
+ newObject[newKey] =
405
+ recursive && typeof object[key] === 'object'
406
+ ? camelCaseToSnakeCase(object[key], true)
407
+ : object[key];
408
+ });
409
+ return newObject;
410
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.34",
3
+ "version": "1.3.5-beta.36",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",