d2coreui 21.0.31 → 21.0.33

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 (35) hide show
  1. package/components/color/colorPicker.js +1 -1
  2. package/components/color/colorPicker.js.map +1 -1
  3. package/components/date/dateRangeInputConfirm.js +1 -1
  4. package/components/date/dateRangeInputConfirm.js.map +1 -1
  5. package/components/date/dateTimeInput.js +1 -1
  6. package/components/date/dateTimeInput.js.map +1 -1
  7. package/components/grid/cell/simpleStatusTextCellEditor.js +2 -1
  8. package/components/grid/cell/simpleStatusTextCellEditor.js.map +1 -1
  9. package/components/grid/cell/statusTextCellEditor.js +3 -2
  10. package/components/grid/cell/statusTextCellEditor.js.map +1 -1
  11. package/components/grid/cell/textCellEditor.js +4 -4
  12. package/components/grid/cell/textCellEditor.js.map +1 -1
  13. package/components/grid/config/dataGridEditor.js +1 -1
  14. package/components/grid/config/dataGridEditor.js.map +1 -1
  15. package/components/grid/dataGrid.js +1 -1
  16. package/components/grid/dataGrid.js.map +1 -1
  17. package/components/grid/export/contextMenu.js.map +1 -1
  18. package/components/grid/panel/tablePagination.js +1 -1
  19. package/components/grid/panel/tablePagination.js.map +1 -1
  20. package/components/input/autoCompleteInput.d.ts +3 -2
  21. package/components/input/autoCompleteInput.js +3 -3
  22. package/components/input/autoCompleteInput.js.map +1 -1
  23. package/components/input/hexaFormattedInput.d.ts +1 -1
  24. package/components/input/hexaFormattedInput.js.map +1 -1
  25. package/components/input/maskedInput.d.ts +20 -13
  26. package/components/input/maskedInput.js +9 -4
  27. package/components/input/maskedInput.js.map +1 -1
  28. package/components/modal/impl/draggableModalInner.d.ts +1 -1
  29. package/components/modal/impl/draggableModalInner.js +6 -6
  30. package/components/modal/impl/draggableModalInner.js.map +1 -1
  31. package/components/picker/enumValuePicker.js +1 -1
  32. package/components/picker/enumValuePicker.js.map +1 -1
  33. package/components/scrollTo/scrollTo.js +1 -1
  34. package/components/scrollTo/scrollTo.js.map +1 -1
  35. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"contextMenu.js","sourceRoot":"","sources":["../../../../../components/grid/export/contextMenu.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAC,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAChG,OAAO,EAAC,IAAI,EAAE,MAAM,EAAC,MAAM,MAAM,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAC,MAAM,SAAS,CAAA;AAC7C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAC,cAAc,EAAC,MAAM,8CAA8C,CAAC;AAE5E,OAAO,YAAY,MAAM,+FAA+F,CAAA;AAExH,OAAO,YAAY,MAAM,+FAA+F,CAAA;AAExH,OAAO,kBAAkB,MAAM,2GAA2G,CAAA;AAE1I,OAAO,YAAY,MAAM,+FAA+F,CAAA;AACxH,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AA0BpE,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,KAAK,CAAC,SAA6C;IACxF,YAAY,KAAiC;QACzC,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG;YACT,eAAe,EAAE,UAAU;YAC3B,SAAS,EAAE,KAAK;SACnB,CAAC;IACN,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,OAAe;QACnC,IAAI,CAAC,QAAQ,CAAC,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;QACjC,QAAQ,OAAO,EAAE;YACb,KAAK,WAAW,CAAC,CAAC;gBACd,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,MAAM,CAAC,C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BAAmB,CAAC,CACpG;SACf,CAAC;IACN,CAAC;CACJ","sourcesContent":["import {CopyOutlined, FileOutlined, FilePdfOutlined, FileTextOutlined} from \"@ant-design/icons\";\nimport {Menu, Switch} from \"antd\";\nimport React from \"react\";\nimport i18n from \"d2core/i18n/i18n\";\nimport {spawn, Thread, Worker} from \"threads\"\nimport moment from \"moment\";\nimport ProgressPopup from \"./progressPopup\";\nimport {MenuElement} from \"../dataGrid\";\nimport {ClipboardUtils} from \"d2coreui/components/clipboard/clipboardUtils\";\n// @ts-ignore\nimport txtExportUrl from 'threads-plugin/dist/loader?name=txtExport!d2coreui/components/grid/export/worker/txtExport.ts'\n// @ts-ignore\nimport csvExportUrl from \"threads-plugin/dist/loader?name=csvExport!d2coreui/components/grid/export/worker/csvExport.ts\"\n// @ts-ignore\nimport clipboardExportUrl from \"threads-plugin/dist/loader?name=clipboardExport!d2coreui/components/grid/export/worker/clipboardExport.ts\"\n// @ts-ignore\nimport pdfExportUrl from \"threads-plugin/dist/loader?name=pdfExport!d2coreui/components/grid/export/worker/pdfExport.ts\"\nimport PlatformSpecific from \"d2coreui/components/platformSpecific\";\n\n\nexport interface ContextMenuProps {\n onlySelectedNodes?: boolean\n showMilliseconds: boolean\n showYear: boolean\n hideNotificationOnClipboardCopy?: boolean\n\n getExportContent: (progressPopup: ProgressPopup | null, props: ContextMenuProps) => Promise<string[][]>\n\n // overrides context menu rendering\n renderer?(menuElements: MenuElement[]): MenuElement[]\n\n // handler for custom context menu items click\n onClick?(key: string): void\n}\n\ntype PageOrientation = \"PORTRAIT\" | \"LANDSCAPE\";\n\ninterface ContextMenuState {\n pageOrientation: PageOrientation\n exporting: boolean\n}\n\n\nexport default class ContextMenu extends React.Component<ContextMenuProps, ContextMenuState> {\n constructor(props: Readonly<ContextMenuProps>) {\n super(props);\n this.state = {\n pageOrientation: \"PORTRAIT\",\n exporting: false\n };\n }\n\n async onExportMenuClick(menuKey: string) {\n this.setState({exporting: true});\n switch (menuKey) {\n case \"txtExport\": {\n const progressPopup = new ProgressPopup(i18n(\"Export List to\") + \" TXT\");\n const tableContent = await this.props.getExportContent(progressPopup, this.props);\n const txtExport = await spawn(new Worker(txtExportUrl));\n const textContent = await txtExport(tableContent);\n await Thread.terminate(txtExport);\n await progressPopup.update(100);\n PlatformSpecific.INSTANCE.saveContent(`export_${moment().format(\"YYYYMMDD_HHmm\")}.txt`, textContent, true);\n break;\n }\n case \"csvExport\": {\n const progressPopup = new ProgressPopup(i18n(\"Export List to\") + \" CSV\");\n const tableContent = await this.props.getExportContent(progressPopup, this.props);\n const csvExport = await spawn(new Worker(csvExportUrl));\n const csvContent = await csvExport(tableContent);\n await Thread.terminate(csvExport);\n await progressPopup.update(100);\n PlatformSpecific.INSTANCE.saveContent(`export_${moment().format(\"YYYYMMDD_HHmm\")}.csv`, `\\ufeff${csvContent}`, true);\n break;\n }\n case \"clipboardCopy\": {\n const progressPopup = !this.props.hideNotificationOnClipboardCopy ? new ProgressPopup(i18n(\"Export List to\") + \" \" + i18n(\"Clipboard\")) : null;\n const tableContent = await this.props.getExportContent(progressPopup, this.props);\n const clipboardExport = await spawn(new Worker(clipboardExportUrl));\n const clipboardContent = await clipboardExport(tableContent);\n const success = ClipboardUtils.copyToClipboard(clipboardContent);\n if (success) {\n await Thread.terminate(clipboardExport);\n await progressPopup?.update(100);\n } else {\n progressPopup?.error();\n }\n break;\n }\n case \"pdfExport\": {\n const progressPopup = new ProgressPopup(i18n(\"Export List to\") + \" PDF\");\n const tableContent = await this.props.getExportContent(progressPopup, this.props);\n const pdfExport = await spawn(new Worker(pdfExportUrl));\n pdfExport.handler().subscribe(async (data: string) => {\n Thread.terminate(pdfExport);\n await progressPopup.update(100);\n PlatformSpecific.INSTANCE.saveContent(`export_${moment().format(\"YYYYMMDD_HHmm\")}.pdf`, data, false);\n });\n pdfExport.export(tableContent, {pageOrientation: this.state.pageOrientation});\n }\n }\n this.setState({exporting: false});\n }\n\n render() {\n const {onlySelectedNodes, showMilliseconds, showYear, hideNotificationOnClipboardCopy, getExportContent, renderer, ...rest} = this.props;\n let menuItems: MenuElement[] = this.renderExportMenuItems();\n if (renderer) {\n menuItems = renderer(menuItems);\n }\n return (\n <Menu {...rest}\n onClick={(item: any) => {\n this.onExportMenuClick(item.key);\n if (this.props.onClick) {\n this.props.onClick(item.key.toString());\n }\n }}>\n {menuItems}\n </Menu>);\n }\n\n renderExportMenuItems() {\n return [\n <Menu.Item icon={<FileOutlined/>} key=\"txtExport\" disabled={this.state.exporting}>{i18n(\"Export List to\") + \" TXT\"}\n </Menu.Item>,\n <Menu.Item icon={<FileTextOutlined/>} key=\"csvExport\"\n disabled={this.state.exporting}>{i18n(\"Export List to\") + \" CSV\"}\n </Menu.Item>,\n <Menu.Item icon={<FilePdfOutlined/>} key=\"pdfExport\"\n disabled={this.state.exporting}>{i18n(\"Export List to\") + \" PDF\"}\n <Switch\n style={{marginLeft: 8}}\n checkedChildren={i18n(\"Landscape\") + \" \"}\n unCheckedChildren={\"\" + i18n(\"Portrait\")}\n checked={this.state.pageOrientation !== \"PORTRAIT\"}\n onChange={(checked, e: MouseEvent) => {\n e.stopPropagation();\n (e as any).nativeEvent.stopImmediatePropagation();\n this.setState({pageOrientation: checked ? \"LANDSCAPE\" : \"PORTRAIT\"});\n }}\n /></Menu.Item>,\n <Menu.Divider key=\"divider1\"/>,\n <Menu.Item key=\"clipboardCopy\" icon={<CopyOutlined/>} disabled={this.state.exporting}>{i18n(\"Copy to Clipboard\")}\n </Menu.Item>\n ];\n }\n}"]}
