d2coreui 23.0.55 → 23.0.57

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 (36) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/components/date/dateRangeInput.js +5 -5
  3. package/components/date/dateRangeInput.js.map +1 -1
  4. package/components/date/dateRangeInputAdvancedPanel.js +26 -15
  5. package/components/date/dateRangeInputAdvancedPanel.js.map +1 -1
  6. package/components/date/dateRangeInputConfirm.js +16 -13
  7. package/components/date/dateRangeInputConfirm.js.map +1 -1
  8. package/components/date/dateTimeInput.d.ts +12 -3
  9. package/components/date/dateTimeInput.js +164 -93
  10. package/components/date/dateTimeInput.js.map +1 -1
  11. package/components/grid/config/dataGridEditor.d.ts +4 -3
  12. package/components/grid/config/dataGridEditor.js +16 -4
  13. package/components/grid/config/dataGridEditor.js.map +1 -1
  14. package/components/grid/dataGrid.d.ts +19 -5
  15. package/components/grid/dataGrid.js +9 -5
  16. package/components/grid/dataGrid.js.map +1 -1
  17. package/components/grid/export/contextMenu.d.ts +3 -2
  18. package/components/grid/export/contextMenu.js.map +1 -1
  19. package/components/grid/extendedDataGrid.d.ts +11 -4
  20. package/components/grid/extendedDataGrid.js +34 -24
  21. package/components/grid/extendedDataGrid.js.map +1 -1
  22. package/components/modal/impl/draggableModalInner.js +22 -10
  23. package/components/modal/impl/draggableModalInner.js.map +1 -1
  24. package/components/modal/impl/draggableModalReducer.d.ts +2 -3
  25. package/components/modal/impl/draggableModalReducer.js +9 -7
  26. package/components/modal/impl/draggableModalReducer.js.map +1 -1
  27. package/components/modal/modalDialog.d.ts +2 -1
  28. package/components/modal/modalDialog.js +2 -1
  29. package/components/modal/modalDialog.js.map +1 -1
  30. package/components/style/withCss.d.ts +9 -4
  31. package/components/style/withCss.js +7 -3
  32. package/components/style/withCss.js.map +1 -1
  33. package/i18n/components.cs.json +2 -0
  34. package/i18n/components.sk.json +2 -0
  35. package/i18n/components.uk.json +2 -0
  36. package/package.json +1 -1
@@ -23,6 +23,8 @@ export interface ModalsState {
23
23
  };
24
24
  }
25
25
  export declare const initialModalsState: ModalsState;
26
+ /** Free space in total (half on each side) a maximized dialog, or one opened larger than the window, leaves around it. */
27
+ export declare const WINDOW_MARGIN = 32;
26
28
  export declare const initialModalState: ModalState;