1
+ {"version":3,"file":"contextMenu.js","sourceRoot":"","sources":["../../../../../components/grid/export/contextMenu.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAC,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAChG,OAAO,EAAC,IAAI,EAAE,MAAM,EAAC,MAAM,MAAM,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,O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C,IAAI,EAAE,oBAAC,eAAe,OAAE,EAAE,GAAG,EAAC,WAAW,EACzC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS;gBAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,MAAM;gBACvE,oBAAC,MAAM,IACH,KAAK,EAAE,EAAC,UAAU,EAAE,CAAC,EAAC,EACtB,eAAe,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,GAAG,EACxC,iBAAiB,EAAE,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,EACxC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,eAAe,KAAK,UAAU,EAClD,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;wBACrB,CAAC,CAAC,eAAe,EAAE,CAAC;wBACnB,CAAS,CAAC,WAAW,CAAC,wBAAwB,EAAE,CAAC;wBAClD,IAAI,CAAC,QAAQ,CAAC,EAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,EAAC,CAAC,CAAC;oBACzE,CAAC,GACH,CAAY;YAClB,oBAAC,IAAI,CAAC,OAAO,IAAC,GAAG,EAAC,UAAU,GAAE;YAC9B,oBAAC,IAAI,CAAC,IAAI,IAAC,GAAG,EAAC,eAAe,EAAC,IAAI,EAAE,oBAAC,YAAY,OAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,IAAG,IAAI,CAAC,mBAAmB,CAAC,CACpG;SACf,CAAC;IACN,CAAC;CACJ","sourcesContent":["import {CopyOutlined, FileOutlined, FilePdfOutlined, FileTextOutlined} from \"@ant-design/icons\";\nimport {Menu, Switch} from \"antd\";\nimport React from \"react\";\nimport i18n from \"d2core/i18n/i18n\";\nimport {spawn, Thread, Worker} from \"threads\"\nimport moment from \"moment\";\nimport ProgressPopup from \"./progressPopup\";\nimport {MenuElement} from \"../dataGrid\";\nimport {ClipboardUtils} from \"d2coreui/components/clipboard/clipboardUtils\";\n// @ts-ignore\nimport txtExportUrl from 'threads-plugin/dist/loader?name=txtExport!d2coreui/components/grid/export/worker/txtExport.ts'\n// @ts-ignore\nimport csvExportUrl from \"threads-plugin/dist/loader?name=csvExport!d2coreui/components/grid/export/worker/csvExport.ts\"\n// @ts-ignore\nimport clipboardExportUrl from \"threads-plugin/dist/loader?name=clipboardExport!d2coreui/components/grid/export/worker/clipboardExport.ts\"\n// @ts-ignore\nimport pdfExportUrl from \"threads-plugin/dist/loader?name=pdfExport!d2coreui/components/grid/export/worker/pdfExport.ts\"\nimport PlatformSpecific from \"d2coreui/components/platformSpecific\";\n\n\nexport interface ContextMenuProps {\n onlySelectedNodes?: boolean\n showMilliseconds: boolean\n showYear: boolean\n hideNotificationOnClipboardCopy?: boolean\n\n getExportContent: (progressPopup: ProgressPopup | null, props: ContextMenuProps) => Promise<string[][]>\n\n // overrides context menu rendering\n renderer?(menuElements: MenuElement[]): MenuElement[]\n\n // handler for custom context menu items click\n onClick?(key: string): void\n}\n\ntype PageOrientation = \"PORTRAIT\" | \"LANDSCAPE\";\n\ninterface ContextMenuState {\n pageOrientation: PageOrientation\n exporting: boolean\n}\n\n\nexport default class ContextMenu extends React.Component<ContextMenuProps, ContextMenuState> {\n constructor(props: Readonly<ContextMenuProps>) {\n super(props);\n this.state = {\n pageOrientation: \"PORTRAIT\",\n exporting: false\n };\n }\n\n async onExportMenuClick(menuKey: string) {\n this.setState({exporting: true});\n switch (menuKey) {\n case \"txtExport\": {\n const progressPopup = new ProgressPopup(i18n(\"Export List to\") + \" TXT\");\n const tableContent = await this.props.getExportContent(progressPopup, this.props);\n const txtExport = await spawn(new Worker(txtExportUrl));\n const textContent = await txtExport(tableContent);\n await Thread.terminate(txtExport);\n await progressPopup.update(100);\n PlatformSpecific.INSTANCE.saveContent(`export_${moment().format(\"YYYYMMDD_HHmm\")}.txt`, textContent, true);\n break;\n }\n case \"csvExport\": {\n const progressPopup = new ProgressPopup(i18n(\"Export List to\") + \" CSV\");\n const tableContent = await this.props.getExportContent(progressPopup, this.props);\n const csvExport = await spawn(new Worker(csvExportUrl));\n const csvContent = await csvExport(tableContent);\n await Thread.terminate(csvExport);\n await progressPopup.update(100);\n PlatformSpecific.INSTANCE.saveContent(`export_${moment().format(\"YYYYMMDD_HHmm\")}.csv`, `\\ufeff${csvContent}`, true);\n break;\n }\n case \"clipboardCopy\": {\n const progressPopup = !this.props.hideNotificationOnClipboardCopy ? new ProgressPopup(i18n(\"Export List to\") + \" \" + i18n(\"Clipboard\")) : null;\n const tableContent = await this.props.getExportContent(progressPopup, this.props);\n const clipboardExport = await spawn(new Worker(clipboardExportUrl));\n const clipboardContent = await clipboardExport(tableContent);\n const success = ClipboardUtils.copyToClipboard(clipboardContent);\n if (success) {\n await Thread.terminate(clipboardExport);\n await progressPopup?.update(100);\n } else {\n progressPopup?.error();\n }\n break;\n }\n case \"pdfExport\": {\n const progressPopup = new ProgressPopup(i18n(\"Export List to\") + \" PDF\");\n const tableContent = await this.props.getExportContent(progressPopup, this.props);\n const pdfExport = await spawn(new Worker(pdfExportUrl));\n pdfExport.handler().subscribe(async (data: string) => {\n Thread.terminate(pdfExport);\n await progressPopup.update(100);\n PlatformSpecific.INSTANCE.saveContent(`export_${moment().format(\"YYYYMMDD_HHmm\")}.pdf`, data, false);\n });\n pdfExport.export(tableContent, {pageOrientation: this.state.pageOrientation});\n }\n }\n this.setState({exporting: false});\n }\n\n render() {\n const {onlySelectedNodes, showMilliseconds, showYear, hideNotificationOnClipboardCopy, getExportContent, renderer, ...rest} = this.props;\n let menuItems: MenuElement[] = this.renderExportMenuItems();\n if (renderer) {\n menuItems = renderer(menuItems);\n }\n return (\n <Menu {...rest}\n onClick={(item: any) => {\n this.onExportMenuClick(item.key);\n if (this.props.onClick) {\n this.props.onClick(item.key.toString());\n }\n }}>\n {menuItems}\n </Menu>);\n }\n\n renderExportMenuItems() {\n return [\n <Menu.Item icon={<FileOutlined/>} key=\"txtExport\" disabled={this.state.exporting}>{i18n(\"Export List to\") + \" TXT\"}\n </Menu.Item>,\n <Menu.Item icon={<FileTextOutlined/>} key=\"csvExport\"\n disabled={this.state.exporting}>{i18n(\"Export List to\") + \" CSV\"}\n </Menu.Item>,\n <Menu.Item icon={<FilePdfOutlined/>} key=\"pdfExport\"\n disabled={this.state.exporting}>{i18n(\"Export List to\") + \" PDF\"}\n <Switch\n style={{marginLeft: 8}}\n checkedChildren={i18n(\"Landscape\") + \" \"}\n unCheckedChildren={\"\" + i18n(\"Portrait\")}\n checked={this.state.pageOrientation !== \"PORTRAIT\"}\n onChange={(checked, e) => {\n e.stopPropagation();\n (e as any).nativeEvent.stopImmediatePropagation();\n this.setState({pageOrientation: checked ? \"LANDSCAPE\" : \"PORTRAIT\"});\n }}\n /></Menu.Item>,\n <Menu.Divider key=\"divider1\"/>,\n <Menu.Item key=\"clipboardCopy\" icon={<CopyOutlined/>} disabled={this.state.exporting}>{i18n(\"Copy to Clipboard\")}\n </Menu.Item>\n ];\n }\n}"]}
@@ -31,7 +31,7 @@ export default class PaginationComponent extends React.Component {
31
31
  this.props.onChange(this.state.gotoPageNumber, this.props.pageSize);
32
32
  }
33
33
  } },
34
- React.createElement(CheckOutlined, null))), trigger: "hover", onVisibleChange: (visible) => {
34
+ React.createElement(CheckOutlined, null))), trigger: "hover", onOpenChange: (visible) => {
35
35
  if (!visible) {
36
36
  this.setState({ gotoPageNumber: null });
37
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tablePagination.js","sourceRoot":"","sources":["../../../../../components/grid/panel/tablePagination.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAC,MAAM,MAAM,CAAC;AACrE,OAAO,IAAI,MAAM,kBAAkB,CAAC;AAOpC,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ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AO,KAAK,CAAC,IAAkB,CAAC,CAAC,OAAO,KAAK,EAAE,EAAY;4CAC7D,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;gDAClD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;6CACvE;yCACJ;oCACL,CAAC,GACZ;gCACF,oBAAC,MAAM,IAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,EAAE,IAAI,EAAC,SAAS,EAAC,OAAO,EAAE,GAAG,EAAE;wCAC3D,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;4CAClD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;yCACvE;oCACL,CAAC;oCACG,oBAAC,aAAa,OAAE,CACX,CACC,EAElB,OAAO,EAAC,OAAO,EACf,eAAe,EAAE,CAAC,OAAO,EAAE,EAAE;gCACzB,IAAI,CAAC,OAAO,EAAE;oCACV,IAAI,CAAC,QAAQ,CAAC,EAAC,cAAc,EAAE,IAAI,EAAC,CAAC,CAAC;iCACzC;4BACL,CAAC,EACD,gBAAgB,EAAC,uBAAuB,IAEvC,eAAe,CACV,CACb,CAAC;qBACL;yBAAM;wBACH,OAAO,eAAe,CAAC;qBAC1B;gBACL,CAAC,IACH,CACA,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from \"react\";\nimport {CheckOutlined} from \"@ant-design/icons\";\nimport {Button, Input, InputNumber, Pagination, Popover} from \"antd\";\nimport i18n from \"d2core/i18n/i18n\";\nimport {PaginationProps} from \"antd/es/pagination\";\n\ninterface PaginationComponentState {\n gotoPageNumber?: number | null\n}\n\nexport default class PaginationComponent extends React.Component<PaginationProps, PaginationComponentState> {\n constructor(props: Readonly<PaginationProps>) {\n super(props);\n this.state = {\n gotoPageNumber: null\n }\n }\n\n render() {\n const pageCount = this.props.total && this.props.pageSize ? Math.ceil(this.props.total / this.props.pageSize) : 1;\n return (\n <div>\n <Pagination\n showSizeChanger={false}\n {...this.props}\n itemRender={(page, type, originalElement) => {\n if (page === this.props.current && type === \"page\") {\n return (\n <Popover\n title=\"\"\n placement=\"bottom\"\n content={\n <Input.Group compact>\n <InputNumber min={1} max={pageCount}\n value={this.state.gotoPageNumber ? this.state.gotoPageNumber : this.props.current}\n onChange={(newValue) => {\n if (typeof newValue === \"number\") {\n this.setState({gotoPageNumber: newValue});\n }\n }}\n onKeyDown={(e) => {\n if (e.keyCode === 3 /*MAC_ENTER*/ || e.keyCode === 13 /*ENTER*/) {\n if (this.state.gotoPageNumber && this.props.onChange) {\n this.props.onChange(this.state.gotoPageNumber, this.props.pageSize);\n }\n }\n }}\n />\n <Button title={i18n(\"Goto Page\")} type=\"primary\" onClick={() => {\n if (this.state.gotoPageNumber && this.props.onChange) {\n this.props.onChange(this.state.gotoPageNumber, this.props.pageSize);\n }\n }}>\n <CheckOutlined/>\n </Button>\n </Input.Group>\n }\n trigger=\"hover\"\n onVisibleChange={(visible) => {\n if (!visible) {\n this.setState({gotoPageNumber: null});\n }\n }}\n overlayClassName=\"control-panel-popover\"\n >\n {originalElement}\n </Popover>\n );\n } else {\n return originalElement;\n }\n }}\n />\n </div>\n );\n }\n}"]}
1
+ {"version":3,"file":"tablePagination.js","sourceRoot":"","sources":["../../../../../components/grid/panel/tablePagination.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAC,MAAM,MAAM,CAAC;AACrE,OAAO,IAAI,MAAM,kBAAk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AE,CAAC,CAAC,EAAE,EAAE;wCACb,IAAI,CAAC,CAAC,OAAO,KAAK,CAAC,IAAkB,CAAC,CAAC,OAAO,KAAK,EAAE,EAAY;4CAC7D,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;gDAClD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,QAAS,CAAC,CAAC;6CACxE;yCACJ;oCACL,CAAC,GACZ;gCACF,oBAAC,MAAM,IAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,EAAE,IAAI,EAAC,SAAS,EAAC,OAAO,EAAE,GAAG,EAAE;wCAC3D,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;4CAClD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,QAAS,CAAC,CAAC;yCACxE;oCACL,CAAC;oCACG,oBAAC,aAAa,OAAE,CACX,CACC,EAElB,OAAO,EAAC,OAAO,EACf,YAAY,EAAE,CAAC,OAAO,EAAE,EAAE;gCACtB,IAAI,CAAC,OAAO,EAAE;oCACV,IAAI,CAAC,QAAQ,CAAC,EAAC,cAAc,EAAE,IAAI,EAAC,CAAC,CAAC;iCACzC;4BACL,CAAC,EACD,gBAAgB,EAAC,uBAAuB,IAEvC,eAAe,CACV,CACb,CAAC;qBACL;yBAAM;wBACH,OAAO,eAAe,CAAC;qBAC1B;gBACL,CAAC,IACH,CACA,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from \"react\";\nimport {CheckOutlined} from \"@ant-design/icons\";\nimport {Button, Input, InputNumber, Pagination, Popover} from \"antd\";\nimport i18n from \"d2core/i18n/i18n\";\nimport {PaginationProps} from \"antd/es/pagination\";\n\ninterface PaginationComponentState {\n gotoPageNumber?: number | null\n}\n\nexport default class PaginationComponent extends React.Component<PaginationProps, PaginationComponentState> {\n constructor(props: Readonly<PaginationProps>) {\n super(props);\n this.state = {\n gotoPageNumber: null\n }\n }\n\n render() {\n const pageCount = this.props.total && this.props.pageSize ? Math.ceil(this.props.total / this.props.pageSize) : 1;\n return (\n <div>\n <Pagination\n showSizeChanger={false}\n {...this.props}\n itemRender={(page, type, originalElement) => {\n if (page === this.props.current && type === \"page\") {\n return (\n <Popover\n title=\"\"\n placement=\"bottom\"\n content={\n <Input.Group compact>\n <InputNumber min={1} max={pageCount}\n value={this.state.gotoPageNumber ? this.state.gotoPageNumber : this.props.current}\n onChange={(newValue) => {\n if (typeof newValue === \"number\") {\n this.setState({gotoPageNumber: newValue});\n }\n }}\n onKeyDown={(e) => {\n if (e.keyCode === 3 /*MAC_ENTER*/ || e.keyCode === 13 /*ENTER*/) {\n if (this.state.gotoPageNumber && this.props.onChange) {\n this.props.onChange(this.state.gotoPageNumber, this.props.pageSize!);\n }\n }\n }}\n />\n <Button title={i18n(\"Goto Page\")} type=\"primary\" onClick={() => {\n if (this.state.gotoPageNumber && this.props.onChange) {\n this.props.onChange(this.state.gotoPageNumber, this.props.pageSize!);\n }\n }}>\n <CheckOutlined/>\n </Button>\n </Input.Group>\n }\n trigger=\"hover\"\n onOpenChange={(visible) => {\n if (!visible) {\n this.setState({gotoPageNumber: null});\n }\n }}\n overlayClassName=\"control-panel-popover\"\n >\n {originalElement}\n </Popover>\n );\n } else {\n return originalElement;\n }\n }}\n />\n </div>\n );\n }\n}"]}
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
- import { AutoCompleteProps, DataSourceItemObject } from "antd/es/auto-complete";
2
+ import { AutoCompleteProps } from "antd/es/auto-complete";
3
+ import { DefaultOptionType } from "antd/es/select";
3
4
  interface InputSearchWithHistoryProps extends Omit<AutoCompleteProps, "onChange" | "onSearch" | "placeholder" | "options"> {
4
5
  value?: string;
5
6
  options?: string[];
@@ -26,7 +27,7 @@ export default class AutoCompleteInput extends React.Component<InputSearchWithHi
26
27
  focus(): void;
27
28
  static getDerivedStateFromProps(props: InputSearchWithHistoryProps, state: InputSearchWithHistoryState): Partial<InputSearchWithHistoryState>;
28
29
  setSearchString(searchString: string): void;
29
- getAutocompleteOptions(): DataSourceItemObject[];
30
+ getAutocompleteOptions(): DefaultOptionType[];
30
31
  onSearch(): void;
31
32
  onSelect(searchString: string): void;
32
33
  render(): JSX.Element;
@@ -71,10 +71,10 @@ export default class AutoCompleteInput extends React.Component {
71
71
  autocompleteData.push(...this.props.options);
72
72
  }
73
73
  return autocompleteData.filter((e) => !!e).map((e) => {
74
- return {
74
+ return ({
75
75
  value: "" + (this.props.stringFormatter ? this.props.stringFormatter(e) : e),
76
- text: "" + (this.props.stringFormatter ? this.props.stringFormatter(e) : e)
77
- };
76
+ label: "" + (this.props.stringFormatter ? this.props.stringFormatter(e) : e)
77
+ });
78
78
  });
79
79
  }