27
29
  export type Action = {
28
30
  type: 'show';
@@ -30,9 +32,6 @@ export type Action = {
30
32
  } | {
31
33
  type: 'hide';
32
34
  id: ModalID;
33
- } | {
34
- type: 'focus';
35
- id: ModalID;
36
35
  } | {
37
36
  type: 'unmount';
38
37
  id: ModalID;
@@ -6,6 +6,8 @@ export const initialModalsState = {
6
6
  windowSize: getWindowSize(),
7
7
  modals: {},
8
8
  };
9
+ /** Free space in total (half on each side) a maximized dialog, or one opened larger than the window, leaves around it. */
10
+ export const WINDOW_MARGIN = 32;
9
11
  export const initialModalState = {
10
12
  x: 0,
11
13
  y: 0,
@@ -61,15 +63,15 @@ export const draggableModalReducer = (state, action) => {
61
63
  return Object.assign(Object.assign({}, state), { modals: Object.assign(Object.assign({}, state.modals), { [action.id]: Object.assign(Object.assign({}, state.modals[action.id]), clampDrag(state.windowSize.width, state.windowSize.height, action.x, action.y, state.modals[action.id].width, state.modals[action.id].height)) }) });
62
64
  case 'show': {
63
65
  const modalState = state.modals[action.id];
64
- const centerX = state.windowSize.width / 2 - modalState.width / 2;
65
- const centerY = state.windowSize.height / 2 - modalState.height / 2;
66
- const position = clampDrag(state.windowSize.width, state.windowSize.height, centerX, centerY, modalState.width, modalState.height);
67
- const size = clampResize(state.windowSize.width, state.windowSize.height, position.x, position.y, modalState.width, modalState.height);
66
+ // a dialog larger than the window opens shrunk to it, with the margin a maximized one keeps
67
+ const width = Math.min(modalState.width, state.windowSize.width - WINDOW_MARGIN);
68
+ const height = Math.min(modalState.height, state.windowSize.height - WINDOW_MARGIN);
69
+ const centerX = state.windowSize.width / 2 - width / 2;
70
+ const centerY = state.windowSize.height / 2 - height / 2;
71
+ const position = clampDrag(state.windowSize.width, state.windowSize.height, centerX, centerY, width, height);
72
+ const size = clampResize(state.windowSize.width, state.windowSize.height, position.x, position.y, width, height);
68
73
  return Object.assign(Object.assign({}, state), { modals: Object.assign(Object.assign({}, state.modals), { [action.id]: Object.assign(Object.assign(Object.assign(Object.assign({}, modalState), position), size), { visible: true }) }) });
69
74
  }
70
- case 'focus':
71
- const modalState = state.modals[action.id];
72
- return Object.assign(Object.assign({}, state), { modals: Object.assign(Object.assign({}, state.modals), { [action.id]: Object.assign({}, modalState) }) });
73
75
  case 'hide': {
74
76
  const modalState = state.modals[action.id];
75
77
  return Object.assign(Object.assign({}, state), { modals: Object.assign(Object.assign({}, state.modals), { [action.id]: Object.assign(Object.assign({}, modalState), { visible: false }) }) });
@@ -1 +1 @@
1
- {"version":3,"file":"draggableModalReducer.js","sourceRoot":"","sources":["../../../../../components/modal/impl/draggableModalReducer.ts"],"names":[],"mappings":"AAAA,yCAAyC;AAEzC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAA;AAE7B,MAAM,SAAS,GAAG,CAAI,CAAuB,EAAE,CAAkB,EAAwB,EAAE,CACvF,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAA;AA2BnE,MAAM,CAAC,MAAM,kBAAkB,GAAgB;IAC3C,UAAU,EAAE,aAAa,EAAE;IAC3B,MAAM,EAAE,EAAE;CACb,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAe;IACzC,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,KAAK,EAAE,GAAG;IACV,MAAM,EAAE,GAAG;IACX,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,CAAA;oBACD,MAAM,IAAI,GAAG,WAAW,CACpB,KAAK,CAAC,UAAU,CAAC,KAAK,EACtB,KAAK,CAAC,UAAU,CAAC,MAAM,EACvB,QAAQ,CAAC,CAAC,EACV,QAAQ,CAAC,CAAC,EACV,UAAU,CAAC,KAAK,EAChB,UAAU,CAAC,MAAM,CACpB,CAAA;oBACD,qDACO,UAAU,GACV,QAAQ,GACR,IAAI,EACV;gBACL,CAAC,CAAC,IACL;QACL;YACI,MAAM,IAAI,KAAK,EAAE,CAAA;IACzB,CAAC;AACL,CAAC,CAAA","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport {getWindowSize} from './getWindowSize'\r\nimport {clamp} from './clamp'\r\n\r\nconst mapObject = <T>(o: { [key: string]: T }, f: (value: T) => T): { [key: string]: T } =>\r\n Object.assign({}, ...Object.keys(o).map(k => ({[k]: f(o[k])})))\r\n\r\n// ID for a specific modal.\r\nexport type ModalID = string\r\n\r\n// State for a specific modal.\r\nexport interface ModalState {\r\n x: number\r\n y: number\r\n width: number\r\n height: number\r\n visible: boolean\r\n /** rectangle to return to when un-maximizing; set only while the dialog is maximized */\r\n restore?: { x: number; y: number; width: number; height: number }\r\n}\r\n\r\n// State of all modals.\r\nexport interface ModalsState {\r\n windowSize: {\r\n width: number\r\n height: number\r\n }\r\n modals: {\r\n [key: string]: ModalState\r\n }\r\n}\r\n\r\nexport const initialModalsState: ModalsState = {\r\n windowSize: getWindowSize(),\r\n modals: {},\r\n};\r\n\r\nexport const initialModalState: ModalState = {\r\n x: 0,\r\n y: 0,\r\n width: 400,\r\n height: 400,\r\n visible: false,\r\n};\r\n\r\nconst getInitialModalState = ({\r\n initialWidth = initialModalState.width,\r\n initialHeight = initialModalState.height,\r\n }: {\r\n initialWidth?: number\r\n initialHeight?: number\r\n}) => {\r\n return {\r\n ...initialModalState,\r\n width: initialWidth,\r\n height: initialHeight,\r\n }\r\n}\r\n\r\nexport type Action =\r\n | { type: 'show'; id: ModalID }\r\n | { type: 'hide'; id: ModalID }\r\n | { type: 'focus'; id: ModalID }\r\n | { type: 'unmount'; id: ModalID }\r\n | { type: 'mount'; id: ModalID, intialState: { initialWidth?: number; initialHeight?: number } }\r\n | { type: 'windowResize'; size: { width: number; height: number } }\r\n | { type: 'drag'; id: ModalID; x: number; y: number }\r\n /**\r\n * Toggle: fills the window leaving `margin` px of free space in total (half of it on each side),\r\n * or returns to the rectangle from before maximizing.\r\n */\r\n | { type: 'maximize'; id: ModalID; margin: number }\r\n | {\r\n type: 'resize'\r\n id: ModalID\r\n x: number\r\n y: number\r\n width: number\r\n height: number\r\n}\r\n\r\nexport const getModalState = ({\r\n state,\r\n id,\r\n initialWidth,\r\n initialHeight,\r\n }: {\r\n state: ModalsState\r\n id: ModalID\r\n initialWidth?: number\r\n initialHeight?: number\r\n}): ModalState => state.modals[id] || getInitialModalState({ initialWidth, initialHeight })\r\n\r\nconst clampDrag = (\r\n windowWidth: number,\r\n windowHeight: number,\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n): { x: number; y: number } => {\r\n const maxX = windowWidth - width;\r\n const maxY = windowHeight - height;\r\n const clampedX = clamp(0, maxX, x);\r\n const clampedY = clamp(0, maxY, y);\r\n return {x: clampedX, y: clampedY}\r\n}\r\n\r\nconst clampResize = (\r\n windowWidth: number,\r\n windowHeight: number,\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n): { width: number; height: number } => {\r\n const maxWidth = windowWidth - x;\r\n const maxHeight = windowHeight - y;\r\n const clampedWidth = clamp(200, maxWidth, width);\r\n const clampedHeight = clamp(200, maxHeight, height);\r\n return {width: clampedWidth, height: clampedHeight}\r\n}\r\n\r\nexport const draggableModalReducer = (state: ModalsState, action: Action): ModalsState => {\r\n switch (action.type) {\r\n case 'resize':\r\n const size = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n action.x,\r\n action.y,\r\n action.width,\r\n action.height,\r\n )\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...state.modals[action.id],\r\n ...size,\r\n // resizing by hand takes the dialog out of the maximized state\r\n restore: undefined,\r\n },\r\n },\r\n }\r\n case 'maximize': {\r\n const modalState = state.modals[action.id];\r\n const {restore} = modalState;\r\n if (restore) {\r\n // the window may have shrunk in the meantime, so the old rectangle goes through the\r\n // same clamping as a manual drag/resize\r\n const position = clampDrag(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n restore.x,\r\n restore.y,\r\n restore.width,\r\n restore.height,\r\n )\r\n const size = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n position.x,\r\n position.y,\r\n restore.width,\r\n restore.height,\r\n )\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n ...position,\r\n ...size,\r\n restore: undefined,\r\n },\r\n },\r\n }\r\n }\r\n const inset = action.margin / 2;\r\n const maximized = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n inset,\r\n inset,\r\n state.windowSize.width - action.margin,\r\n state.windowSize.height - action.margin,\r\n )\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n x: inset,\r\n y: inset,\r\n ...maximized,\r\n restore: {\r\n x: modalState.x,\r\n y: modalState.y,\r\n width: modalState.width,\r\n height: modalState.height,\r\n },\r\n },\r\n },\r\n }\r\n }\r\n case 'drag':\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...state.modals[action.id],\r\n ...clampDrag(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n action.x,\r\n action.y,\r\n state.modals[action.id].width,\r\n state.modals[action.id].height,\r\n ),\r\n },\r\n },\r\n }\r\n case 'show': {\r\n const modalState = state.modals[action.id]\r\n const centerX = state.windowSize.width / 2 - modalState.width / 2\r\n const centerY = state.windowSize.height / 2 - modalState.height / 2\r\n const position = clampDrag(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n centerX,\r\n centerY,\r\n modalState.width,\r\n modalState.height,\r\n )\r\n const size = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n position.x,\r\n position.y,\r\n modalState.width,\r\n modalState.height,\r\n )\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n ...position,\r\n ...size,\r\n visible: true,\r\n },\r\n },\r\n }\r\n }\r\n case 'focus':\r\n const modalState = state.modals[action.id]\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n },\r\n },\r\n }\r\n case 'hide': {\r\n const modalState = state.modals[action.id]\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n visible: false,\r\n },\r\n },\r\n }\r\n }\r\n case 'mount':\r\n const initialState = getInitialModalState(action.intialState);\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...initialState,\r\n x: state.windowSize.width / 2 - initialState.width / 2,\r\n y: state.windowSize.height / 2 - initialState.height / 2,\r\n },\r\n },\r\n };\r\n case 'unmount':\r\n const modalsClone = {...state.modals};\r\n delete modalsClone[action.id];\r\n return {\r\n ...state,\r\n modals: modalsClone,\r\n };\r\n case 'windowResize':\r\n return {\r\n ...state,\r\n windowSize: action.size,\r\n modals: mapObject(state.modals, (modalState: ModalState) => {\r\n if (!modalState.visible) {\r\n return modalState\r\n }\r\n const position = clampDrag(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n modalState.x,\r\n modalState.y,\r\n modalState.width,\r\n modalState.height,\r\n )\r\n const size = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n position.x,\r\n position.y,\r\n modalState.width,\r\n modalState.height,\r\n )\r\n return {\r\n ...modalState,\r\n ...position,\r\n ...size,\r\n }\r\n }),\r\n }\r\n default:\r\n throw new Error()\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"draggableModal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UAAU,CAAC,KAAK,GAAG,CAAC,GAAG,YAAY,CAAC,KAAK,GAAG,CAAC,EACtD,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,UAGlE;QACN,KAAK,SAAS;YACV,MAAM,WAAW,qBAAO,KAAK,CAAC,MAAM,CAAC,CAAC;YACtC,OAAO,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC9B,uCACO,KAAK,KACR,MAAM,EAAE,WAAW,IACrB;QACN,KAAK,cAAc;YACf,uCACO,KAAK,KACR,UAAU,EAAE,MAAM,CAAC,IAAI,EACvB,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,UAAsB,EAAE,EAAE;oBACvD,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;wBACtB,OAAO,UAAU,CAAA;oBACrB,CAAC;oBACD,MAAM,QAAQ,GAAG,SAAS,CACtB,KAAK,CAAC,UAAU,CAAC,KAAK,EACtB,KAAK,CAAC,UAAU,CAAC,MAAM,EACvB,UAAU,CAAC,CAAC,EACZ,UAAU,CAAC,CAAC,EACZ,UAAU,CAAC,KAAK,EAChB,UAAU,CAAC,MAAM,CACpB,CAAA;oBACD,MAAM,IAAI,GAAG,WAAW,CACpB,KAAK,CAAC,UAAU,CAAC,KAAK,EACtB,KAAK,CAAC,UAAU,CAAC,MAAM,EACvB,QAAQ,CAAC,CAAC,EACV,QAAQ,CAAC,CAAC,EACV,UAAU,CAAC,KAAK,EAChB,UAAU,CAAC,MAAM,CACpB,CAAA;oBACD,qDACO,UAAU,GACV,QAAQ,GACR,IAAI,EACV;gBACL,CAAC,CAAC,IACL;QACL;YACI,MAAM,IAAI,KAAK,EAAE,CAAA;IACzB,CAAC;AACL,CAAC,CAAA","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport {getWindowSize} from './getWindowSize'\r\nimport {clamp} from './clamp'\r\n\r\nconst mapObject = <T>(o: { [key: string]: T }, f: (value: T) => T): { [key: string]: T } =>\r\n Object.assign({}, ...Object.keys(o).map(k => ({[k]: f(o[k])})))\r\n\r\n// ID for a specific modal.\r\nexport type ModalID = string\r\n\r\n// State for a specific modal.\r\nexport interface ModalState {\r\n x: number\r\n y: number\r\n width: number\r\n height: number\r\n visible: boolean\r\n /** rectangle to return to when un-maximizing; set only while the dialog is maximized */\r\n restore?: { x: number; y: number; width: number; height: number }\r\n}\r\n\r\n// State of all modals.\r\nexport interface ModalsState {\r\n windowSize: {\r\n width: number\r\n height: number\r\n }\r\n modals: {\r\n [key: string]: ModalState\r\n }\r\n}\r\n\r\nexport const initialModalsState: ModalsState = {\r\n windowSize: getWindowSize(),\r\n modals: {},\r\n};\r\n\r\n/** Free space in total (half on each side) a maximized dialog, or one opened larger than the window, leaves around it. */\r\nexport const WINDOW_MARGIN = 32\r\n\r\nexport const initialModalState: ModalState = {\r\n x: 0,\r\n y: 0,\r\n width: 400,\r\n height: 400,\r\n visible: false,\r\n};\r\n\r\nconst getInitialModalState = ({\r\n initialWidth = initialModalState.width,\r\n initialHeight = initialModalState.height,\r\n }: {\r\n initialWidth?: number\r\n initialHeight?: number\r\n}) => {\r\n return {\r\n ...initialModalState,\r\n width: initialWidth,\r\n height: initialHeight,\r\n }\r\n}\r\n\r\nexport type Action =\r\n | { type: 'show'; id: ModalID }\r\n | { type: 'hide'; id: ModalID }\r\n | { type: 'unmount'; id: ModalID }\r\n | { type: 'mount'; id: ModalID, intialState: { initialWidth?: number; initialHeight?: number } }\r\n | { type: 'windowResize'; size: { width: number; height: number } }\r\n | { type: 'drag'; id: ModalID; x: number; y: number }\r\n /**\r\n * Toggle: fills the window leaving `margin` px of free space in total (half of it on each side),\r\n * or returns to the rectangle from before maximizing.\r\n */\r\n | { type: 'maximize'; id: ModalID; margin: number }\r\n | {\r\n type: 'resize'\r\n id: ModalID\r\n x: number\r\n y: number\r\n width: number\r\n height: number\r\n}\r\n\r\nexport const getModalState = ({\r\n state,\r\n id,\r\n initialWidth,\r\n initialHeight,\r\n }: {\r\n state: ModalsState\r\n id: ModalID\r\n initialWidth?: number\r\n initialHeight?: number\r\n}): ModalState => state.modals[id] || getInitialModalState({ initialWidth, initialHeight })\r\n\r\nconst clampDrag = (\r\n windowWidth: number,\r\n windowHeight: number,\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n): { x: number; y: number } => {\r\n const maxX = windowWidth - width;\r\n const maxY = windowHeight - height;\r\n const clampedX = clamp(0, maxX, x);\r\n const clampedY = clamp(0, maxY, y);\r\n return {x: clampedX, y: clampedY}\r\n}\r\n\r\nconst clampResize = (\r\n windowWidth: number,\r\n windowHeight: number,\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n): { width: number; height: number } => {\r\n const maxWidth = windowWidth - x;\r\n const maxHeight = windowHeight - y;\r\n const clampedWidth = clamp(200, maxWidth, width);\r\n const clampedHeight = clamp(200, maxHeight, height);\r\n return {width: clampedWidth, height: clampedHeight}\r\n}\r\n\r\nexport const draggableModalReducer = (state: ModalsState, action: Action): ModalsState => {\r\n switch (action.type) {\r\n case 'resize':\r\n const size = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n action.x,\r\n action.y,\r\n action.width,\r\n action.height,\r\n )\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...state.modals[action.id],\r\n ...size,\r\n // resizing by hand takes the dialog out of the maximized state\r\n restore: undefined,\r\n },\r\n },\r\n }\r\n case 'maximize': {\r\n const modalState = state.modals[action.id];\r\n const {restore} = modalState;\r\n if (restore) {\r\n // the window may have shrunk in the meantime, so the old rectangle goes through the\r\n // same clamping as a manual drag/resize\r\n const position = clampDrag(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n restore.x,\r\n restore.y,\r\n restore.width,\r\n restore.height,\r\n )\r\n const size = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n position.x,\r\n position.y,\r\n restore.width,\r\n restore.height,\r\n )\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n ...position,\r\n ...size,\r\n restore: undefined,\r\n },\r\n },\r\n }\r\n }\r\n const inset = action.margin / 2;\r\n const maximized = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n inset,\r\n inset,\r\n state.windowSize.width - action.margin,\r\n state.windowSize.height - action.margin,\r\n )\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n x: inset,\r\n y: inset,\r\n ...maximized,\r\n restore: {\r\n x: modalState.x,\r\n y: modalState.y,\r\n width: modalState.width,\r\n height: modalState.height,\r\n },\r\n },\r\n },\r\n }\r\n }\r\n case 'drag':\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...state.modals[action.id],\r\n ...clampDrag(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n action.x,\r\n action.y,\r\n state.modals[action.id].width,\r\n state.modals[action.id].height,\r\n ),\r\n },\r\n },\r\n }\r\n case 'show': {\r\n const modalState = state.modals[action.id]\r\n // a dialog larger than the window opens shrunk to it, with the margin a maximized one keeps\r\n const width = Math.min(modalState.width, state.windowSize.width - WINDOW_MARGIN)\r\n const height = Math.min(modalState.height, state.windowSize.height - WINDOW_MARGIN)\r\n const centerX = state.windowSize.width / 2 - width / 2\r\n const centerY = state.windowSize.height / 2 - height / 2\r\n const position = clampDrag(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n centerX,\r\n centerY,\r\n width,\r\n height,\r\n )\r\n const size = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n position.x,\r\n position.y,\r\n width,\r\n height,\r\n )\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n ...position,\r\n ...size,\r\n visible: true,\r\n },\r\n },\r\n }\r\n }\r\n case 'hide': {\r\n const modalState = state.modals[action.id]\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n visible: false,\r\n },\r\n },\r\n }\r\n }\r\n case 'mount':\r\n const initialState = getInitialModalState(action.intialState);\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...initialState,\r\n x: state.windowSize.width / 2 - initialState.width / 2,\r\n y: state.windowSize.height / 2 - initialState.height / 2,\r\n },\r\n },\r\n };\r\n case 'unmount':\r\n const modalsClone = {...state.modals};\r\n delete modalsClone[action.id];\r\n return {\r\n ...state,\r\n modals: modalsClone,\r\n };\r\n case 'windowResize':\r\n return {\r\n ...state,\r\n windowSize: action.size,\r\n modals: mapObject(state.modals, (modalState: ModalState) => {\r\n if (!modalState.visible) {\r\n return modalState\r\n }\r\n const position = clampDrag(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n modalState.x,\r\n modalState.y,\r\n modalState.width,\r\n modalState.height,\r\n )\r\n const size = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n position.x,\r\n position.y,\r\n modalState.width,\r\n modalState.height,\r\n )\r\n return {\r\n ...modalState,\r\n ...position,\r\n ...size,\r\n }\r\n }),\r\n }\r\n default:\r\n throw new Error()\r\n }\r\n}\r\n"]}
@@ -51,7 +51,8 @@ export interface ModalDialogProps extends DraggableModalProps {
51
51
  * Dialog with a predefined, localized button set (see {@link ModalDialogMode}).
52
52
  *
53
53
  * As a component it renders a draggable (by the title), resizable (bottom-right handle) and maximizable antd
54
- * `Modal` that is kept inside the window and destroyed when hidden. It must be rendered inside a
54
+ * `Modal` that is kept inside the window and destroyed when hidden, unless `destroyOnHidden={false}` keeps its content
55
+ * mounted. Every opening brings it on top of the modals opened before. It must be rendered inside a
55
56
  * `DraggableModalProvider` (`d2coreui/components/modal/draggableModalProvider`), otherwise it throws.
56
57
  * Note that in {@link ModalDialogMode.OK} mode the component still renders the Cancel button; only the static
57
58
  * methods hide it.
@@ -40,7 +40,8 @@ export var ModalDialogMode;
40
40
  * Dialog with a predefined, localized button set (see {@link ModalDialogMode}).
41
41
  *
42
42
  * As a component it renders a draggable (by the title), resizable (bottom-right handle) and maximizable antd
43
- * `Modal` that is kept inside the window and destroyed when hidden. It must be rendered inside a
43
+ * `Modal` that is kept inside the window and destroyed when hidden, unless `destroyOnHidden={false}` keeps its content
44
+ * mounted. Every opening brings it on top of the modals opened before. It must be rendered inside a
44
45
  * `DraggableModalProvider` (`d2coreui/components/modal/draggableModalProvider`), otherwise it throws.
45
46
  * Note that in {@link ModalDialogMode.OK} mode the component still renders the Cancel button; only the static
46
47
  * methods hide it.
@@ -1 +1 @@
1
- {"version":3,"file":"modalDialog.js","sourceRoot":"","sources":["../../../../components/modal/modalDialog.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,MAAM,CAAC;AAEnC,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAC,cAAc,EAAsB,MAAM,gCAAgC,CAAC;AAGnF;;;GAGG;AACH,MAAM,CAAN,IAAkB,eAiBjB;AAjBD,WAAkB,eAAe;IAC7B;;;OAGG;IACH,4CAAyB,CAAA;IACzB,iCAAiC;IACjC,0CAAuB,CAAA;IACvB,mDAAmD;IACnD,oCAAiB,CAAA;IACjB;;;OAGG;IACH,kDAA+B,CAAA;IAC/B,qFAAqF;IACrF,4BAAS,CAAA;AACb,CAAC,EAjBiB,eAAe,KAAf,eAAe,QAiBhC;AA2BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK,CAAC,SAA+B;IAGlE,YAAY,KAAiC;QACzC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,gBAAgB,CAAC,QAAiB;QAC5C,WAAW,CAAC,WAAW,GAAG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,EAAE,EAAE,EAAC,KAAK,EAAE,EAAC,KAAK,EAAE,OAAO,EAAC,EAAC,CAAC,CAAC;QAC1I,CAAC;QAED,IAAI,IAAI,wDAAkC,EAAE,CAAC;YACzC,IAAI,IAAI,CAAC,iBAAiB,IAAI,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;gBACzD,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;gBACzC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;gBAC5C,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;gBAChD,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,UAAU,GAAG,aAAa,CAAC;YAC5D,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import React from \"react\";\r\nimport {Button, Modal} from \"antd\";\r\nimport {ModalFuncProps} from \"antd/es/modal\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {DraggableModal, DraggableModalProps} from \"d2coreui/components/modal/impl\";\r\nimport {HookAPI} from \"antd/es/modal/useModal\";\r\n\r\n/**\r\n * Button set of a {@link ModalDialog}. Button labels are localized and can be overridden with `okText` /\r\n * `cancelText` (and `denyText`).\r\n */\r\nexport const enum ModalDialogMode {\r\n /**\r\n * No footer, unless a `footer` is given explicitly. Honored only by the component; the static methods show\r\n * antd's default buttons.\r\n */\r\n NO_BUTTONS = \"NO_BUTTONS\",\r\n /** \"OK\" and \"Cancel\" buttons. */\r\n OK_CANCEL = \"OK_CANCEL\",\r\n /** \"Yes\" and \"No\" buttons; \"No\" acts as cancel. */\r\n YES_NO = \"YES_NO\",\r\n /**\r\n * \"Yes\", \"No\" and \"Cancel\" buttons: \"Yes\" calls `onOk`, \"No\" calls `onDeny` and \"Cancel\" `onCancel`.\r\n * Supported only by the static methods; the component renders antd's default buttons in this mode.\r\n */\r\n YES_NO_CANCEL = \"YES_NO_CANCEL\",\r\n /** Only an \"OK\" button (see the note at {@link ModalDialog} about the component). */\r\n OK = \"OK\",\r\n}\r\n\r\n/**\r\n * Options of the static {@link ModalDialog} methods: antd `ModalFuncProps` plus the button mode.\r\n * `autoFocusButton` defaults to `\"ok\"`.\r\n */\r\nexport interface ModalDialogFuncProps extends ModalFuncProps {\r\n /** Button set of the dialog. */\r\n mode: ModalDialogMode\r\n /** Label of the \"No\" button in {@link ModalDialogMode.YES_NO_CANCEL} mode; defaults to localized \"No\". */\r\n denyText?: string\r\n /**\r\n * Called with the click event when the \"No\" button is clicked in {@link ModalDialogMode.YES_NO_CANCEL} mode;\r\n * the dialog is closed afterwards.\r\n */\r\n onDeny?: (...args: any[]) => any;\r\n}\r\n\r\n/**\r\n * Props of the {@link ModalDialog} component: antd `ModalProps` (except `width`) plus `initialWidth`,\r\n * `initialHeight`, `maximizable` and `onResize` of the draggable modal, and the button mode.\r\n */\r\nexport interface ModalDialogProps extends DraggableModalProps {\r\n /** Button set of the dialog. */\r\n mode: ModalDialogMode\r\n}\r\n\r\n/**\r\n * Dialog with a predefined, localized button set (see {@link ModalDialogMode}).\r\n *\r\n * As a component it renders a draggable (by the title), resizable (bottom-right handle) and maximizable antd\r\n * `Modal` that is kept inside the window and destroyed when hidden. It must be rendered inside a\r\n * `DraggableModalProvider` (`d2coreui/components/modal/draggableModalProvider`), otherwise it throws.\r\n * Note that in {@link ModalDialogMode.OK} mode the component still renders the Cancel button; only the static\r\n * methods hide it.\r\n *\r\n * The static methods open imperative antd dialogs; register the app's modal API once with\r\n * {@link ModalDialog.setModalInstance}. They modify the passed `okButtonProps` / `cancelButtonProps` objects and\r\n * replace their `style`.\r\n *\r\n * @example\r\n * <DraggableModalProvider>\r\n * <ModalDialog mode={ModalDialogMode.OK_CANCEL} open={open} title=\"Rename\"\r\n * initialWidth={480} initialHeight={240}\r\n * onOk={save} onCancel={() => setOpen(false)}>\r\n * <Input value={name} onChange={e => setName(e.target.value)}/>\r\n * </ModalDialog>\r\n * </DraggableModalProvider>\r\n *\r\n * @example\r\n * ModalDialog.confirm({\r\n * mode: ModalDialogMode.YES_NO_CANCEL,\r\n * title: \"Save changes?\",\r\n * onOk: save,\r\n * onDeny: discard,\r\n * });\r\n */\r\nexport class ModalDialog extends React.Component<ModalDialogProps, {}> {\r\n private static modalStatic: HookAPI;\r\n\r\n constructor(props: Readonly<ModalDialogProps>) {\r\n super(props);\r\n }\r\n\r\n /**\r\n * Registers the antd `modal` API from `App.useApp()` for the static methods, so that their dialogs inherit the app's\r\n * theme, locale and context. Until it is called they fall back to antd's static `Modal` functions.\r\n */\r\n public static setModalInstance(instance: HookAPI) {\r\n ModalDialog.modalStatic = instance;\r\n }\r\n\r\n /**\r\n * Opens a confirmation dialog (antd `confirm`) with the buttons of `props.mode`.\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static confirm(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.confirm : Modal.confirm;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n /**\r\n * Opens an error dialog (antd `error`) with the buttons of `props.mode`.\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static error(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.error : Modal.error;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n /**\r\n * Opens a confirmation dialog like {@link ModalDialog.confirm} with a danger OK button. The button is marked as\r\n * danger only when `props.okButtonProps` is passed (an empty object is enough).\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static delete(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.confirm : Modal.confirm;\r\n if (props.okButtonProps) {\r\n props.okButtonProps.danger = true;\r\n }\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n /**\r\n * Opens a success dialog (antd `success`) with the buttons of `props.mode`.\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static success(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.success : Modal.success;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n /**\r\n * Opens an information dialog (antd `info`) with the buttons of `props.mode`.\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static info(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.info : Modal.info;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n render() {\r\n const modalDialogProperties = ModalDialog.getModalProperties(this.props);\r\n return (\r\n <DraggableModal {...modalDialogProperties}>\r\n {this.props.children}\r\n </DraggableModal>);\r\n }\r\n\r\n private static getModalProperties(props: ModalDialogProps) {\r\n const {mode, ...rest} = props;\r\n if (mode === ModalDialogMode.NO_BUTTONS) {\r\n if (rest.footer === undefined) {\r\n rest.footer = null;\r\n }\r\n } else {\r\n switch (mode) {\r\n case ModalDialogMode.OK_CANCEL:\r\n rest.okText = props.okText ?? i18n(\"OK\");\r\n rest.cancelText = props.cancelText ?? i18n(\"Cancel\");\r\n break;\r\n case ModalDialogMode.YES_NO:\r\n rest.okText = props.okText ?? i18n(\"Yes\");\r\n rest.cancelText = props.cancelText ?? i18n(\"No\");\r\n break;\r\n case ModalDialogMode.OK:\r\n rest.okText = props.okText ?? i18n(\"OK\");\r\n rest.cancelButtonProps = undefined;\r\n break;\r\n }\r\n\r\n rest.okButtonProps = Object.assign(rest.okButtonProps !== undefined ? rest.okButtonProps : {}, {style: {marginRight: 8}});\r\n rest.cancelButtonProps = Object.assign(rest.cancelButtonProps !== undefined ? rest.cancelButtonProps : {}, {style: {float: \"right\"}});\r\n }\r\n return rest;\r\n }\r\n\r\n private static getModalFuncProperties(props: ModalDialogFuncProps, performClose: () => void) {\r\n const {mode, denyText, onDeny, ...rest} = props;\r\n switch (mode) {\r\n case ModalDialogMode.OK_CANCEL:\r\n rest.okText = rest.okText ?? i18n(\"OK\");\r\n rest.cancelText = rest.cancelText ?? i18n(\"Cancel\");\r\n break;\r\n case ModalDialogMode.YES_NO:\r\n rest.okText = rest.okText ?? i18n(\"Yes\");\r\n rest.cancelText = rest.cancelText ?? i18n(\"No\");\r\n break;\r\n case ModalDialogMode.YES_NO_CANCEL:\r\n rest.okText = rest.okText ?? i18n(\"Yes\");\r\n rest.cancelText = (<React.Fragment>\r\n <Button onClick={(e) => {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n e.nativeEvent.stopImmediatePropagation();\r\n onDeny?.(e);\r\n performClose();\r\n }}>{denyText ?? i18n(\"No\")}</Button>\r\n <Button>{rest.cancelText ?? i18n(\"Cancel\")}</Button>\r\n </React.Fragment>\r\n );\r\n if (!rest.cancelButtonProps) {\r\n rest.cancelButtonProps = {};\r\n }\r\n rest.cancelButtonProps.type = \"text\";\r\n break;\r\n case ModalDialogMode.OK:\r\n rest.okText = props.okText ?? i18n(\"OK\");\r\n rest.cancelButtonProps = {style: {display: \"none\"}};\r\n }\r\n if (rest.autoFocusButton === undefined) {\r\n rest.autoFocusButton = \"ok\";\r\n }\r\n\r\n rest.okButtonProps = Object.assign(rest.okButtonProps !== undefined ? rest.okButtonProps : {}, {style: {marginRight: 8}});\r\n\r\n if (mode !== ModalDialogMode.OK) {\r\n rest.cancelButtonProps = Object.assign(rest.cancelButtonProps !== undefined ? rest.cancelButtonProps : {}, {style: {float: \"right\"}});\r\n }\r\n\r\n if (mode === ModalDialogMode.YES_NO_CANCEL) {\r\n if (rest.cancelButtonProps && rest.cancelButtonProps.style) {\r\n rest.cancelButtonProps.style.padding = 0;\r\n rest.cancelButtonProps.style.marginTop = -1;\r\n rest.cancelButtonProps.style.cursor = \"default\";\r\n rest.cancelButtonProps.style.background = \"transparent\";\r\n }\r\n }\r\n return rest;\r\n }\r\n}"]}
1
+ {"version":3,"file":"modalDialog.js","sourceRoot":"","sources":["../../../../components/modal/modalDialog.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,MAAM,CAAC;AAEnC,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAC,cAAc,EAAsB,MAAM,gCAAgC,CAAC;AAGnF;;;GAGG;AACH,MAAM,CAAN,IAAkB,eAiBjB;AAjBD,WAAkB,eAAe;IAC7B;;;OAGG;IACH,4CAAyB,CAAA;IACzB,iCAAiC;IACjC,0CAAuB,CAAA;IACvB,mDAAmD;IACnD,oCAAiB,CAAA;IACjB;;;OAGG;IACH,kDAA+B,CAAA;IAC/B,qFAA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CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,EAAE,EAAC,KAAK,EAAE,EAAC,WAAW,EAAE,CAAC,EAAC,EAAC,CAAC,CAAC;QAE1H,IAAI,IAAI,kCAAuB,EAAE,CAAC;YAC9B,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAC,KAAK,EAAE,EAAC,KAAK,EAAE,OAAO,EAAC,EAAC,CAAC,CAAC;QAC1I,CAAC;QAED,IAAI,IAAI,wDAAkC,EAAE,CAAC;YACzC,IAAI,IAAI,CAAC,iBAAiB,IAAI,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;gBACzD,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;gBACzC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;gBAC5C,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;gBAChD,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,UAAU,GAAG,aAAa,CAAC;YAC5D,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import React from \"react\";\r\nimport {Button, Modal} from \"antd\";\r\nimport {ModalFuncProps} from \"antd/es/modal\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {DraggableModal, DraggableModalProps} from \"d2coreui/components/modal/impl\";\r\nimport {HookAPI} from \"antd/es/modal/useModal\";\r\n\r\n/**\r\n * Button set of a {@link ModalDialog}. Button labels are localized and can be overridden with `okText` /\r\n * `cancelText` (and `denyText`).\r\n */\r\nexport const enum ModalDialogMode {\r\n /**\r\n * No footer, unless a `footer` is given explicitly. Honored only by the component; the static methods show\r\n * antd's default buttons.\r\n */\r\n NO_BUTTONS = \"NO_BUTTONS\",\r\n /** \"OK\" and \"Cancel\" buttons. */\r\n OK_CANCEL = \"OK_CANCEL\",\r\n /** \"Yes\" and \"No\" buttons; \"No\" acts as cancel. */\r\n YES_NO = \"YES_NO\",\r\n /**\r\n * \"Yes\", \"No\" and \"Cancel\" buttons: \"Yes\" calls `onOk`, \"No\" calls `onDeny` and \"Cancel\" `onCancel`.\r\n * Supported only by the static methods; the component renders antd's default buttons in this mode.\r\n */\r\n YES_NO_CANCEL = \"YES_NO_CANCEL\",\r\n /** Only an \"OK\" button (see the note at {@link ModalDialog} about the component). */\r\n OK = \"OK\",\r\n}\r\n\r\n/**\r\n * Options of the static {@link ModalDialog} methods: antd `ModalFuncProps` plus the button mode.\r\n * `autoFocusButton` defaults to `\"ok\"`.\r\n */\r\nexport interface ModalDialogFuncProps extends ModalFuncProps {\r\n /** Button set of the dialog. */\r\n mode: ModalDialogMode\r\n /** Label of the \"No\" button in {@link ModalDialogMode.YES_NO_CANCEL} mode; defaults to localized \"No\". */\r\n denyText?: string\r\n /**\r\n * Called with the click event when the \"No\" button is clicked in {@link ModalDialogMode.YES_NO_CANCEL} mode;\r\n * the dialog is closed afterwards.\r\n */\r\n onDeny?: (...args: any[]) => any;\r\n}\r\n\r\n/**\r\n * Props of the {@link ModalDialog} component: antd `ModalProps` (except `width`) plus `initialWidth`,\r\n * `initialHeight`, `maximizable` and `onResize` of the draggable modal, and the button mode.\r\n */\r\nexport interface ModalDialogProps extends DraggableModalProps {\r\n /** Button set of the dialog. */\r\n mode: ModalDialogMode\r\n}\r\n\r\n/**\r\n * Dialog with a predefined, localized button set (see {@link ModalDialogMode}).\r\n *\r\n * As a component it renders a draggable (by the title), resizable (bottom-right handle) and maximizable antd\r\n * `Modal` that is kept inside the window and destroyed when hidden, unless `destroyOnHidden={false}` keeps its content\r\n * mounted. Every opening brings it on top of the modals opened before. It must be rendered inside a\r\n * `DraggableModalProvider` (`d2coreui/components/modal/draggableModalProvider`), otherwise it throws.\r\n * Note that in {@link ModalDialogMode.OK} mode the component still renders the Cancel button; only the static\r\n * methods hide it.\r\n *\r\n * The static methods open imperative antd dialogs; register the app's modal API once with\r\n * {@link ModalDialog.setModalInstance}. They modify the passed `okButtonProps` / `cancelButtonProps` objects and\r\n * replace their `style`.\r\n *\r\n * @example\r\n * <DraggableModalProvider>\r\n * <ModalDialog mode={ModalDialogMode.OK_CANCEL} open={open} title=\"Rename\"\r\n * initialWidth={480} initialHeight={240}\r\n * onOk={save} onCancel={() => setOpen(false)}>\r\n * <Input value={name} onChange={e => setName(e.target.value)}/>\r\n * </ModalDialog>\r\n * </DraggableModalProvider>\r\n *\r\n * @example\r\n * ModalDialog.confirm({\r\n * mode: ModalDialogMode.YES_NO_CANCEL,\r\n * title: \"Save changes?\",\r\n * onOk: save,\r\n * onDeny: discard,\r\n * });\r\n */\r\nexport class ModalDialog extends React.Component<ModalDialogProps, {}> {\r\n private static modalStatic: HookAPI;\r\n\r\n constructor(props: Readonly<ModalDialogProps>) {\r\n super(props);\r\n }\r\n\r\n /**\r\n * Registers the antd `modal` API from `App.useApp()` for the static methods, so that their dialogs inherit the app's\r\n * theme, locale and context. Until it is called they fall back to antd's static `Modal` functions.\r\n */\r\n public static setModalInstance(instance: HookAPI) {\r\n ModalDialog.modalStatic = instance;\r\n }\r\n\r\n /**\r\n * Opens a confirmation dialog (antd `confirm`) with the buttons of `props.mode`.\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static confirm(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.confirm : Modal.confirm;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n /**\r\n * Opens an error dialog (antd `error`) with the buttons of `props.mode`.\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static error(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.error : Modal.error;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n /**\r\n * Opens a confirmation dialog like {@link ModalDialog.confirm} with a danger OK button. The button is marked as\r\n * danger only when `props.okButtonProps` is passed (an empty object is enough).\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static delete(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.confirm : Modal.confirm;\r\n if (props.okButtonProps) {\r\n props.okButtonProps.danger = true;\r\n }\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n /**\r\n * Opens a success dialog (antd `success`) with the buttons of `props.mode`.\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static success(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.success : Modal.success;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n /**\r\n * Opens an information dialog (antd `info`) with the buttons of `props.mode`.\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static info(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.info : Modal.info;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n render() {\r\n const modalDialogProperties = ModalDialog.getModalProperties(this.props);\r\n return (\r\n <DraggableModal {...modalDialogProperties}>\r\n {this.props.children}\r\n </DraggableModal>);\r\n }\r\n\r\n private static getModalProperties(props: ModalDialogProps) {\r\n const {mode, ...rest} = props;\r\n if (mode === ModalDialogMode.NO_BUTTONS) {\r\n if (rest.footer === undefined) {\r\n rest.footer = null;\r\n }\r\n } else {\r\n switch (mode) {\r\n case ModalDialogMode.OK_CANCEL:\r\n rest.okText = props.okText ?? i18n(\"OK\");\r\n rest.cancelText = props.cancelText ?? i18n(\"Cancel\");\r\n break;\r\n case ModalDialogMode.YES_NO:\r\n rest.okText = props.okText ?? i18n(\"Yes\");\r\n rest.cancelText = props.cancelText ?? i18n(\"No\");\r\n break;\r\n case ModalDialogMode.OK:\r\n rest.okText = props.okText ?? i18n(\"OK\");\r\n rest.cancelButtonProps = undefined;\r\n break;\r\n }\r\n\r\n rest.okButtonProps = Object.assign(rest.okButtonProps !== undefined ? rest.okButtonProps : {}, {style: {marginRight: 8}});\r\n rest.cancelButtonProps = Object.assign(rest.cancelButtonProps !== undefined ? rest.cancelButtonProps : {}, {style: {float: \"right\"}});\r\n }\r\n return rest;\r\n }\r\n\r\n private static getModalFuncProperties(props: ModalDialogFuncProps, performClose: () => void) {\r\n const {mode, denyText, onDeny, ...rest} = props;\r\n switch (mode) {\r\n case ModalDialogMode.OK_CANCEL:\r\n rest.okText = rest.okText ?? i18n(\"OK\");\r\n rest.cancelText = rest.cancelText ?? i18n(\"Cancel\");\r\n break;\r\n case ModalDialogMode.YES_NO:\r\n rest.okText = rest.okText ?? i18n(\"Yes\");\r\n rest.cancelText = rest.cancelText ?? i18n(\"No\");\r\n break;\r\n case ModalDialogMode.YES_NO_CANCEL:\r\n rest.okText = rest.okText ?? i18n(\"Yes\");\r\n rest.cancelText = (<React.Fragment>\r\n <Button onClick={(e) => {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n e.nativeEvent.stopImmediatePropagation();\r\n onDeny?.(e);\r\n performClose();\r\n }}>{denyText ?? i18n(\"No\")}</Button>\r\n <Button>{rest.cancelText ?? i18n(\"Cancel\")}</Button>\r\n </React.Fragment>\r\n );\r\n if (!rest.cancelButtonProps) {\r\n rest.cancelButtonProps = {};\r\n }\r\n rest.cancelButtonProps.type = \"text\";\r\n break;\r\n case ModalDialogMode.OK:\r\n rest.okText = props.okText ?? i18n(\"OK\");\r\n rest.cancelButtonProps = {style: {display: \"none\"}};\r\n }\r\n if (rest.autoFocusButton === undefined) {\r\n rest.autoFocusButton = \"ok\";\r\n }\r\n\r\n rest.okButtonProps = Object.assign(rest.okButtonProps !== undefined ? rest.okButtonProps : {}, {style: {marginRight: 8}});\r\n\r\n if (mode !== ModalDialogMode.OK) {\r\n rest.cancelButtonProps = Object.assign(rest.cancelButtonProps !== undefined ? rest.cancelButtonProps : {}, {style: {float: \"right\"}});\r\n }\r\n\r\n if (mode === ModalDialogMode.YES_NO_CANCEL) {\r\n if (rest.cancelButtonProps && rest.cancelButtonProps.style) {\r\n rest.cancelButtonProps.style.padding = 0;\r\n rest.cancelButtonProps.style.marginTop = -1;\r\n rest.cancelButtonProps.style.cursor = \"default\";\r\n rest.cancelButtonProps.style.background = \"transparent\";\r\n }\r\n }\r\n return rest;\r\n }\r\n}"]}
@@ -1,9 +1,13 @@
1
1
  import { BaseReturnType } from 'antd-style';
2
2
  import { ReturnStyles } from "antd-style/lib/factories/createStyles/types";
3
- import { SizeType } from "antd/lib/config-provider/SizeContext";
3
+ import { SizeType } from "antd/es/config-provider/SizeContext";
4
4
  import { Variant } from "antd/es/config-provider";
5
- /** Render function of {@link WithCss}; receives the result of `useStyles` (`styles`, `cx`, `theme`, ...). */
6
- type WithCssChildren<T extends BaseReturnType> = (css: ReturnStyles<T>) => any;
5
+ /**
6
+ * Render function of {@link WithCss}; receives the result of `useStyles` (`styles`, `cx`, `theme`, ...) and the
7
+ * resolved `size` and `variant` - read them from here, not from the component's own props, which may leave them to
8
+ * the antd context.
9
+ */
10
+ type WithCssChildren<T extends BaseReturnType> = (css: ReturnStyles<T>, resolved: WithCssInjectedProps) => any;
7
11
  /** Props that {@link WithCss} resolves before passing them to `useStyles`. */
8
12
  type WithCssOwnProps = {
9
13
  size?: SizeType;
@@ -28,7 +32,8 @@ interface WithCssProperties<T extends BaseReturnType, P extends WithCssOwnProps>
28
32
  }
29
33
  /**
30
34
  * Lets class components use an antd-style `createStyles` hook: calls `useStyles` and renders `children(css)`.
31
- * `size` is resolved as `props.size`, then the enclosing `Space.Compact` size, then `'middle'`; `variant` as
35
+ * `size` is resolved as `props.size`, then the enclosing `Space.Compact` size, then the `ConfigProvider`
36
+ * `componentSize`, then `'middle'`; `variant` as
32
37
  * `props.variant`, then the `ConfigProvider` variant, then `'outlined'`.
33
38
  */
34
39
  export default function WithCss<T extends BaseReturnType, P extends WithCssOwnProps = {}>({ useStyles, children, props }: WithCssProperties<T, P>): any;
@@ -1,20 +1,24 @@
1
1
  import { useContext } from "react";
2
2
  import { SpaceCompactItemContext } from "antd/es/space/Compact";
3
+ import SizeContext from "antd/es/config-provider/SizeContext";
3
4
  import { ConfigContext } from "antd/es/config-provider";
4
5
  /**
5
6
  * Lets class components use an antd-style `createStyles` hook: calls `useStyles` and renders `children(css)`.
6
- * `size` is resolved as `props.size`, then the enclosing `Space.Compact` size, then `'middle'`; `variant` as
7
+ * `size` is resolved as `props.size`, then the enclosing `Space.Compact` size, then the `ConfigProvider`
8
+ * `componentSize`, then `'middle'`; `variant` as
7
9
  * `props.variant`, then the `ConfigProvider` variant, then `'outlined'`.
8
10
  */
9
11
  export default function WithCss({ useStyles, children, props }) {
10
12
  var _a, _b;
11
13
  const contextSize = useContext(SpaceCompactItemContext);
14
+ const configSize = useContext(SizeContext);
12
15
  const { variant: configVariant } = useContext(ConfigContext);
13
- const mergedSize = (props === null || props === void 0 ? void 0 : props.size) || (contextSize === null || contextSize === void 0 ? void 0 : contextSize.compactSize) || 'middle';
16
+ // same precedence as antd's internal useSize: own prop > Space.Compact > ConfigProvider > middle
17
+ const mergedSize = (props === null || props === void 0 ? void 0 : props.size) || (contextSize === null || contextSize === void 0 ? void 0 : contextSize.compactSize) || configSize || 'middle';
14
18
  // same precedence as antd's internal useVariant: own prop > ConfigProvider > outlined
15
19
  const mergedVariant = (_b = (_a = props === null || props === void 0 ? void 0 : props.variant) !== null && _a !== void 0 ? _a : configVariant) !== null && _b !== void 0 ? _b : 'outlined';
16
20
  const css = useStyles(Object.assign(Object.assign({}, props), { size: mergedSize, variant: mergedVariant }));
17
- return children(css);
21
+ return children(css, { size: mergedSize, variant: mergedVariant });
18
22
  }
19
23
  ;
20
24
  //# sourceMappingURL=withCss.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"withCss.js","sourceRoot":"","sources":["../../../../components/style/withCss.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,MAAM,OAAO,CAAC;AACjC,OAAO,EAAC,uBAAuB,EAAC,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAC,aAAa,EAAU,MAAM,yBAAyB,CAAC;AAwB/D;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAA4D,EAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,EAA0B;;IAC5I,MAAM,WAAW,GAAG,UAAU,CAAC,uBAAuB,CAAC,CAAC;IACxD,MAAM,EAAC,OAAO,EAAE,aAAa,EAAC,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAC3D,MAAM,UAAU,GAA0B,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,CAAA,IAAI,QAAQ,CAAC;IAC9F,sFAAsF;IACtF,MAAM,aAAa,GAAY,MAAA,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,mCAAI,aAAa,mCAAI,UAAU,CAAC;IAC7E,MAAM,GAAG,GAAG,SAAS,iCAAM,KAAW,KAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,IAAE,CAAC;IACnF,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAAA,CAAC","sourcesContent":["import {BaseReturnType} from 'antd-style';\r\nimport {ReturnStyles} from \"antd-style/lib/factories/createStyles/types\";\r\nimport {useContext} from \"react\";\r\nimport {SpaceCompactItemContext} from \"antd/es/space/Compact\";\r\nimport {SizeType} from \"antd/lib/config-provider/SizeContext\";\r\nimport {ConfigContext, Variant} from \"antd/es/config-provider\";\r\n\r\n/** Render function of {@link WithCss}; receives the result of `useStyles` (`styles`, `cx`, `theme`, ...). */\r\ntype WithCssChildren<T extends BaseReturnType> = (css: ReturnStyles<T>) => any;\r\n\r\n/** Props that {@link WithCss} resolves before passing them to `useStyles`. */\r\ntype WithCssOwnProps = { size?: SizeType, variant?: Variant };\r\n\r\n/**\r\n * Props always passed to `useStyles` by {@link WithCss}. `size` and `variant` are resolved from the passed props\r\n * and the antd context, so they are never `undefined`.\r\n */\r\nexport type WithCssInjectedProps = { size: NonNullable<SizeType>, variant: Variant };\r\n\r\n/** Props of {@link WithCss}. */\r\ninterface WithCssProperties<T extends BaseReturnType, P extends WithCssOwnProps> {\r\n /** Render function called with the computed styles. */\r\n children: WithCssChildren<T>;\r\n /** Style hook created by antd-style `createStyles`. */\r\n useStyles: (props?: P & WithCssInjectedProps) => ReturnStyles<T>\r\n /** Props passed to `useStyles`, merged with the resolved `size` and `variant`. */\r\n props?: P;\r\n}\r\n\r\n/**\r\n * Lets class components use an antd-style `createStyles` hook: calls `useStyles` and renders `children(css)`.\r\n * `size` is resolved as `props.size`, then the enclosing `Space.Compact` size, then `'middle'`; `variant` as\r\n * `props.variant`, then the `ConfigProvider` variant, then `'outlined'`.\r\n */\r\nexport default function WithCss<T extends BaseReturnType, P extends WithCssOwnProps = {}> ({useStyles, children, props}: WithCssProperties<T, P>) {\r\n const contextSize = useContext(SpaceCompactItemContext);\r\n const {variant: configVariant} = useContext(ConfigContext);\r\n const mergedSize: NonNullable<SizeType> = props?.size || contextSize?.compactSize || 'middle';\r\n // same precedence as antd's internal useVariant: own prop > ConfigProvider > outlined\r\n const mergedVariant: Variant = props?.variant ?? configVariant ?? 'outlined';\r\n const css = useStyles({...(props as P), size: mergedSize, variant: mergedVariant});\r\n return children(css);\r\n};\r\n"]}
1
+ {"version":3,"file":"withCss.js","sourceRoot":"","sources":["../../../../components/style/withCss.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,MAAM,OAAO,CAAC;AACjC,OAAO,EAAC,uBAAuB,EAAC,MAAM,uBAAuB,CAAC;AAC9D,OAAO,WAAuB,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAC,aAAa,EAAU,MAAM,yBAAyB,CAAC;AA4B/D;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAA4D,EAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,EAA0B;;IAC5I,MAAM,WAAW,GAAG,UAAU,CAAC,uBAAuB,CAAC,CAAC;IACxD,MAAM,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IAC3C,MAAM,EAAC,OAAO,EAAE,aAAa,EAAC,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAC3D,iGAAiG;IACjG,MAAM,UAAU,GAA0B,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,CAAA,IAAI,UAAU,IAAI,QAAQ,CAAC;IAC5G,sFAAsF;IACtF,MAAM,aAAa,GAAY,MAAA,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,mCAAI,aAAa,mCAAI,UAAU,CAAC;IAC7E,MAAM,GAAG,GAAG,SAAS,iCAAM,KAAW,KAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,IAAE,CAAC;IACnF,OAAO,QAAQ,CAAC,GAAG,EAAE,EAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAC,CAAC,CAAC;AACrE,CAAC;AAAA,CAAC","sourcesContent":["import {BaseReturnType} from 'antd-style';\r\nimport {ReturnStyles} from \"antd-style/lib/factories/createStyles/types\";\r\nimport {useContext} from \"react\";\r\nimport {SpaceCompactItemContext} from \"antd/es/space/Compact\";\r\nimport SizeContext, {SizeType} from \"antd/es/config-provider/SizeContext\";\r\nimport {ConfigContext, Variant} from \"antd/es/config-provider\";\r\n\r\n/**\r\n * Render function of {@link WithCss}; receives the result of `useStyles` (`styles`, `cx`, `theme`, ...) and the\r\n * resolved `size` and `variant` - read them from here, not from the component's own props, which may leave them to\r\n * the antd context.\r\n */\r\ntype WithCssChildren<T extends BaseReturnType> = (css: ReturnStyles<T>, resolved: WithCssInjectedProps) => any;\r\n\r\n/** Props that {@link WithCss} resolves before passing them to `useStyles`. */\r\ntype WithCssOwnProps = { size?: SizeType, variant?: Variant };\r\n\r\n/**\r\n * Props always passed to `useStyles` by {@link WithCss}. `size` and `variant` are resolved from the passed props\r\n * and the antd context, so they are never `undefined`.\r\n */\r\nexport type WithCssInjectedProps = { size: NonNullable<SizeType>, variant: Variant };\r\n\r\n/** Props of {@link WithCss}. */\r\ninterface WithCssProperties<T extends BaseReturnType, P extends WithCssOwnProps> {\r\n /** Render function called with the computed styles. */\r\n children: WithCssChildren<T>;\r\n /** Style hook created by antd-style `createStyles`. */\r\n useStyles: (props?: P & WithCssInjectedProps) => ReturnStyles<T>\r\n /** Props passed to `useStyles`, merged with the resolved `size` and `variant`. */\r\n props?: P;\r\n}\r\n\r\n/**\r\n * Lets class components use an antd-style `createStyles` hook: calls `useStyles` and renders `children(css)`.\r\n * `size` is resolved as `props.size`, then the enclosing `Space.Compact` size, then the `ConfigProvider`\r\n * `componentSize`, then `'middle'`; `variant` as\r\n * `props.variant`, then the `ConfigProvider` variant, then `'outlined'`.\r\n */\r\nexport default function WithCss<T extends BaseReturnType, P extends WithCssOwnProps = {}> ({useStyles, children, props}: WithCssProperties<T, P>) {\r\n const contextSize = useContext(SpaceCompactItemContext);\r\n const configSize = useContext(SizeContext);\r\n const {variant: configVariant} = useContext(ConfigContext);\r\n // same precedence as antd's internal useSize: own prop > Space.Compact > ConfigProvider > middle\r\n const mergedSize: NonNullable<SizeType> = props?.size || contextSize?.compactSize || configSize || 'middle';\r\n // same precedence as antd's internal useVariant: own prop > ConfigProvider > outlined\r\n const mergedVariant: Variant = props?.variant ?? configVariant ?? 'outlined';\r\n const css = useStyles({...(props as P), size: mergedSize, variant: mergedVariant});\r\n return children(css, {size: mergedSize, variant: mergedVariant});\r\n};\r\n"]}
@@ -59,6 +59,8 @@
59
59
  "Set No Color": "Nastavit žádnou barvu",
60
60
  "Show time with milliseconds": "Zobrazit čas s milisekundami",
61
61
  "Show time with time zone": "Zobrazit čas s časovou zónou",
62
+ "Only at the change to winter time": "Jen při přechodu na zimní čas",
63
+ "A2:00 / B2:00 at the change to winter time": "A2:00 / B2:00 při přechodu na zimní čas",
62
64
  "Show time with year": "Zobrazit čas s rokem",
63
65
  "Show/Hide filter panel": "Zobrazit/skrýt panel s filtrem",
64
66
  "Show/Hide panel with modified filter": "Zobrazit/skrýt panel s modifikovaným filtrem",
@@ -59,6 +59,8 @@
59
59
  "Set No Color": "Nastaviť žiadnu farbu",
60
60
  "Show time with milliseconds": "Zobraziť čas s milisekundami",
61
61
  "Show time with time zone": "Zobraziť čas s časovou zónou",
62
+ "Only at the change to winter time": "Len pri prechode na zimný čas",
63
+ "A2:00 / B2:00 at the change to winter time": "A2:00 / B2:00 pri prechode na zimný čas",
62
64
  "Show time with year": "Zobraziť čas s rokom",
63
65
  "Show/Hide filter panel": "Zobraziť/skryť panel s filtrom",
64
66
  "Show/Hide panel with modified filter": "Zobraziť/skryť panel s modifikovaným filtrom",
@@ -59,6 +59,8 @@
59
59
  "Set No Color": "Не встановлюйте колір",
60
60
  "Show time with milliseconds": "Показувати час у мілісекундах",
61
61
  "Show time with time zone": "Показувати час із часовим поясом",
62
+ "Only at the change to winter time": "Лише під час переходу на зимовий час",
63
+ "A2:00 / B2:00 at the change to winter time": "A2:00 / B2:00 під час переходу на зимовий час",
62
64
  "Show time with year": "Покажіть час роком",
63
65
  "Show/Hide filter panel": "Показати/сховати панель фільтрів",
64
66
  "Show/Hide panel with modified filter": "Показати/сховати панель із зміненим фільтром",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "d2coreui",
3
- "version": "23.0.55",
3
+ "version": "23.0.57",
4
4
  "description": "Core UI components and utilities library.",
5
5
  "author": "Ipesoft s.r.o.",
6
6
  "license": "MIT",