80
80
  onSearch() {
@@ -1 +1 @@
1
- {"version":3,"file":"autoCompleteInput.js","sourceRoot":"","sources":["../../../../components/input/autoCompleteInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,YAAY,EAAE,KAAK,EAAC,MAAM,MAAM,CAAC;AAEzC,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AA6B/C,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,KAAK,CAAC,SAAmE;IAYpH,YAAY,KAA4C;QACpD,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG;YACT,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,KAAK;SACjB,CAAC;QAEF,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QACtC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;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;gBACL,CAAC,EACD,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EACzB,MAAM,EACF,oBAAoB,IAAI,8BAAM,SAAS,EAAC,gBAAgB;oBACpD,oBAAC,YAAY,IACT,SAAS,EAAC,0CAA0C,EACpD,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,CAAC,CAAC,EAC1B,OAAO,EAAE,GAAG,EAAE;4BACV,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;gCAC3E,IAAI,CAAC,QAAQ,CAAC,EAAC,MAAM,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAC,CAAC,CAAC;6BAC/C;wBACL,CAAC,GAAG,CACD,EAEf,QAAQ,EAAE,aAAa,EACvB,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAC1C,QAAQ,EAAE,CAAC,QAAQ,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAC5D,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,GAAG,CACtD,CAClB,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from \"react\"\nimport {AutoComplete, Input} from \"antd\";\nimport {AutoCompleteProps, DataSourceItemObject} from \"antd/es/auto-complete\";\nimport {DownOutlined} from \"@ant-design/icons\";\nimport {RefSelectProps} from \"antd/es/select\";\n\ninterface InputSearchWithHistoryProps extends Omit<AutoCompleteProps, \"onChange\" | \"onSearch\" | \"placeholder\" | \"options\"> {\n value?: string\n\n options?: string[]\n\n placeholder?: string\n\n prefix?: React.ReactNode\n\n onChange(searchString: string): void\n\n onSearch(): void\n\n onPressEnter?(): void\n\n inputReadonly?: boolean\n\n stringFormatter?(rawString: string): string\n}\n\ninterface InputSearchWithHistoryState {\n opened: boolean\n loading: boolean\n searchString?: string\n}\n\nexport default class AutoCompleteInput extends React.Component<InputSearchWithHistoryProps, InputSearchWithHistoryState> {\n static get defaultProps() {\n return {\n onSearch: () => {\n },\n onChange: () => {\n }\n };\n }\n\n private autocomplete: React.RefObject<RefSelectProps>;\n\n constructor(props: Readonly<InputSearchWithHistoryProps>) {\n super(props);\n this.state = {\n opened: false,\n loading: false,\n };\n\n this.autocomplete = React.createRef();\n this.focus = this.focus.bind(this);\n }\n\n focus() {\n this.autocomplete.current?.focus();\n }\n\n /**\n * Handling setting search string from parent component\n */\n static getDerivedStateFromProps(props: InputSearchWithHistoryProps, state: InputSearchWithHistoryState): Partial<InputSearchWithHistoryState> {\n const newState: Partial<InputSearchWithHistoryState> = {};\n if (props.value !== state.searchString) {\n newState.searchString = props.value;\n }\n return newState;\n }\n\n setSearchString(searchString: string) {\n if(this.props.stringFormatter) {\n if (searchString.indexOf(\"ðð\") < 0 && this.props.options && this.props.options.length > 0) {\n for (let i = 0; i < this.props.options.length; i++) {\n if (searchString === this.props.stringFormatter(this.props.options[i])) {\n searchString = this.props.options[i];\n break;\n }\n }\n }\n if (this.state.searchString !== searchString) {\n this.setState({opened: false, searchString: searchString}, () => {\n this.props.onChange(searchString);\n });\n } else {\n this.setState({opened: false});\n }\n } else {\n this.setState({opened: false, searchString: searchString});\n this.props.onChange(searchString);\n }\n }\n\n getAutocompleteOptions(): DataSourceItemObject[] {\n const autocompleteData = [];\n if (this.props.options && this.props.options.length > 0) {\n autocompleteData.push(...this.props.options);\n }\n return autocompleteData.filter((e) => !!e).map((e) => {\n return ({\n value: \"\" + (this.props.stringFormatter ? this.props.stringFormatter(e) : e),\n text: \"\" + (this.props.stringFormatter ? this.props.stringFormatter(e) : e)\n } as DataSourceItemObject);\n });\n }\n\n /**\n * Handling search confirmation by pressing enter\n */\n onSearch() {\n this.props.onSearch();\n }\n\n onSelect(searchString: string) {\n this.setSearchString(searchString);\n }\n\n render() {\n let {disabled, inputReadonly, stringFormatter, onChange, onSearch, placeholder, onPressEnter, options, value, size, ...rest} = this.props;\n const searchHistoryPresent = this.props.options && this.props.options.length > 0;\n return (\n <AutoComplete\n className={(this.state.opened ? \"autocomplete-open\" : \"\") + (inputReadonly ? \" readonly\" : \"\")}\n options={this.state.opened ? this.getAutocompleteOptions() : []}\n style={{width: 200}}\n value={this.state.searchString && stringFormatter ? stringFormatter(this.state.searchString) : this.state.searchString}\n defaultOpen={false}\n defaultActiveFirstOption={false}\n onChange={(searchString) => {\n if (typeof searchString === \"string\") {\n this.setSearchString(searchString as string);\n }\n }}\n onSelect={(searchString) => {\n if (typeof searchString === \"string\") {\n this.onSelect(searchString as string);\n }\n }}\n onBlur={() => {\n this.setState({opened: false});\n }}\n {...rest}\n disabled={(disabled && !inputReadonly) || this.state.loading}\n >\n <Input\n size={size}\n allowClear={!disabled || inputReadonly}\n onKeyDown={(e) => {\n if (!this.state.opened && e.keyCode === 40 /*DOWN*/) {\n this.setState({opened: true});\n } else if (e.keyCode === 27 /*ESC*/) {\n this.setState({opened: false});\n } else if (this.state.opened && ((e.keyCode === 3 /*MAC_ENTER*/ || e.keyCode === 13) /*ENTER*/)) {\n this.setState({opened: false});\n this.onSearch();\n } else if (!this.state.opened && ((e.keyCode === 3 /*MAC_ENTER*/ || e.keyCode === 13) /*ENTER*/)) {\n this.onSearch();\n }\n }}\n placeholder={placeholder}\n prefix={this.props.prefix}\n suffix={\n searchHistoryPresent && <span className=\"dropdown-arrow\">\n <DownOutlined\n className=\"dropdown-arrow-icon ant-input-clear-icon\"\n role=\"button\" tabIndex={-1}\n onClick={() => {\n if ((!this.props.disabled || this.props.inputReadonly) && !this.state.loading) {\n this.setState({opened: !this.state.opened});\n }\n }}/>\n </span>\n }\n readOnly={inputReadonly}\n className={inputReadonly ? \"readonly\" : \"\"}\n disabled={(disabled && !inputReadonly) || this.state.loading}\n onPressEnter={this.state.opened ? undefined : onPressEnter}/>\n </AutoComplete>\n );\n }\n}"]}
1
+ {"version":3,"file":"autoCompleteInput.js","sourceRoot":"","sources":["../../../../components/input/autoCompleteInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,YAAY,EAAE,KAAK,EAAC,MAAM,MAAM,CAAC;AAEzC,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AA6B/C,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,KAAK,CAAC,SAAmE;IAYpH,YAAY,KAA4C;QACpD,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG;YACT,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,KAAK;SACjB,CAAC;QAEF,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QACtC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IApBD,MAAM,KAAK,YAAY;QACnB,OAAO;YACH,QAAQ,EAAE,GAAG,EAAE;YACf,CAAC;YACD,QAAQ,EAAE,GAAG,EAAE;YACf,CAAC;SACJ,CAAC;IACN,CAAC;IAeD,KAAK;;QACD,MAAA,IAAI,CAAC,YAAY,CAAC,OAAO,0CAAE,KAAK,EAAE,CAAC;IACvC,CAAC;IAKD,MAAM,CAAC,wBAAwB,CAAC,KAAkC,EAAE,KAAkC;QAClG,MAAM,QAAQ,GAAyC,EAAE,CAAC;QAC1D,IAAI,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,YAAY,EAAE;YACpC,QAAQ,CAAC,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC;SACvC;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED,eAAe,CAAC,YAAoB;QAChC,IAAG,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE;YAC3B,IAAI,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,EAAE,aAAa,EACvB,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAC1C,QAAQ,EAAE,CAAC,QAAQ,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAC5D,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,GAAG,CACtD,CAClB,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from \"react\"\nimport {AutoComplete, Input} from \"antd\";\nimport {AutoCompleteProps} from \"antd/es/auto-complete\";\nimport {DownOutlined} from \"@ant-design/icons\";\nimport {DefaultOptionType, RefSelectProps} from \"antd/es/select\";\n\ninterface InputSearchWithHistoryProps extends Omit<AutoCompleteProps, \"onChange\" | \"onSearch\" | \"placeholder\" | \"options\"> {\n value?: string\n\n options?: string[]\n\n placeholder?: string\n\n prefix?: React.ReactNode\n\n onChange(searchString: string): void\n\n onSearch(): void\n\n onPressEnter?(): void\n\n inputReadonly?: boolean\n\n stringFormatter?(rawString: string): string\n}\n\ninterface InputSearchWithHistoryState {\n opened: boolean\n loading: boolean\n searchString?: string\n}\n\nexport default class AutoCompleteInput extends React.Component<InputSearchWithHistoryProps, InputSearchWithHistoryState> {\n static get defaultProps() {\n return {\n onSearch: () => {\n },\n onChange: () => {\n }\n };\n }\n\n private autocomplete: React.RefObject<RefSelectProps>;\n\n constructor(props: Readonly<InputSearchWithHistoryProps>) {\n super(props);\n this.state = {\n opened: false,\n loading: false,\n };\n\n this.autocomplete = React.createRef();\n this.focus = this.focus.bind(this);\n }\n\n focus() {\n this.autocomplete.current?.focus();\n }\n\n /**\n * Handling setting search string from parent component\n */\n static getDerivedStateFromProps(props: InputSearchWithHistoryProps, state: InputSearchWithHistoryState): Partial<InputSearchWithHistoryState> {\n const newState: Partial<InputSearchWithHistoryState> = {};\n if (props.value !== state.searchString) {\n newState.searchString = props.value;\n }\n return newState;\n }\n\n setSearchString(searchString: string) {\n if(this.props.stringFormatter) {\n if (searchString.indexOf(\"ðð\") < 0 && this.props.options && this.props.options.length > 0) {\n for (let i = 0; i < this.props.options.length; i++) {\n if (searchString === this.props.stringFormatter(this.props.options[i])) {\n searchString = this.props.options[i];\n break;\n }\n }\n }\n if (this.state.searchString !== searchString) {\n this.setState({opened: false, searchString: searchString}, () => {\n this.props.onChange(searchString);\n });\n } else {\n this.setState({opened: false});\n }\n } else {\n this.setState({opened: false, searchString: searchString});\n this.props.onChange(searchString);\n }\n }\n\n getAutocompleteOptions(): DefaultOptionType[] {\n const autocompleteData = [];\n if (this.props.options && this.props.options.length > 0) {\n autocompleteData.push(...this.props.options);\n }\n return autocompleteData.filter((e) => !!e).map((e) => {\n return ({\n value: \"\" + (this.props.stringFormatter ? this.props.stringFormatter(e) : e),\n label: \"\" + (this.props.stringFormatter ? this.props.stringFormatter(e) : e)\n });\n });\n }\n\n /**\n * Handling search confirmation by pressing enter\n */\n onSearch() {\n this.props.onSearch();\n }\n\n onSelect(searchString: string) {\n this.setSearchString(searchString);\n }\n\n render() {\n let {disabled, inputReadonly, stringFormatter, onChange, onSearch, placeholder, onPressEnter, options, value, size, ...rest} = this.props;\n const searchHistoryPresent = this.props.options && this.props.options.length > 0;\n return (\n <AutoComplete\n className={(this.state.opened ? \"autocomplete-open\" : \"\") + (inputReadonly ? \" readonly\" : \"\")}\n options={this.state.opened ? this.getAutocompleteOptions() : []}\n style={{width: 200}}\n value={this.state.searchString && stringFormatter ? stringFormatter(this.state.searchString) : this.state.searchString}\n defaultOpen={false}\n defaultActiveFirstOption={false}\n onChange={(searchString) => {\n if (typeof searchString === \"string\") {\n this.setSearchString(searchString as string);\n }\n }}\n onSelect={(searchString) => {\n if (typeof searchString === \"string\") {\n this.onSelect(searchString as string);\n }\n }}\n onBlur={() => {\n this.setState({opened: false});\n }}\n {...rest}\n disabled={(disabled && !inputReadonly) || this.state.loading}\n >\n <Input\n size={size}\n allowClear={!disabled || inputReadonly}\n onKeyDown={(e) => {\n if (!this.state.opened && e.keyCode === 40 /*DOWN*/) {\n this.setState({opened: true});\n } else if (e.keyCode === 27 /*ESC*/) {\n this.setState({opened: false});\n } else if (this.state.opened && ((e.keyCode === 3 /*MAC_ENTER*/ || e.keyCode === 13) /*ENTER*/)) {\n this.setState({opened: false});\n this.onSearch();\n } else if (!this.state.opened && ((e.keyCode === 3 /*MAC_ENTER*/ || e.keyCode === 13) /*ENTER*/)) {\n this.onSearch();\n }\n }}\n placeholder={placeholder}\n prefix={this.props.prefix}\n suffix={\n searchHistoryPresent && <span className=\"dropdown-arrow\">\n <DownOutlined\n className=\"dropdown-arrow-icon ant-input-clear-icon\"\n role=\"button\" tabIndex={-1}\n onClick={() => {\n if ((!this.props.disabled || this.props.inputReadonly) && !this.state.loading) {\n this.setState({opened: !this.state.opened});\n }\n }}/>\n </span>\n }\n readOnly={inputReadonly}\n className={inputReadonly ? \"readonly\" : \"\"}\n disabled={(disabled && !inputReadonly) || this.state.loading}\n onPressEnter={this.state.opened ? undefined : onPressEnter}/>\n </AutoComplete>\n );\n }\n}"]}
@@ -8,7 +8,7 @@ interface HexaFormattedInputProps extends Omit<InputProps, "value" | "onChange">
8
8
  export default class HexaFormattedInput extends React.Component<HexaFormattedInputProps, any> {
9
9
  private inputRef;
10
10
  constructor(props: Readonly<HexaFormattedInputProps>);
11
- get input(): HTMLInputElement | undefined;
11
+ get input(): HTMLInputElement | null | undefined;
12
12
  focus(): void;
13
13
  private getFormattedValue;
14
14
  render(): JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"hexaFormattedInput.js","sourceRoot":"","sources":["../../../../components/input/hexaFormattedInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,KAAK,EAAC,MAAM,MAAM,CAAC;AAU3B,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,KAAK,CAAC,SAAuC;IAGz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,MAAM,CAAC,KAAK,CAAC;gBAC/B,IAAI,CAAC,KAAK,EAAE;oBACR,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;iBAClC;qBAAM;oBACH,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;oBACrD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;iBACvC;YACL,CAAC,EACD,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,IACjC,CACL,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from \"react\";\nimport {Input} from \"antd\";\nimport {InputProps} from \"antd/es\";\n\ninterface HexaFormattedInputProps extends Omit<InputProps, \"value\" | \"onChange\"> {\n value: string\n maxLength: number\n\n onChange(value: string | undefined): void\n}\n\nexport default class HexaFormattedInput extends React.Component<HexaFormattedInputProps, any> {\n private inputRef: Input | null = null;\n\n constructor(props: Readonly<HexaFormattedInputProps>) {\n super(props);\n }\n\n get input() {\n return this.inputRef?.input;\n }\n\n focus() {\n this.inputRef?.focus();\n }\n\n private getFormattedValue(value: string): string {\n let valueToFormat = value;\n for (let i = 0; i < this.props.maxLength - value.length; i++) {\n valueToFormat = \"0\" + valueToFormat;\n }\n return valueToFormat.toUpperCase();\n }\n\n render() {\n const {value, maxLength, onChange, ...rest} = this.props;\n\n return (\n <Input\n {...rest}\n ref={component => {\n this.inputRef = component;\n }}\n value={this.props.value.toUpperCase()}\n onChange={event => {\n const value = event.target.value;\n if (/^[0-9A-Fa-f]+$/.test(value) || value === \"\") {\n this.props.onChange(value);\n }\n }}\n onBlur={event => {\n let value = event.target.value;\n if (!value) {\n this.props.onChange(undefined);\n } else {\n const formattedValue = this.getFormattedValue(value);\n this.props.onChange(formattedValue);\n }\n }}\n maxLength={this.props.maxLength}\n />\n );\n }\n}"]}
1
+ {"version":3,"file":"hexaFormattedInput.js","sourceRoot":"","sources":["../../../../components/input/hexaFormattedInput.tsx"],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AAI,KAAK,KAAK,EAAE,EAAE;oBAC9C,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;iBAC9B;YACL,CAAC,EACD,MAAM,EAAE,KAAK,CAAC,EAAE;gBACZ,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC/B,IAAI,CAAC,KAAK,EAAE;oBACR,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;iBAClC;qBAAM;oBACH,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;oBACrD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;iBACvC;YACL,CAAC,EACD,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,IACjC,CACL,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from \"react\";\nimport {Input, InputRef} from \"antd\";\nimport {InputProps} from \"antd/es\";\n\ninterface HexaFormattedInputProps extends Omit<InputProps, \"value\" | \"onChange\"> {\n value: string\n maxLength: number\n\n onChange(value: string | undefined): void\n}\n\nexport default class HexaFormattedInput extends React.Component<HexaFormattedInputProps, any> {\n private inputRef: InputRef | null = null;\n\n constructor(props: Readonly<HexaFormattedInputProps>) {\n super(props);\n }\n\n get input() {\n return this.inputRef?.input;\n }\n\n focus() {\n this.inputRef?.focus();\n }\n\n private getFormattedValue(value: string): string {\n let valueToFormat = value;\n for (let i = 0; i < this.props.maxLength - value.length; i++) {\n valueToFormat = \"0\" + valueToFormat;\n }\n return valueToFormat.toUpperCase();\n }\n\n render() {\n const {value, maxLength, onChange, ...rest} = this.props;\n\n return (\n <Input\n {...rest}\n ref={component => {\n this.inputRef = component;\n }}\n value={this.props.value.toUpperCase()}\n onChange={event => {\n const value = event.target.value;\n if (/^[0-9A-Fa-f]+$/.test(value) || value === \"\") {\n this.props.onChange(value);\n }\n }}\n onBlur={event => {\n let value = event.target.value;\n if (!value) {\n this.props.onChange(undefined);\n } else {\n const formattedValue = this.getFormattedValue(value);\n this.props.onChange(formattedValue);\n }\n }}\n maxLength={this.props.maxLength}\n />\n );\n }\n}"]}
@@ -1,5 +1,5 @@
1
1
  import React, { ChangeEvent, ClipboardEvent, Component, KeyboardEvent } from 'react';
2
- import { Input } from 'antd';
2
+ import { InputRef } from 'antd';
3
3
  import InputMask from 'd2coreui/components/input/mask/inputMaskCore';
4
4
  import { InputProps } from 'antd/lib/input';
5
5
  export declare type MaskedInputProps = InputProps & {
@@ -11,7 +11,9 @@ export declare type MaskedInputProps = InputProps & {
11
11
  declare type TChangeEvent = ChangeEvent<HTMLInputElement>;
12
12
  declare type TKeyboardEvent = KeyboardEvent<HTMLInputElement>;
13
13
  declare type TClipboardEvent = ClipboardEvent<any>;
14
- export default class MaskedInput extends Component<MaskedInputProps> {
14
+ export default class MaskedInput extends Component<MaskedInputProps, {
15
+ value?: string;
16
+ }> {
15
17
  mask: InputMask;
16
18
  input: HTMLInputElement;
17
19
  constructor(props: MaskedInputProps);
@@ -45,15 +47,9 @@ export default class MaskedInput extends Component<MaskedInputProps> {
45
47
  onPaste: (e: TClipboardEvent) => void;
46
48
  onBeforeInput?: React.FormEventHandler<HTMLInputElement> | undefined;
47
49
  onKeyPress?: React.KeyboardEventHandler<HTMLInputElement> | undefined;
48
- prefixCls?: string | undefined;
49
50
  size?: import("antd/lib/button").ButtonSize;
50
- type?: import("antd/lib/_util/type").LiteralUnion<"number" | "button" | "time" | "search" | "image" | "text" | "hidden" | "color" | "checkbox" | "radio" | "tel" | "url" | "email" | "date" | "datetime-local" | "file" | "month" | "password" | "range" | "reset" | "submit" | "week", string> | undefined;
51
- onPressEnter?: React.KeyboardEventHandler<HTMLInputElement> | undefined;
52
- addonBefore?: React.ReactNode;
53
- addonAfter?: React.ReactNode;
54
- prefix?: React.ReactNode;
55
- suffix?: React.ReactNode;
56
- allowClear?: boolean | undefined;
51
+ disabled?: boolean | undefined;
52
+ status?: "" | "warning" | "error" | undefined;
57
53
  bordered?: boolean | undefined;
58
54
  dir?: string | undefined;
59
55
  form?: string | undefined;
@@ -61,6 +57,7 @@ export default class MaskedInput extends Component<MaskedInputProps> {
61
57
  style?: React.CSSProperties | undefined;
62
58
  title?: string | undefined;
63
59
  className?: string | undefined;
60
+ prefix?: React.ReactNode;
64
61
  value?: ((string | number | readonly string[]) & string) | undefined;
65
62
  children?: React.ReactNode;
66
63
  pattern?: string | undefined;
@@ -71,7 +68,6 @@ export default class MaskedInput extends Component<MaskedInputProps> {
71
68
  capture?: boolean | "user" | "environment" | undefined;
72
69
  checked?: boolean | undefined;
73
70
  crossOrigin?: string | undefined;
74
- disabled?: boolean | undefined;
75
71
  formAction?: string | undefined;
76
72
  formEncType?: string | undefined;
77
73
  formMethod?: string | undefined;
@@ -88,6 +84,7 @@ export default class MaskedInput extends Component<MaskedInputProps> {
88
84
  required?: boolean | undefined;
89
85
  src?: string | undefined;
90
86
  step?: string | number | undefined;
87
+ type?: import("rc-input/lib/utils/types").LiteralUnion<"number" | "button" | "time" | "search" | "image" | "text" | "hidden" | "color" | "checkbox" | "radio" | "tel" | "url" | "email" | "date" | "submit" | "reset" | "datetime-local" | "file" | "month" | "password" | "range" | "week", string> | undefined;
91
88
  width?: string | number | undefined;
92
89
  defaultChecked?: boolean | undefined;
93
90
  defaultValue?: string | number | readonly string[] | undefined;
@@ -332,13 +329,23 @@ export default class MaskedInput extends Component<MaskedInputProps> {
332
329
  onAnimationIterationCapture?: React.AnimationEventHandler<HTMLInputElement> | undefined;
333
330
  onTransitionEnd?: React.TransitionEventHandler<HTMLInputElement> | undefined;
334
331
  onTransitionEndCapture?: React.TransitionEventHandler<HTMLInputElement> | undefined;
332
+ prefixCls?: string | undefined;
335
333
  enterKeyHint?: "search" | "enter" | "done" | "go" | "next" | "previous" | "send" | undefined;
334
+ onPressEnter?: React.KeyboardEventHandler<HTMLInputElement> | undefined;
335
+ showCount?: boolean | import("rc-input/lib/interface").ShowCountProps | undefined;
336
+ htmlSize?: number | undefined;
337
+ suffix?: React.ReactNode;
338
+ addonBefore?: React.ReactNode;
339
+ addonAfter?: React.ReactNode;
340
+ allowClear?: boolean | {
341
+ clearIcon?: React.ReactNode;
342
+ } | undefined;
336
343
  mask: string;
337
344
  };
338
345
  _lastValue: any;
339
346
  setInputValue: (value: string) => void;
340
- _Input: Input | null;
341
- handleInputRef: (ref: Input) => void;
347
+ _Input: InputRef | null;
348
+ handleInputRef: (ref: InputRef) => void;
342
349
  render(): JSX.Element;
343
350
  }
344
351
  export {};
@@ -110,13 +110,15 @@ export default class MaskedInput extends Component {
110
110
  return;
111
111
  if (value === this._lastValue)
112
112
  return;
113
+ this.setState({ value: value });
113
114
  this._lastValue = value;
114
- this._Input.setState({ value });
115
- this._Input.input.value = value;
115
+ if (this._Input.input) {
116
+ this._Input.input.value = value;
117
+ }
116
118
  };
117
119
  this._Input = null;
118
120
  this.handleInputRef = (ref) => {
119
- if (!ref)
121
+ if (!ref || !ref.input)
120
122
  return;
121
123
  this._Input = ref;
122
124
  this.input = ref.input;
@@ -126,6 +128,9 @@ export default class MaskedInput extends Component {
126
128
  this.setInputValue(this._getDisplayValue());
127
129
  }
128
130
  };
131
+ this.state = {
132
+ value: this.props.value,
133
+ };
129
134
  let options = {
130
135
  pattern: this.props.mask,
131
136
  value: this.props.value,
@@ -214,7 +219,7 @@ export default class MaskedInput extends Component {
214
219
  this.input.blur();
215
220
  }
216
221
  render() {
217
- return React.createElement(Input, Object.assign({}, this.getInputProps(), { ref: this.handleInputRef }));
222
+ return React.createElement(Input, Object.assign({ value: this.state.value }, this.getInputProps(), { ref: this.handleInputRef }));
218
223
  }
219
224
  }
220
225
  //# sourceMappingURL=maskedInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"maskedInput.js","sourceRoot":"","sources":["../../../../components/input/maskedInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAA8B,SAAS,EAAgB,MAAM,OAAO,CAAC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CAAC,CAAC;IAClD,CAAC;IA+FD,gBAAgB;QACZ,IAAI,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACjC,OAAO,KAAK,KAAK,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACvD,CAAC;IAED,iBAAiB;QACb,IAAI,OAAO,SAAS,KAAK,WAAW,EAAE;YAClC,OAAO,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC;gBACxC,CAAC,CAAC,eAAe;gBACjB,CAAC,CAAC,YAAY,CAAC;SACtB;QACD,OAAO,YAAY,CAAC;IACxB,CAAC;IAED,iBAAiB;QAOb,OAAO;YACH,QAAQ,EAAE,IAAI,CAAC,SAAS;YACxB,SAAS,EAAE,IAAI,CAAC,UAAU;YAC1B,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,EAAE,IAAI,CAAC,WAAW;SAC/C,CAAC;IACN,CAAC;IAED,KAAK;QACD,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAED,IAAI;QACA,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;IAsCD,MAAM;QACF,OAAO,oBAAC,KAAK,oBAAK,IAAI,CAAC,aAAa,EAAE,IAAE,GAAG,EAAE,IAAI,CAAC,cAAc,IAAG,CAAC;IACxE,CAAC;CACJ","sourcesContent":["import React, {ChangeEvent, ClipboardEvent, Component, KeyboardEvent} from 'react';\nimport {Input} from 'antd';\nimport InputMask from 'd2coreui/components/input/mask/inputMaskCore';\nimport {getSelection, isRedo, isUndo, setSelection} from 'd2coreui/components/input/mask/helpers';\nimport {InputProps} from 'antd/lib/input';\n\nexport type MaskedInputProps = InputProps & {\n mask: string;\n formatCharacters?: object;\n placeholderChar?: string;\n value?: string;\n};\n\ntype TChangeEvent = ChangeEvent<HTMLInputElement>;\ntype TKeyboardEvent = KeyboardEvent<HTMLInputElement>;\ntype TClipboardEvent = ClipboardEvent<any>;\n\nexport default class MaskedInput extends Component<MaskedInputProps> {\n mask: InputMask;\n input!: HTMLInputElement;\n\n constructor(props: MaskedInputProps) {\n super(props);\n\n let options: any = {\n pattern: this.props.mask,\n value: this.props.value,\n formatCharacters: this.props.formatCharacters\n };\n\n if (this.props.placeholderChar) {\n options.placeholderChar = this.props.placeholderChar;\n }\n\n this.mask = new InputMask(options);\n }\n\n componentDidMount() {\n this.setInputValue(this._getDisplayValue());\n }\n\n UNSAFE_componentWillReceiveProps(nextProps: MaskedInputProps) {\n if (\n this.props.mask !== nextProps.mask &&\n this.props.value !== nextProps.mask\n ) {\n // if we get a new value and a new mask at the same time\n // check if the mask.value is still the initial value\n // - if so use the nextProps value\n // - otherwise the `this.mask` has a value for us (most likely from paste action)\n if (this.mask.getValue() === this.mask.emptyValue) {\n this.mask.setPattern(nextProps.mask, {value: nextProps.value});\n } else {\n this.mask.setPattern(nextProps.mask, {\n value: this.mask.getRawValue()\n });\n }\n } else if (this.props.mask !== nextProps.mask) {\n this.mask.setPattern(nextProps.mask, {value: this.mask.getRawValue()});\n }\n\n if (this.props.value !== nextProps.value) {\n this.mask.setValue(nextProps.value);\n this.setInputValue(this._getDisplayValue());\n }\n }\n\n UNSAFE_componentWillUpdate(nextProps: MaskedInputProps) {\n if (!this.props.mask) return null;\n if (nextProps.mask !== this.props.mask) {\n this._updatePattern(nextProps);\n }\n return;\n }\n\n componentDidUpdate(prevProps: MaskedInputProps) {\n if (!this.props.mask) return null;\n if (prevProps.mask !== this.props.mask && this.mask.selection.start) {\n this._updateInputSelection();\n }\n return;\n }\n\n _updatePattern(props: MaskedInputProps) {\n this.mask.setPattern(props.mask, {\n value: this.mask.getRawValue(),\n selection: getSelection(this.input)\n });\n }\n\n _updateMaskSelection() {\n this.mask.selection = getSelection(this.input);\n }\n\n _updateInputSelection() {\n setSelection(this.input, this.mask.selection);\n }\n\n _onChange = (e: TChangeEvent) => {\n let maskValue = this.mask.getValue();\n let incomingValue = e.target.value;\n if (incomingValue !== maskValue) {\n // only modify mask if form contents actually changed\n this._updateMaskSelection();\n this.mask.setValue(incomingValue); // write the whole updated value into the mask\n this.setInputValue(this._getDisplayValue()); // update the form with pattern applied to the value\n this._updateInputSelection();\n }\n\n if (this.props.onChange) {\n this.props.onChange(e);\n }\n };\n\n _onKeyDown = (e: TKeyboardEvent) => {\n setTimeout(() => {\n this.input.classList[this.input.value ? 'add' : 'remove']('has-value');\n }, 100);\n\n if (isUndo(e)) {\n e.preventDefault();\n if (this.mask.undo()) {\n this.setInputValue(this._getDisplayValue());\n this._updateInputSelection();\n if (this.props.onChange) {\n this.props.onChange(e as unknown as TChangeEvent);\n }\n }\n return;\n } else if (isRedo(e)) {\n e.preventDefault();\n if (this.mask.redo()) {\n this.setInputValue(this._getDisplayValue());\n this._updateInputSelection();\n if (this.props.onChange) {\n this.props.onChange(e as unknown as TChangeEvent);\n }\n }\n return;\n }\n\n if (e.key === 'Backspace') {\n e.preventDefault();\n this._updateMaskSelection();\n if (this.mask.backspace()) {\n let value = this._getDisplayValue();\n this.setInputValue(value);\n if (value) {\n this._updateInputSelection();\n }\n if (this.props.onChange) {\n this.props.onChange(e as unknown as TChangeEvent);\n }\n }\n }\n };\n\n _onKeyPress = (e: TKeyboardEvent) => {\n // Ignore modified key presses\n // Ignore enter key to allow form submission\n if (e.metaKey || e.altKey || e.ctrlKey || e.key === 'Enter') {\n return;\n }\n\n e.preventDefault();\n this._updateMaskSelection();\n if (this.mask.input(e.key /*|| e.data*/)) {\n this.setInputValue(this.mask.getValue());\n this._updateInputSelection();\n if (this.props.onChange) {\n this.props.onChange(e as unknown as TChangeEvent);\n }\n }\n };\n\n _onPaste = (e: TClipboardEvent) => {\n e.preventDefault();\n this._updateMaskSelection();\n // getData value needed for IE also works in FF & Chrome\n if (this.mask.paste(e.clipboardData.getData('Text'))) {\n // @ts-ignore\n this.setInputValue(this.mask.getValue());\n // Timeout needed for IE\n setTimeout(() => this._updateInputSelection(), 0);\n if (this.props.onChange) {\n // @ts-ignore\n this.props.onChange(e);\n }\n }\n };\n\n _getDisplayValue() {\n let value = this.mask.getValue();\n return value === this.mask.emptyValue ? '' : value;\n }\n\n _keyPressPropName() {\n if (typeof navigator !== 'undefined') {\n return navigator.userAgent.match(/Android/i)\n ? 'onBeforeInput'\n : 'onKeyPress';\n }\n return 'onKeyPress';\n }\n\n _getEventHandlers(): {\n onChange: (e: TChangeEvent) => void;\n onKeyDown: (e: TKeyboardEvent) => void;\n onPaste: (e: TClipboardEvent) => void;\n onBeforeInput?: (e: TChangeEvent) => void;\n onKeyPress?: (e: TKeyboardEvent) => void;\n } {\n return {\n onChange: this._onChange,\n onKeyDown: this._onKeyDown,\n onPaste: this._onPaste,\n [this._keyPressPropName()]: this._onKeyPress\n };\n }\n\n focus() {\n this.input.focus();\n }\n\n blur() {\n this.input.blur();\n }\n\n getInputProps = () => {\n let maxLength = this.mask.pattern.length;\n let eventHandlers = this._getEventHandlers();\n let {placeholder = this.mask.emptyValue} = this.props;\n\n let {placeholderChar, formatCharacters, ...cleanedProps} = this.props;\n const props = {...cleanedProps, ...eventHandlers, maxLength, placeholder};\n delete props.value;\n return props;\n };\n\n _lastValue = null as any;\n setInputValue = (value: string) => {\n if (!this._Input) return;\n if (value === this._lastValue) return;\n\n this._lastValue = value;\n this._Input.setState({value});\n this._Input.input.value = value;\n };\n\n _Input: Input | null = null;\n handleInputRef = (ref: Input) => {\n if (!ref) return;\n this._Input = ref;\n this.input = ref.input;\n\n if (\n this._lastValue === null &&\n typeof this.props.defaultValue === 'string'\n ) {\n this.mask.setValue(this.props.defaultValue); // write the whole updated value into the mask\n this.setInputValue(this._getDisplayValue()); // update the form with pattern applied to the value\n }\n };\n\n render() {\n return <Input {...this.getInputProps()} ref={this.handleInputRef}/>;\n }\n}"]}
1
+ {"version":3,"file":"maskedInput.js","sourceRoot":"","sources":["../../../../components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Ac,IAAG,CAAC;IACjG,CAAC;CACJ","sourcesContent":["import React, {ChangeEvent, ClipboardEvent, Component, KeyboardEvent} from 'react';\nimport {Input, InputRef} from 'antd';\nimport InputMask from 'd2coreui/components/input/mask/inputMaskCore';\nimport {getSelection, isRedo, isUndo, setSelection} from 'd2coreui/components/input/mask/helpers';\nimport {InputProps} from 'antd/lib/input';\n\nexport type MaskedInputProps = InputProps & {\n mask: string;\n formatCharacters?: object;\n placeholderChar?: string;\n value?: string;\n};\n\ntype TChangeEvent = ChangeEvent<HTMLInputElement>;\ntype TKeyboardEvent = KeyboardEvent<HTMLInputElement>;\ntype TClipboardEvent = ClipboardEvent<any>;\n\nexport default class MaskedInput extends Component<MaskedInputProps, {value?: string}> {\n mask: InputMask;\n input!: HTMLInputElement;\n\n constructor(props: MaskedInputProps) {\n super(props);\n\n this.state = {\n value: this.props.value,\n }\n\n let options: any = {\n pattern: this.props.mask,\n value: this.props.value,\n formatCharacters: this.props.formatCharacters\n };\n\n if (this.props.placeholderChar) {\n options.placeholderChar = this.props.placeholderChar;\n }\n\n this.mask = new InputMask(options);\n }\n\n componentDidMount() {\n this.setInputValue(this._getDisplayValue());\n }\n\n UNSAFE_componentWillReceiveProps(nextProps: MaskedInputProps) {\n if (\n this.props.mask !== nextProps.mask &&\n this.props.value !== nextProps.mask\n ) {\n // if we get a new value and a new mask at the same time\n // check if the mask.value is still the initial value\n // - if so use the nextProps value\n // - otherwise the `this.mask` has a value for us (most likely from paste action)\n if (this.mask.getValue() === this.mask.emptyValue) {\n this.mask.setPattern(nextProps.mask, {value: nextProps.value});\n } else {\n this.mask.setPattern(nextProps.mask, {\n value: this.mask.getRawValue()\n });\n }\n } else if (this.props.mask !== nextProps.mask) {\n this.mask.setPattern(nextProps.mask, {value: this.mask.getRawValue()});\n }\n\n if (this.props.value !== nextProps.value) {\n this.mask.setValue(nextProps.value);\n this.setInputValue(this._getDisplayValue());\n }\n }\n\n UNSAFE_componentWillUpdate(nextProps: MaskedInputProps) {\n if (!this.props.mask) return null;\n if (nextProps.mask !== this.props.mask) {\n this._updatePattern(nextProps);\n }\n return;\n }\n\n componentDidUpdate(prevProps: MaskedInputProps) {\n if (!this.props.mask) return null;\n if (prevProps.mask !== this.props.mask && this.mask.selection.start) {\n this._updateInputSelection();\n }\n return;\n }\n\n _updatePattern(props: MaskedInputProps) {\n this.mask.setPattern(props.mask, {\n value: this.mask.getRawValue(),\n selection: getSelection(this.input)\n });\n }\n\n _updateMaskSelection() {\n this.mask.selection = getSelection(this.input);\n }\n\n _updateInputSelection() {\n setSelection(this.input, this.mask.selection);\n }\n\n _onChange = (e: TChangeEvent) => {\n let maskValue = this.mask.getValue();\n let incomingValue = e.target.value;\n if (incomingValue !== maskValue) {\n // only modify mask if form contents actually changed\n this._updateMaskSelection();\n this.mask.setValue(incomingValue); // write the whole updated value into the mask\n this.setInputValue(this._getDisplayValue()); // update the form with pattern applied to the value\n this._updateInputSelection();\n }\n\n if (this.props.onChange) {\n this.props.onChange(e);\n }\n };\n\n _onKeyDown = (e: TKeyboardEvent) => {\n setTimeout(() => {\n this.input.classList[this.input.value ? 'add' : 'remove']('has-value');\n }, 100);\n\n if (isUndo(e)) {\n e.preventDefault();\n if (this.mask.undo()) {\n this.setInputValue(this._getDisplayValue());\n this._updateInputSelection();\n if (this.props.onChange) {\n this.props.onChange(e as unknown as TChangeEvent);\n }\n }\n return;\n } else if (isRedo(e)) {\n e.preventDefault();\n if (this.mask.redo()) {\n this.setInputValue(this._getDisplayValue());\n this._updateInputSelection();\n if (this.props.onChange) {\n this.props.onChange(e as unknown as TChangeEvent);\n }\n }\n return;\n }\n\n if (e.key === 'Backspace') {\n e.preventDefault();\n this._updateMaskSelection();\n if (this.mask.backspace()) {\n let value = this._getDisplayValue();\n this.setInputValue(value);\n if (value) {\n this._updateInputSelection();\n }\n if (this.props.onChange) {\n this.props.onChange(e as unknown as TChangeEvent);\n }\n }\n }\n };\n\n _onKeyPress = (e: TKeyboardEvent) => {\n // Ignore modified key presses\n // Ignore enter key to allow form submission\n if (e.metaKey || e.altKey || e.ctrlKey || e.key === 'Enter') {\n return;\n }\n\n e.preventDefault();\n this._updateMaskSelection();\n if (this.mask.input(e.key /*|| e.data*/)) {\n this.setInputValue(this.mask.getValue());\n this._updateInputSelection();\n if (this.props.onChange) {\n this.props.onChange(e as unknown as TChangeEvent);\n }\n }\n };\n\n _onPaste = (e: TClipboardEvent) => {\n e.preventDefault();\n this._updateMaskSelection();\n // getData value needed for IE also works in FF & Chrome\n if (this.mask.paste(e.clipboardData.getData('Text'))) {\n // @ts-ignore\n this.setInputValue(this.mask.getValue());\n // Timeout needed for IE\n setTimeout(() => this._updateInputSelection(), 0);\n if (this.props.onChange) {\n // @ts-ignore\n this.props.onChange(e);\n }\n }\n };\n\n _getDisplayValue() {\n let value = this.mask.getValue();\n return value === this.mask.emptyValue ? '' : value;\n }\n\n _keyPressPropName() {\n if (typeof navigator !== 'undefined') {\n return navigator.userAgent.match(/Android/i)\n ? 'onBeforeInput'\n : 'onKeyPress';\n }\n return 'onKeyPress';\n }\n\n _getEventHandlers(): {\n onChange: (e: TChangeEvent) => void;\n onKeyDown: (e: TKeyboardEvent) => void;\n onPaste: (e: TClipboardEvent) => void;\n onBeforeInput?: (e: TChangeEvent) => void;\n onKeyPress?: (e: TKeyboardEvent) => void;\n } {\n return {\n onChange: this._onChange,\n onKeyDown: this._onKeyDown,\n onPaste: this._onPaste,\n [this._keyPressPropName()]: this._onKeyPress\n };\n }\n\n focus() {\n this.input.focus();\n }\n\n blur() {\n this.input.blur();\n }\n\n getInputProps = () => {\n let maxLength = this.mask.pattern.length;\n let eventHandlers = this._getEventHandlers();\n let {placeholder = this.mask.emptyValue} = this.props;\n\n let {placeholderChar, formatCharacters, ...cleanedProps} = this.props;\n const props = {...cleanedProps, ...eventHandlers, maxLength, placeholder};\n delete props.value;\n return props;\n };\n\n _lastValue = null as any;\n setInputValue = (value: string) => {\n if (!this._Input) return;\n if (value === this._lastValue) return;\n\n this.setState({value: value});\n\n this._lastValue = value;\n if (this._Input.input) {\n this._Input.input.value = value;\n }\n };\n\n _Input: InputRef | null = null;\n handleInputRef = (ref: InputRef) => {\n if (!ref || !ref.input) return;\n this._Input = ref;\n this.input = ref.input;\n\n if (\n this._lastValue === null &&\n typeof this.props.defaultValue === 'string'\n ) {\n this.mask.setValue(this.props.defaultValue); // write the whole updated value into the mask\n this.setInputValue(this._getDisplayValue()); // update the form with pattern applied to the value\n }\n };\n\n render() {\n return <Input value={this.state.value} {...this.getInputProps()} ref={this.handleInputRef}/>;\n }\n}"]}
@@ -9,5 +9,5 @@ interface ContextProps extends DraggableModalContextMethods {
9
9
  export interface DraggableModalInnerProps extends DraggableModalProps, ContextProps {
10
10
  children?: React.ReactNode;
11
11
  }
12
- export declare const DraggableModalInner: React.MemoExoticComponent<({ id, modalState, dispatch, visible, children, title, onResize, ...otherProps }: DraggableModalInnerProps) => JSX.Element>;
12
+ export declare const DraggableModalInner: React.MemoExoticComponent<({ id, modalState, dispatch, open, children, title, onResize, ...otherProps }: DraggableModalInnerProps) => JSX.Element>;
13
13
  export {};
@@ -18,22 +18,22 @@ import { usePrevious } from './usePrevious';
18
18
  import { useResize } from './useResize';
19
19
  const modalStyle = { margin: 0, paddingBottom: 0, pointerEvents: 'auto' };
20
20
  export const DraggableModalInner = memo((_a) => {
21
- var { id, modalState, dispatch, visible, children, title, onResize } = _a, otherProps = __rest(_a, ["id", "modalState", "dispatch", "visible", "children", "title", "onResize"]);
21
+ var { id, modalState, dispatch, open, children, title, onResize } = _a, otherProps = __rest(_a, ["id", "modalState", "dispatch", "open", "children", "title", "onResize"]);
22
22
  useEffect(() => {
23
23
  dispatch({ type: 'mount', id, size: { width: otherProps.initialWidth, height: otherProps.initialHeight } });
24
24
  return () => dispatch({ type: 'unmount', id });
25
25
  }, [dispatch, id]);
26
- const visiblePrevious = usePrevious(visible);
26
+ const visiblePrevious = usePrevious(open);
27
27
  useEffect(() => {
28
- if (visible !== visiblePrevious) {
29
- if (visible) {
28
+ if (open !== visiblePrevious) {
29
+ if (open) {
30
30
  dispatch({ type: 'show', id });
31
31
  }
32
32
  else {
33
33
  dispatch({ type: 'hide', id });
34
34
  }
35
35
  }
36
- }, [visible, visiblePrevious, id, dispatch]);
36
+ }, [open, visiblePrevious, id, dispatch]);
37
37
  const { zIndex, x, y, width, height } = modalState;
38
38
  const style = useMemo(() => (Object.assign(Object.assign({}, modalStyle), { top: y, left: x, height })), [y, x, height]);
39
39
  const onFocus = useCallback(() => dispatch({ type: 'focus', id }), [id, dispatch]);
@@ -48,7 +48,7 @@ export const DraggableModalInner = memo((_a) => {
48
48
  const onMouseDrag = useDrag(x, y, onDragWithID);
49
49
  const onMouseResize = useResize(x, y, width, height, onResizeWithID);
50
50
  const titleElement = useMemo(() => (React.createElement("div", { className: "ant-design-draggable-modal-title", onMouseDown: onMouseDrag, onClick: onFocus }, title)), [onMouseDrag, onFocus, title]);
51
- return (React.createElement(Modal, Object.assign({ wrapClassName: "ant-design-draggable-modal", style: style, destroyOnClose: true, width: width, zIndex: zIndex, title: titleElement, visible: visible }, otherProps),
51
+ return (React.createElement(Modal, Object.assign({ wrapClassName: "ant-design-draggable-modal", style: style, destroyOnClose: true, width: width, zIndex: zIndex, title: titleElement, open: open }, otherProps),
52
52
  children,
53
53
  React.createElement(ResizeHandle, { onMouseDown: onMouseResize })));
54
54
  });
@@ -1 +1 @@
1
- {"version":3,"file":"draggableModalInner.js","sourceRoot":"","sources":["../../../../../components/modal/impl/draggableModalInner.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAC,MAAM,OAAO,CAAA;AAC3D,OAAO,EAAC,KAAK,EAAC,MAAM,MAAM,CAAA;AAC1B,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,OAAO,EAAC,MAAM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E,OAAO,IAEf,KAAK,CACJ,CACT,EACD,CAAC,WAAW,EAAE,OAAO,EAAE,KAAK,CAAC,CAChC,CAAC;IAEF,OAAO,CACH,oBAAC,KAAK,kBACF,aAAa,EAAC,4BAA4B,EAC1C,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,IAAI,EACpB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,OAAO,IACZ,UAAU;QAEb,QAAQ;QACT,oBAAC,YAAY,IAAC,WAAW,EAAE,aAAa,GAAG,CACvC,CACX,CAAA;AACL,CAAC,CACJ,CAAC;AAEF,mBAAmB,CAAC,WAAW,GAAG,qBAAqB,CAAC","sourcesContent":["import * as React from 'react'\nimport {memo, useCallback, useEffect, useMemo} from 'react'\nimport {Modal} from 'antd'\nimport {ResizeHandle} from './resizeHandle'\nimport {useDrag} from './useDrag'\nimport {DraggableModalContextMethods} from './draggableModalContext'\nimport {usePrevious} from './usePrevious'\nimport {ModalID, ModalState} from './draggableModalReducer'\nimport {useResize} from './useResize'\nimport {DraggableModalProps} from \"./draggableModal\";\n\nconst modalStyle: React.CSSProperties = {margin: 0, paddingBottom: 0, pointerEvents: 'auto'}\n\ninterface ContextProps extends DraggableModalContextMethods {\n id: ModalID\n modalState: ModalState\n}\n\n//export type DraggableModalInnerProps = ModalProps & { children?: React.ReactNode } & ContextProps\nexport interface DraggableModalInnerProps extends DraggableModalProps, ContextProps {\n children?: React.ReactNode\n}\n\nexport const DraggableModalInner = memo(\n ({\n id,\n modalState,\n dispatch,\n visible,\n children,\n title,\n onResize,\n ...otherProps\n }: DraggableModalInnerProps) => {\n // Call on mount and unmount.\n useEffect(() => {\n dispatch({type: 'mount', id, size: {width: otherProps.initialWidth, height: otherProps.initialHeight}});\n return () => dispatch({type: 'unmount', id})\n }, [dispatch, id]);\n\n // Bring this to the front if it's been opened with props.\n const visiblePrevious = usePrevious(visible);\n useEffect(() => {\n if (visible !== visiblePrevious) {\n if (visible) {\n dispatch({type: 'show', id})\n } else {\n dispatch({type: 'hide', id})\n }\n }\n }, [visible, visiblePrevious, id, dispatch]);\n\n const {zIndex, x, y, width, height} = modalState;\n\n const style: React.CSSProperties = useMemo(\n () => ({...modalStyle, top: y, left: x, height}),\n [y, x, height],\n );\n\n const onFocus = useCallback(() => dispatch({type: 'focus', id}), [id, dispatch])\n\n const onDragWithID = useCallback(args => dispatch({type: 'drag', id, ...args}), [\n dispatch,\n id,\n ]);\n\n const onResizeWithID = useCallback((args) => {\n onResize?.({width: args.width, height: args.height});\n return dispatch({type: 'resize', id, ...args});\n }, [dispatch, id,]);\n\n const onMouseDrag = useDrag(x, y, onDragWithID);\n const onMouseResize = useResize(x, y, width, height, onResizeWithID);\n\n const titleElement = useMemo(\n () => (\n <div\n className=\"ant-design-draggable-modal-title\"\n onMouseDown={onMouseDrag}\n onClick={onFocus}\n >\n {title}\n </div>\n ),\n [onMouseDrag, onFocus, title],\n );\n\n return (\n <Modal\n wrapClassName=\"ant-design-draggable-modal\"\n style={style}\n destroyOnClose={true}\n width={width}\n zIndex={zIndex}\n title={titleElement}\n visible={visible}\n {...otherProps}\n >\n {children}\n <ResizeHandle onMouseDown={onMouseResize}/>\n </Modal>\n )\n },\n);\n\nDraggableModalInner.displayName = 'DraggableModalInner';\n"]}
1
+ {"version":3,"file":"draggableModalInner.js","sourceRoot":"","sources":["../../../../../components/modal/impl/draggableModalInner.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAC,MAAM,OAAO,CAAA;AAC3D,OAAO,EAAC,KAAK,EAAC,MAAM,MAAM,CAAA;AAC1B,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AAEjC,OAAO,EAAC,WAAW,EA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C,WAAW,EAAE,OAAO,EAAE,KAAK,CAAC,CAChC,CAAC;IAEF,OAAO,CACH,oBAAC,KAAK,kBACF,aAAa,EAAC,4BAA4B,EAC1C,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,IAAI,EACpB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,IAAI,IACN,UAAU;QAEb,QAAQ;QACT,oBAAC,YAAY,IAAC,WAAW,EAAE,aAAa,GAAG,CACvC,CACX,CAAA;AACL,CAAC,CACJ,CAAC;AAEF,mBAAmB,CAAC,WAAW,GAAG,qBAAqB,CAAC","sourcesContent":["import * as React from 'react'\nimport {memo, useCallback, useEffect, useMemo} from 'react'\nimport {Modal} from 'antd'\nimport {ResizeHandle} from './resizeHandle'\nimport {useDrag} from './useDrag'\nimport {DraggableModalContextMethods} from './draggableModalContext'\nimport {usePrevious} from './usePrevious'\nimport {ModalID, ModalState} from './draggableModalReducer'\nimport {useResize} from './useResize'\nimport {DraggableModalProps} from \"./draggableModal\";\n\nconst modalStyle: React.CSSProperties = {margin: 0, paddingBottom: 0, pointerEvents: 'auto'}\n\ninterface ContextProps extends DraggableModalContextMethods {\n id: ModalID\n modalState: ModalState\n}\n\n//export type DraggableModalInnerProps = ModalProps & { children?: React.ReactNode } & ContextProps\nexport interface DraggableModalInnerProps extends DraggableModalProps, ContextProps {\n children?: React.ReactNode\n}\n\nexport const DraggableModalInner = memo(\n ({\n id,\n modalState,\n dispatch,\n open,\n children,\n title,\n onResize,\n ...otherProps\n }: DraggableModalInnerProps) => {\n // Call on mount and unmount.\n useEffect(() => {\n dispatch({type: 'mount', id, size: {width: otherProps.initialWidth, height: otherProps.initialHeight}});\n return () => dispatch({type: 'unmount', id})\n }, [dispatch, id]);\n\n // Bring this to the front if it's been opened with props.\n const visiblePrevious = usePrevious(open);\n useEffect(() => {\n if (open !== visiblePrevious) {\n if (open) {\n dispatch({type: 'show', id})\n } else {\n dispatch({type: 'hide', id})\n }\n }\n }, [open, visiblePrevious, id, dispatch]);\n\n const {zIndex, x, y, width, height} = modalState;\n\n const style: React.CSSProperties = useMemo(\n () => ({...modalStyle, top: y, left: x, height}),\n [y, x, height],\n );\n\n const onFocus = useCallback(() => dispatch({type: 'focus', id}), [id, dispatch])\n\n const onDragWithID = useCallback(args => dispatch({type: 'drag', id, ...args}), [\n dispatch,\n id,\n ]);\n\n const onResizeWithID = useCallback((args) => {\n onResize?.({width: args.width, height: args.height});\n return dispatch({type: 'resize', id, ...args});\n }, [dispatch, id,]);\n\n const onMouseDrag = useDrag(x, y, onDragWithID);\n const onMouseResize = useResize(x, y, width, height, onResizeWithID);\n\n const titleElement = useMemo(\n () => (\n <div\n className=\"ant-design-draggable-modal-title\"\n onMouseDown={onMouseDrag}\n onClick={onFocus}\n >\n {title}\n </div>\n ),\n [onMouseDrag, onFocus, title],\n );\n\n return (\n <Modal\n wrapClassName=\"ant-design-draggable-modal\"\n style={style}\n destroyOnClose={true}\n width={width}\n zIndex={zIndex}\n title={titleElement}\n open={open}\n {...otherProps}\n >\n {children}\n <ResizeHandle onMouseDown={onMouseResize}/>\n </Modal>\n )\n },\n);\n\nDraggableModalInner.displayName = 'DraggableModalInner';\n"]}
@@ -16,7 +16,7 @@ export default class EnumValuePicker extends React.Component {
16
16
  render() {
17
17
  const _a = this.props, { value, allowedValueTypes, onChange, translationPrefix, values, translateValue } = _a, others = __rest(_a, ["value", "allowedValueTypes", "onChange", "translationPrefix", "values", "translateValue"]);
18
18
  let selectValue = value;
19
- if (selectValue !== undefined && allowedValueTypes) {
19
+ if (selectValue !== undefined && selectValue !== null && allowedValueTypes) {
20
20
  if (!allowedValueTypes.includes(selectValue)) {
21
21
  selectValue = undefined;
22
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"enumValuePicker.js","sourceRoot":"","sources":["../../../../components/picker/enumValuePicker.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO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AAC;IACN,CAAC;CACJ","sourcesContent":["import React from \"react\";\nimport {Select, SelectProps} from \"antd\";\nimport i18n from \"d2core/i18n/i18n\";\n\ntype EnumRepresentation<T extends string> = {[key in string]: T};\n\nexport interface EnumValuePickerProps<T extends string> extends Omit<SelectProps<T>, \"onChange\"> {\n allowedValueTypes?: T[]\n values: EnumRepresentation<T>\n translateValue?: boolean\n translationPrefix?: string\n\n onChange(value?: T): void\n}\n\nexport default class EnumValuePicker<T extends string> extends React.Component<EnumValuePickerProps<T>, any> {\n render() {\n const {value, allowedValueTypes, onChange, translationPrefix, values, translateValue, ...others} = this.props;\n let selectValue: T | undefined = value;\n\n if (selectValue !== undefined && allowedValueTypes) {\n if (!allowedValueTypes.includes(selectValue)) {\n selectValue = undefined;\n }\n }\n\n return (\n <Select<T> value={selectValue}\n onChange={(value) => {\n onChange(value !== \"\" ? value : undefined);\n }}\n {...others}>\n {(allowedValueTypes ?? Object.values(values) as T[]).map((val) => {\n let text: string = val;\n if (translateValue) {\n text = i18n(translationPrefix ? translationPrefix + text : text);\n }\n\n return (\n <Select.Option value={val} key={val}>\n {text}\n </Select.Option>\n );\n })}\n </Select>\n );\n }\n}"]}
1
+ {"version":3,"file":"enumValuePicker.js","sourceRoot":"","sources":["../../../../components/picker/enumValuePicker.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAc,MAAM,MAAM,CAAC;AACzC,OAAO,IAAI,MAAM,kBAAkB,CAAC;AAapC,MAAM,CAAC,OAAO,OAAO,eAAkC,SAAQ,KAAK,CAAC,SAAuC;IACxG,MAAM;QACF,MAAM,KAA6F,IAAI,CAAC,KAAK,EAAvG,EAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,EAAE,cAAc,OAAyB,EAApB,MAAM,cAAzF,2FAA0F,CAAa,CAAC;QAC9G,IAAI,WAAW,GAAyB,KAAK,CAAC;QAE9C,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,IAAI,IAAI,iBAAiB,EAAE;YACxE,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;gBAC1C,WAAW,GAAG,SAAS,CAAC;aAC3B;SACJ;QAED,OAAO,CACH,oBAAC,MAAM,kBAAI,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;gBAChB,QAAQ,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YAC/C,CAAC,IACG,MAAM,GAChB,CAAC,iBAAiB,aAAjB,iBAAiB,cAAjB,iBAAiB,GAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YAC7D,IAAI,IAAI,GAAW,GAAG,CAAC;YACvB,IAAI,cAAc,EAAE;gBAChB,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;aACpE;YAED,OAAO,CACH,oBAAC,MAAM,CAAC,MAAM,IAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAC9B,IAAI,CACO,CACnB,CAAC;QACN,CAAC,CAAC,CACG,CACZ,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from \"react\";\nimport {Select, SelectProps} from \"antd\";\nimport i18n from \"d2core/i18n/i18n\";\n\ntype EnumRepresentation<T extends string> = {[key in string]: T};\n\nexport interface EnumValuePickerProps<T extends string> extends Omit<SelectProps<T>, \"onChange\"> {\n allowedValueTypes?: T[]\n values: EnumRepresentation<T>\n translateValue?: boolean\n translationPrefix?: string\n\n onChange(value?: T): void\n}\n\nexport default class EnumValuePicker<T extends string> extends React.Component<EnumValuePickerProps<T>, any> {\n render() {\n const {value, allowedValueTypes, onChange, translationPrefix, values, translateValue, ...others} = this.props;\n let selectValue: T | null | undefined = value;\n\n if (selectValue !== undefined && selectValue !== null && allowedValueTypes) {\n if (!allowedValueTypes.includes(selectValue)) {\n selectValue = undefined;\n }\n }\n\n return (\n <Select<T> value={selectValue}\n onChange={(value) => {\n onChange(value !== \"\" ? value : undefined);\n }}\n {...others}>\n {(allowedValueTypes ?? Object.values(values) as T[]).map((val) => {\n let text: string = val;\n if (translateValue) {\n text = i18n(translationPrefix ? translationPrefix + text : text);\n }\n\n return (\n <Select.Option value={val} key={val}>\n {text}\n </Select.Option>\n );\n })}\n </Select>\n );\n }\n}"]}
@@ -257,7 +257,7 @@ export default class ScrollTo extends Component {
257
257
  }, 0);
258
258
  } },
259
259
  React.createElement("div", { style: { position: "fixed", top: 16, left: 16 } },
260
- React.createElement(Tooltip, { overlayClassName: !this.state.searchStringFound ? "search-string-not-found" : undefined, align: { points: ["tl", "tl"], overflow: { adjustX: true, adjustY: true } }, visible: !!this.state.searchString, title: this.state.searchString },
260
+ React.createElement(Tooltip, { overlayClassName: !this.state.searchStringFound ? "search-string-not-found" : undefined, align: { points: ["tl", "tl"], overflow: { adjustX: true, adjustY: true } }, open: !!this.state.searchString, title: this.state.searchString },
261
261
  React.createElement("span", null))),
262
262
  React.createElement(MarkTextContext.Provider, { value: this.state.searchString }, this.props.children)));
263
263
  }