dinocollab-core 2.2.11 → 2.2.14
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.
- package/dist/data-surface/index.js +1 -1
- package/dist/form/index.js +1 -1
- package/dist/src/data-surface/button-switch.js +1 -1
- package/dist/src/data-surface/button-switch.js.map +1 -1
- package/dist/src/data-surface/index.create.js +1 -1
- package/dist/src/data-surface/index.create.js.map +1 -1
- package/dist/src/data-surface/ui.units.js +1 -1
- package/dist/src/data-surface/ui.units.js.map +1 -1
- package/dist/src/data-surface/view-grid/hooks.js +1 -1
- package/dist/src/data-surface/view-grid/hooks.js.map +1 -1
- package/dist/src/data-surface/view-grid/index.js +1 -1
- package/dist/src/data-surface/view-grid/index.js.map +1 -1
- package/dist/src/data-surface/view-grid/styleds.js +1 -1
- package/dist/src/data-surface/view-grid/styleds.js.map +1 -1
- package/dist/src/data-surface/view-list/hooks.js +1 -1
- package/dist/src/data-surface/view-list/hooks.js.map +1 -1
- package/dist/src/data-surface/view-list/index.js +1 -1
- package/dist/src/data-surface/view-list/index.js.map +1 -1
- package/dist/src/data-surface/view-list/styled.js +1 -1
- package/dist/src/data-surface/view-list/styled.js.map +1 -1
- package/dist/src/data-surface/view-list/types.js.map +1 -1
- package/dist/src/filter-bar/components/chip-viewer.js +1 -1
- package/dist/src/filter-bar/components/chip-viewer.js.map +1 -1
- package/dist/src/filter-bar/components/filter-sort.js +1 -1
- package/dist/src/filter-bar/components/filter-sort.js.map +1 -1
- package/dist/src/filter-bar/components/filter-summary.js +1 -1
- package/dist/src/filter-bar/components/filter-summary.js.map +1 -1
- package/dist/src/filter-bar/components/{units.js → icons.js} +1 -1
- package/dist/src/filter-bar/components/{units.js.map → icons.js.map} +1 -1
- package/dist/src/filter-bar/components/popper-custom.js +1 -1
- package/dist/src/filter-bar/components/popper-custom.js.map +1 -1
- package/dist/src/filter-bar/components/ui.units.js +2 -0
- package/dist/src/filter-bar/components/ui.units.js.map +1 -0
- package/dist/src/filter-bar/index.create.js +1 -1
- package/dist/src/filter-bar/index.create.js.map +1 -1
- package/dist/src/filter-bar/index.dino.js +1 -1
- package/dist/src/filter-bar/index.dino.js.map +1 -1
- package/dist/src/filter-bar/menu/create-form-field-select-multiple.js +2 -0
- package/dist/src/filter-bar/menu/create-form-field-select-multiple.js.map +1 -0
- package/dist/src/filter-bar/menu/create-form-field-select.js +2 -0
- package/dist/src/filter-bar/menu/create-form-field-select.js.map +1 -0
- package/dist/src/filter-bar/menu/create-form-field-string.js +2 -0
- package/dist/src/filter-bar/menu/create-form-field-string.js.map +1 -0
- package/dist/src/filter-bar/menu/create.js +2 -0
- package/dist/src/filter-bar/menu/create.js.map +1 -0
- package/dist/src/form/create.date-expired.js +1 -1
- package/dist/src/form/create.date-expired.js.map +1 -1
- package/dist/src/form/create.form-base.js +1 -1
- package/dist/src/form/create.form-base.js.map +1 -1
- package/dist/src/form/create.form-grid-layout.js +1 -1
- package/dist/src/form/create.form-grid-layout.js.map +1 -1
- package/dist/src/form/create.form-grid-layout.units.js +1 -1
- package/dist/src/form/create.form-grid-layout.units.js.map +1 -1
- package/dist/src/form/create.select-simple.js +1 -1
- package/dist/src/form/create.select-simple.js.map +1 -1
- package/dist/src/form/create.select-with-api.js +1 -1
- package/dist/src/form/create.select-with-api.js.map +1 -1
- package/dist/src/form/create.text-editor.js +1 -1
- package/dist/src/form/dino-form.js.map +1 -1
- package/dist/src/form/helpers.js +1 -1
- package/dist/src/table/create.table.js +1 -1
- package/dist/src/table/create.table.js.map +1 -1
- package/dist/src/table/csv-export-helper.js +2 -0
- package/dist/src/table/csv-export-helper.js.map +1 -0
- package/dist/src/table/custom.export-button.js +2 -0
- package/dist/src/table/custom.export-button.js.map +1 -0
- package/dist/src/table/dino.js +1 -1
- package/dist/src/table/dino.js.map +1 -1
- package/dist/src/table/toolbar-pannel.js +1 -1
- package/dist/src/table/toolbar-pannel.js.map +1 -1
- package/dist/src/utils/helpers.js +1 -1
- package/dist/src/utils/helpers.js.map +1 -1
- package/dist/types/data-surface/button-switch.d.ts +1 -0
- package/dist/types/data-surface/index.create.d.ts +10 -2
- package/dist/types/data-surface/ui.units.d.ts +4 -2
- package/dist/types/data-surface/view-grid/hooks.d.ts +6 -0
- package/dist/types/data-surface/view-grid/styleds.d.ts +2 -0
- package/dist/types/data-surface/view-grid/types.d.ts +15 -3
- package/dist/types/data-surface/view-list/hooks.d.ts +6 -0
- package/dist/types/data-surface/view-list/styled.d.ts +2 -0
- package/dist/types/data-surface/view-list/types.d.ts +15 -3
- package/dist/types/data-view/dino.d.ts +1 -1
- package/dist/types/data-view/query-param-url.d.ts +1 -1
- package/dist/types/filter-bar/components/chip-viewer.d.ts +1 -3
- package/dist/types/filter-bar/components/popper-custom.d.ts +2 -2
- package/dist/types/filter-bar/components/ui.units.d.ts +22 -0
- package/dist/types/filter-bar/index.create.d.ts +1 -1
- package/dist/types/filter-bar/index.dino.d.ts +6 -0
- package/dist/types/filter-bar/menu/create-form-field-select-multiple.d.ts +13 -0
- package/dist/types/filter-bar/menu/create-form-field-select.d.ts +17 -0
- package/dist/types/filter-bar/menu/create-form-field-string.d.ts +10 -0
- package/dist/types/filter-bar/{components/filter-menu.d.ts → menu/create.d.ts} +2 -2
- package/dist/types/filter-bar/{components/filter-menu.types.d.ts → menu/types.d.ts} +6 -1
- package/dist/types/form/create.date-expired.d.ts +10 -5
- package/dist/types/form/create.form-base.d.ts +1 -0
- package/dist/types/form/create.form-grid-layout.d.ts +6 -4
- package/dist/types/form/create.form-grid-layout.units.d.ts +12 -6
- package/dist/types/form/create.select-simple.d.ts +13 -3
- package/dist/types/form/create.select-with-api.d.ts +56 -4
- package/dist/types/form/dino-form.d.ts +4 -3
- package/dist/types/form/index.d.ts +2 -1
- package/dist/types/table/csv-export-helper.d.ts +20 -0
- package/dist/types/table/custom.export-button.d.ts +8 -0
- package/dist/types/table/dino.d.ts +1 -0
- package/dist/types/table/index.d.ts +1 -0
- package/dist/types/table/toolbar-pannel.d.ts +2 -0
- package/package.json +1 -1
- package/dist/src/filter-bar/components/filter-menu.js +0 -2
- package/dist/src/filter-bar/components/filter-menu.js.map +0 -1
- package/dist/src/filter-bar/components/filter-menu.units.js +0 -2
- package/dist/src/filter-bar/components/filter-menu.units.js.map +0 -1
- package/dist/types/filter-bar/components/filter-menu.units.d.ts +0 -18
- /package/dist/types/filter-bar/components/{units.d.ts → icons.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../../src/utils/helpers.ts"],"sourcesContent":["import dayjs from 'dayjs'\r\n\r\nexport const sleep = (sec: number) => new Promise((res) => setTimeout(res, sec))\r\n\r\nexport const fetchDelay = async function <TModel>(action: () => Promise<TModel>, sec: number) {\r\n const [res] = await Promise.all([action(), sleep(sec)])\r\n return res\r\n}\r\n\r\nexport const isGuid = (value: string): boolean => {\r\n const guidRegex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/\r\n return guidRegex.test(value)\r\n}\r\n\r\nexport const isValidEmail = (value: string) => {\r\n const regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/\r\n return regex.test(value)\r\n}\r\n\r\nexport const isValidPhoneNumber = (phoneNumber?: string): boolean => {\r\n const phoneRegex = /^(\\+?\\d{1,4}[\\s-]?)?((\\(\\d{1,4}\\))|\\d{1,4})[\\s-]?\\d{1,4}[\\s-]?\\d{1,9}$/\r\n return phoneRegex.test((phoneNumber ?? '').trim())\r\n}\r\n\r\nexport const isValidURL = (url: string): boolean => {\r\n const regex = /^(https?|ftp):\\/\\/[^\\s/$.?#].[^\\s]*$/i\r\n return regex.test(url)\r\n}\r\n\r\nexport const windowScrollToTop = (options?: ScrollToOptions, delay?: number) => {\r\n setTimeout(() => {\r\n window.scrollTo({ top: 0, left: 0, behavior: 'smooth', ...options })\r\n }, delay || 50)\r\n}\r\n\r\nexport const mergeClasses = (...classes: string[]) => {\r\n return classes.join(' ')\r\n}\r\n\r\n//#region Object\r\n/**\r\n * Simple object check.\r\n * @param item\r\n * @returns {boolean}\r\n */\r\nconst isObject = (obj: any) => {\r\n return obj && typeof obj === 'object' && !Array.isArray(obj)\r\n}\r\n\r\ntype DeepPartial<T> = { [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P] } | undefined\r\n\r\nexport const mergeObjects = <T>(...objects: DeepPartial<T>[]): T => {\r\n return objects.reduce((prev, obj) => {\r\n if (!obj) return prev\r\n Object.keys(obj).forEach((key) => {\r\n if (isObject((prev as any)[key]) && isObject((obj as any)[key])) {\r\n ;(prev as any)[key] = mergeObjects((prev as any)[key], (obj as any)[key])\r\n } else {\r\n ;(prev as any)[key] = (obj as any)[key]\r\n }\r\n })\r\n return prev\r\n }, {} as T) as any\r\n}\r\n\r\nexport const cleanObject = <T extends object>(obj: T): Partial<T> => {\r\n try {\r\n if (!obj) return {}\r\n return Object.entries(obj).reduce((acc, [key, value]) => {\r\n if (value !== undefined) {\r\n ;(acc as any)[key] = value\r\n }\r\n return acc\r\n }, {} as Partial<T>)\r\n } catch (error) {\r\n return {}\r\n }\r\n}\r\n\r\nexport const deepRemoveEmptyFields = <T extends object>(obj: T): T => {\r\n if (typeof obj !== 'object' || obj === null) return obj\r\n const result: any = Array.isArray(obj) ? [] : {}\r\n Object.entries(obj).forEach(([key, value]) => {\r\n if (\r\n value === undefined ||\r\n value === null ||\r\n (typeof value === 'string' && value.trim() === '') ||\r\n (typeof value === 'number' && isNaN(value)) ||\r\n (Array.isArray(value) && value.length === 0) ||\r\n (typeof value === 'object' && !Array.isArray(value) && Object.keys(deepRemoveEmptyFields(value)).length === 0)\r\n ) {\r\n // skip\r\n } else if (typeof value === 'object' && !Array.isArray(value)) {\r\n const cleaned = deepRemoveEmptyFields(value)\r\n if (Object.keys(cleaned).length > 0) result[key] = cleaned\r\n } else {\r\n result[key] = value\r\n }\r\n })\r\n return result\r\n}\r\n//#endregion\r\n\r\nexport const encodeBase64 = (input: string): string => {\r\n try {\r\n const utf8Bytes = new TextEncoder().encode(input)\r\n let binaryString = ''\r\n utf8Bytes.forEach((byte) => {\r\n binaryString += String.fromCharCode(byte)\r\n })\r\n return btoa(binaryString)\r\n } catch (error) {\r\n console.error('Error encoding to base64', error)\r\n return ''\r\n }\r\n}\r\n\r\nexport const decodeBase64 = (encoded: string): string | undefined => {\r\n try {\r\n const binaryString = atob(encoded)\r\n const utf8Bytes = new Uint8Array(binaryString.length)\r\n for (let i = 0; i < binaryString.length; i++) {\r\n utf8Bytes[i] = binaryString.charCodeAt(i)\r\n }\r\n return new TextDecoder().decode(utf8Bytes)\r\n } catch (error) {\r\n console.error('Error decoding base64', error)\r\n return\r\n }\r\n}\r\n\r\n//#region Try Parse\r\nexport const tryParseObject = function <T>(value: any, defaultValue: T): T {\r\n try {\r\n if (!value) return defaultValue\r\n return JSON.parse(value)\r\n } catch (error) {\r\n console.log('Try Parse Object error:', error)\r\n return defaultValue\r\n }\r\n}\r\n\r\nexport const tryParseArray = function <T>(value: any, defaultValue: T[] = []): T[] {\r\n try {\r\n if (!value) return []\r\n const parseValue = JSON.parse(value)\r\n return Array.isArray(parseValue) ? parseValue : []\r\n } catch {\r\n return defaultValue\r\n }\r\n}\r\n\r\nexport const tryParseIntRequired = function (value: any, defaultValue: number): number {\r\n try {\r\n if (!value) return defaultValue\r\n return parseInt(value)\r\n } catch {\r\n return defaultValue\r\n }\r\n}\r\n\r\nexport const tryParseCsvFileToArray = (file: File): Promise<Record<string, string>[]> => {\r\n return new Promise((resolve, reject) => {\r\n const reader = new FileReader()\r\n\r\n reader.onload = () => {\r\n try {\r\n const text = reader.result as string\r\n const rows = text.split(/\\r?\\n/).filter(Boolean)\r\n\r\n if (rows.length < 1) return resolve([])\r\n\r\n const headers = rows[0].split(',').map((h) => h.trim())\r\n\r\n const data = rows.slice(1).map((row) => {\r\n const values = row.split(',').map((v) => v.trim())\r\n const item: Record<string, string> = {}\r\n\r\n headers.forEach((header, index) => {\r\n item[header] = values[index] ?? ''\r\n })\r\n\r\n return item\r\n })\r\n\r\n resolve(data)\r\n } catch (error) {\r\n resolve([])\r\n }\r\n }\r\n\r\n reader.onerror = () => {\r\n reject(new Error('Error reading file'))\r\n }\r\n\r\n reader.readAsText(file)\r\n })\r\n}\r\n//#endregion\r\n\r\n//#region Format\r\nexport const formatFileSize = (sizeInKb: number) => {\r\n if (sizeInKb < 1024) {\r\n return sizeInKb.toFixed(2) + ' Kb'\r\n } else if (sizeInKb < 1024 * 1024) {\r\n return (sizeInKb / 1024).toFixed(2) + ' Mb'\r\n } else if (sizeInKb < 1024 * 1024 * 1024) {\r\n return (sizeInKb / (1024 * 1024)).toFixed(2) + ' Gb'\r\n } else {\r\n return (sizeInKb / (1024 * 1024 * 1024)).toFixed(2) + ' Tb'\r\n }\r\n}\r\n\r\nexport const formatDuration = (duration?: number): string => {\r\n const isNotValidDuration = duration === undefined || duration === null\r\n const isNotNumber = typeof duration === 'string' && isNaN(Number(duration))\r\n if (isNotValidDuration || isNotNumber) return '00:00:00'\r\n\r\n // Round the duration to the nearest second\r\n const totalSeconds = Math.round(duration)\r\n\r\n // Calculate hours, minutes, and seconds\r\n const hours = Math.floor(totalSeconds / 3600)\r\n const minutes = Math.floor((totalSeconds % 3600) / 60)\r\n const seconds = totalSeconds % 60\r\n\r\n // Format each component to ensure it has two digits\r\n const hoursString = String(hours).padStart(2, '0')\r\n const minutesString = String(minutes).padStart(2, '0')\r\n const secondsString = String(seconds).padStart(2, '0')\r\n\r\n // Combine the components into a single string\r\n return `${hoursString}:${minutesString}:${secondsString}`\r\n}\r\n\r\nexport const formatCurrency = (value?: any, prefix = '$ ', suffix = ''): string => {\r\n let parsedValue\r\n try {\r\n parsedValue = parseFloat(value)\r\n if (isNaN(parsedValue)) parsedValue = 0\r\n } catch (e) {\r\n parsedValue = 0\r\n }\r\n const roundedValue = parsedValue.toFixed(2)\r\n const [integerPart, decimalPart] = roundedValue.split('.')\r\n const formattedIntegerPart = integerPart.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ' ')\r\n\r\n let formattedValue = formattedIntegerPart\r\n if (decimalPart !== '00') {\r\n formattedValue = `${formattedIntegerPart}.${decimalPart}`\r\n }\r\n return `${prefix}${formattedValue}${suffix}`\r\n}\r\n\r\nexport const formatNumberWithCommas = (number: number): string => {\r\n return number.toLocaleString('en-US')\r\n}\r\n\r\nexport const formatCapitalizeFirstText = (value: string = '') => {\r\n if (!value) return value\r\n const [first, ...data] = Array.from(value)\r\n return `${first.toUpperCase()}${data.join('')}`\r\n}\r\n\r\nexport type FormatDatetimeStyle = 'style1' | 'style2' | 'style3'\r\n\r\nexport const formatDatetimeStyles: Record<FormatDatetimeStyle, string> = {\r\n style1: 'DD/MM/YYYY HH:mm',\r\n style2: 'MMMM D, YYYY',\r\n style3: 'MM-DD-YYYY'\r\n}\r\n\r\n/**\r\n * Formats a datetime string using one of the predefined styles or a custom format string.\r\n *\r\n * Available format styles:\r\n * - style1: DD/MM/YYYY HH:mm → e.g., '25/04/2025 14:30'\r\n * - style2: MMMM D, YYYY → e.g., 'April 25, 2025'\r\n * - style3: MM-DD-YYYY → e.g., '04-25-2025'\r\n * - Or any custom dayjs format string → e.g., 'YYYY-MM-DD', 'HH:mm:ss'\r\n *\r\n * @param value - A datetime string (ISO format or any format parsable by dayjs).\r\n * @param format - Format style key ('style1', 'style2', 'style3') or custom dayjs format string. Defaults to 'style1'.\r\n * @returns A formatted datetime string, or 'unknown' if the input is invalid or unparsable.\r\n */\r\nexport const formatDatetime = (value: string, format: FormatDatetimeStyle | (string & {}) = 'style1'): string => {\r\n try {\r\n if (!value) throw new Error()\r\n const finalFormat = formatDatetimeStyles[format as FormatDatetimeStyle] ?? format\r\n return dayjs(value).format(finalFormat)\r\n } catch (error) {\r\n return 'unknown'\r\n }\r\n}\r\n//#endregion\r\n"],"names":["sleep","sec","Promise","res","setTimeout","fetchDelay","_ref","_asyncToGenerator","_regenerator","m","_callee","action","_yield$Promise$all","_yield$Promise$all2","w","_context","n","all","v","_slicedToArray","a","_x","_x2","apply","this","arguments","isGuid","value","test","isValidEmail","isValidPhoneNumber","phoneNumber","trim","isValidURL","url","windowScrollToTop","options","delay","window","scrollTo","_objectSpread","top","left","behavior","mergeClasses","_len","length","classes","Array","_key","join","isObject","obj","_typeof","isArray","mergeObjects","_len2","objects","_key2","reduce","prev","Object","keys","forEach","key","cleanObject","entries","acc","_ref2","_ref3","undefined","error","deepRemoveEmptyFields","result","_ref4","_ref5","isNaN","cleaned","encodeBase64","input","utf8Bytes","TextEncoder","encode","binaryString","byte","String","fromCharCode","btoa","console","decodeBase64","encoded","atob","Uint8Array","i","charCodeAt","TextDecoder","decode","tryParseObject","defaultValue","JSON","parse","log","tryParseArray","parseValue","_unused","tryParseIntRequired","parseInt","_unused2","tryParseCsvFileToArray","file","resolve","reject","reader","FileReader","onload","rows","split","filter","Boolean","headers","map","h","data","slice","row","values","item","header","index","_values$index","onerror","Error","readAsText","formatFileSize","sizeInKb","toFixed","formatDuration","duration","isNotValidDuration","isNotNumber","Number","totalSeconds","Math","round","hours","floor","minutes","seconds","hoursString","padStart","minutesString","secondsString","concat","formatCurrency","parsedValue","prefix","suffix","parseFloat","e","_roundedValue$split","_roundedValue$split2","integerPart","decimalPart","formattedIntegerPart","replace","formattedValue","formatNumberWithCommas","number","toLocaleString","formatCapitalizeFirstText","_Array$from","from","_Array$from2","_toArray","first","_arrayLikeToArray","toUpperCase","formatDatetimeStyles","style1","style2","style3","formatDatetime","format","_formatDatetimeStyles","finalFormat","dayjs"],"mappings":"8MAEaA,EAAQ,SAACC,GAAW,OAAK,IAAIC,QAAQ,SAACC,GAAG,OAAKC,WAAWD,EAAKF,IAAK,EAEnEI,EAAU,WAAA,IAAAC,EAAAC,EAAAC,IAAAC,EAAG,SAAAC,EAAwBC,EAA+BV,GAAW,IAAAW,EAAAC,EAAAV,EAAA,OAAAK,IAAAM,EAAA,SAAAC,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../../../src/utils/helpers.ts"],"sourcesContent":["import dayjs from 'dayjs'\r\n\r\nexport const sleep = (sec: number) => new Promise((res) => setTimeout(res, sec))\r\n\r\nexport const fetchDelay = async function <TModel>(action: () => Promise<TModel>, sec: number) {\r\n const [res] = await Promise.all([action(), sleep(sec)])\r\n return res\r\n}\r\n\r\nexport const isGuid = (value: string): boolean => {\r\n const guidRegex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/\r\n return guidRegex.test(value)\r\n}\r\n\r\nexport const isValidEmail = (value: string) => {\r\n const regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/\r\n return regex.test(value)\r\n}\r\n\r\nexport const isValidPhoneNumber = (phoneNumber?: string): boolean => {\r\n const phoneRegex = /^(\\+?\\d{1,4}[\\s-]?)?((\\(\\d{1,4}\\))|\\d{1,4})[\\s-]?\\d{1,4}[\\s-]?\\d{1,9}$/\r\n return phoneRegex.test((phoneNumber ?? '').trim())\r\n}\r\n\r\nexport const isValidURL = (url: string): boolean => {\r\n const regex = /^(https?|ftp):\\/\\/[^\\s/$.?#].[^\\s]*$/i\r\n return regex.test(url)\r\n}\r\n\r\nexport const windowScrollToTop = (options?: ScrollToOptions, delay?: number) => {\r\n setTimeout(() => {\r\n window.scrollTo({ top: 0, left: 0, behavior: 'smooth', ...options })\r\n }, delay || 50)\r\n}\r\n\r\nexport const mergeClasses = (...classes: string[]) => {\r\n return classes.join(' ')\r\n}\r\n\r\n//#region Object\r\n/**\r\n * Simple object check.\r\n * @param item\r\n * @returns {boolean}\r\n */\r\nconst isObject = (obj: any) => {\r\n return obj && typeof obj === 'object' && !Array.isArray(obj)\r\n}\r\n\r\ntype DeepPartial<T> = { [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P] } | undefined\r\n\r\nexport const mergeObjects = <T>(...objects: DeepPartial<T>[]): T => {\r\n return objects.reduce((prev, obj) => {\r\n if (!obj) return prev\r\n Object.keys(obj).forEach((key) => {\r\n if (isObject((prev as any)[key]) && isObject((obj as any)[key])) {\r\n ;(prev as any)[key] = mergeObjects((prev as any)[key], (obj as any)[key])\r\n } else {\r\n ;(prev as any)[key] = (obj as any)[key]\r\n }\r\n })\r\n return prev\r\n }, {} as T) as any\r\n}\r\n\r\nexport const cleanObject = <T extends object>(obj: T): Partial<T> => {\r\n try {\r\n if (!obj) return {}\r\n return Object.entries(obj).reduce((acc, [key, value]) => {\r\n if (value !== undefined) {\r\n ;(acc as any)[key] = value\r\n }\r\n return acc\r\n }, {} as Partial<T>)\r\n } catch (error) {\r\n return {}\r\n }\r\n}\r\n\r\nexport const deepRemoveEmptyFields = <T extends object>(obj: T): T => {\r\n if (typeof obj !== 'object' || obj === null) return obj\r\n const result: any = Array.isArray(obj) ? [] : {}\r\n Object.entries(obj).forEach(([key, value]) => {\r\n if (\r\n value === undefined ||\r\n value === null ||\r\n (typeof value === 'string' && value.trim() === '') ||\r\n (typeof value === 'number' && isNaN(value)) ||\r\n (Array.isArray(value) && value.length === 0) ||\r\n (typeof value === 'object' && !Array.isArray(value) && Object.keys(deepRemoveEmptyFields(value)).length === 0)\r\n ) {\r\n // skip\r\n } else if (typeof value === 'object' && !Array.isArray(value)) {\r\n const cleaned = deepRemoveEmptyFields(value)\r\n if (Object.keys(cleaned).length > 0) result[key] = cleaned\r\n } else {\r\n result[key] = value\r\n }\r\n })\r\n return result\r\n}\r\n//#endregion\r\n\r\nexport const encodeBase64 = (input: string): string => {\r\n try {\r\n const utf8Bytes = new TextEncoder().encode(input)\r\n let binaryString = ''\r\n utf8Bytes.forEach((byte) => {\r\n binaryString += String.fromCharCode(byte)\r\n })\r\n return btoa(binaryString)\r\n } catch (error) {\r\n console.error('Error encoding to base64', error)\r\n return ''\r\n }\r\n}\r\n\r\nexport const decodeBase64 = (encoded: string): string | undefined => {\r\n try {\r\n const binaryString = atob(encoded)\r\n const utf8Bytes = new Uint8Array(binaryString.length)\r\n for (let i = 0; i < binaryString.length; i++) {\r\n utf8Bytes[i] = binaryString.charCodeAt(i)\r\n }\r\n return new TextDecoder().decode(utf8Bytes)\r\n } catch (error) {\r\n console.error('Error decoding base64', error)\r\n return\r\n }\r\n}\r\n\r\n//#region Try Parse\r\nexport const tryParseObject = function <T>(value: any, defaultValue: T): T {\r\n try {\r\n if (!value) return defaultValue\r\n return JSON.parse(value)\r\n } catch {\r\n return defaultValue\r\n }\r\n}\r\n\r\nexport const tryParseArray = function <T>(value: any, defaultValue: T[] = []): T[] {\r\n try {\r\n if (!value) return []\r\n const parseValue = JSON.parse(value)\r\n return Array.isArray(parseValue) ? parseValue : []\r\n } catch {\r\n return defaultValue\r\n }\r\n}\r\n\r\nexport const tryParseIntRequired = function (value: any, defaultValue: number): number {\r\n try {\r\n if (!value) return defaultValue\r\n return parseInt(value)\r\n } catch {\r\n return defaultValue\r\n }\r\n}\r\n\r\nexport const tryParseCsvFileToArray = (file: File): Promise<Record<string, string>[]> => {\r\n return new Promise((resolve, reject) => {\r\n const reader = new FileReader()\r\n\r\n reader.onload = () => {\r\n try {\r\n const text = reader.result as string\r\n const rows = text.split(/\\r?\\n/).filter(Boolean)\r\n\r\n if (rows.length < 1) return resolve([])\r\n\r\n const headers = rows[0].split(',').map((h) => h.trim())\r\n\r\n const data = rows.slice(1).map((row) => {\r\n const values = row.split(',').map((v) => v.trim())\r\n const item: Record<string, string> = {}\r\n\r\n headers.forEach((header, index) => {\r\n item[header] = values[index] ?? ''\r\n })\r\n\r\n return item\r\n })\r\n\r\n resolve(data)\r\n } catch (error) {\r\n resolve([])\r\n }\r\n }\r\n\r\n reader.onerror = () => {\r\n reject(new Error('Error reading file'))\r\n }\r\n\r\n reader.readAsText(file)\r\n })\r\n}\r\n//#endregion\r\n\r\n//#region Format\r\nexport const formatFileSize = (sizeInKb: number) => {\r\n if (sizeInKb < 1024) {\r\n return sizeInKb.toFixed(2) + ' Kb'\r\n } else if (sizeInKb < 1024 * 1024) {\r\n return (sizeInKb / 1024).toFixed(2) + ' Mb'\r\n } else if (sizeInKb < 1024 * 1024 * 1024) {\r\n return (sizeInKb / (1024 * 1024)).toFixed(2) + ' Gb'\r\n } else {\r\n return (sizeInKb / (1024 * 1024 * 1024)).toFixed(2) + ' Tb'\r\n }\r\n}\r\n\r\nexport const formatDuration = (duration?: number): string => {\r\n const isNotValidDuration = duration === undefined || duration === null\r\n const isNotNumber = typeof duration === 'string' && isNaN(Number(duration))\r\n if (isNotValidDuration || isNotNumber) return '00:00:00'\r\n\r\n // Round the duration to the nearest second\r\n const totalSeconds = Math.round(duration)\r\n\r\n // Calculate hours, minutes, and seconds\r\n const hours = Math.floor(totalSeconds / 3600)\r\n const minutes = Math.floor((totalSeconds % 3600) / 60)\r\n const seconds = totalSeconds % 60\r\n\r\n // Format each component to ensure it has two digits\r\n const hoursString = String(hours).padStart(2, '0')\r\n const minutesString = String(minutes).padStart(2, '0')\r\n const secondsString = String(seconds).padStart(2, '0')\r\n\r\n // Combine the components into a single string\r\n return `${hoursString}:${minutesString}:${secondsString}`\r\n}\r\n\r\nexport const formatCurrency = (value?: any, prefix = '$ ', suffix = ''): string => {\r\n let parsedValue\r\n try {\r\n parsedValue = parseFloat(value)\r\n if (isNaN(parsedValue)) parsedValue = 0\r\n } catch (e) {\r\n parsedValue = 0\r\n }\r\n const roundedValue = parsedValue.toFixed(2)\r\n const [integerPart, decimalPart] = roundedValue.split('.')\r\n const formattedIntegerPart = integerPart.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ' ')\r\n\r\n let formattedValue = formattedIntegerPart\r\n if (decimalPart !== '00') {\r\n formattedValue = `${formattedIntegerPart}.${decimalPart}`\r\n }\r\n return `${prefix}${formattedValue}${suffix}`\r\n}\r\n\r\nexport const formatNumberWithCommas = (number: number): string => {\r\n return number.toLocaleString('en-US')\r\n}\r\n\r\nexport const formatCapitalizeFirstText = (value: string = '') => {\r\n if (!value) return value\r\n const [first, ...data] = Array.from(value)\r\n return `${first.toUpperCase()}${data.join('')}`\r\n}\r\n\r\nexport type FormatDatetimeStyle = 'style1' | 'style2' | 'style3'\r\n\r\nexport const formatDatetimeStyles: Record<FormatDatetimeStyle, string> = {\r\n style1: 'DD/MM/YYYY HH:mm',\r\n style2: 'MMMM D, YYYY',\r\n style3: 'MM-DD-YYYY'\r\n}\r\n\r\n/**\r\n * Formats a datetime string using one of the predefined styles or a custom format string.\r\n *\r\n * Available format styles:\r\n * - style1: DD/MM/YYYY HH:mm → e.g., '25/04/2025 14:30'\r\n * - style2: MMMM D, YYYY → e.g., 'April 25, 2025'\r\n * - style3: MM-DD-YYYY → e.g., '04-25-2025'\r\n * - Or any custom dayjs format string → e.g., 'YYYY-MM-DD', 'HH:mm:ss'\r\n *\r\n * @param value - A datetime string (ISO format or any format parsable by dayjs).\r\n * @param format - Format style key ('style1', 'style2', 'style3') or custom dayjs format string. Defaults to 'style1'.\r\n * @returns A formatted datetime string, or 'unknown' if the input is invalid or unparsable.\r\n */\r\nexport const formatDatetime = (value: string, format: FormatDatetimeStyle | (string & {}) = 'style1'): string => {\r\n try {\r\n if (!value) throw new Error()\r\n const finalFormat = formatDatetimeStyles[format as FormatDatetimeStyle] ?? format\r\n return dayjs(value).format(finalFormat)\r\n } catch (error) {\r\n return 'unknown'\r\n }\r\n}\r\n//#endregion\r\n"],"names":["sleep","sec","Promise","res","setTimeout","fetchDelay","_ref","_asyncToGenerator","_regenerator","m","_callee","action","_yield$Promise$all","_yield$Promise$all2","w","_context","n","all","v","_slicedToArray","a","_x","_x2","apply","this","arguments","isGuid","value","test","isValidEmail","isValidPhoneNumber","phoneNumber","trim","isValidURL","url","windowScrollToTop","options","delay","window","scrollTo","_objectSpread","top","left","behavior","mergeClasses","_len","length","classes","Array","_key","join","isObject","obj","_typeof","isArray","mergeObjects","_len2","objects","_key2","reduce","prev","Object","keys","forEach","key","cleanObject","entries","acc","_ref2","_ref3","undefined","error","deepRemoveEmptyFields","result","_ref4","_ref5","isNaN","cleaned","encodeBase64","input","utf8Bytes","TextEncoder","encode","binaryString","byte","String","fromCharCode","btoa","console","decodeBase64","encoded","atob","Uint8Array","i","charCodeAt","TextDecoder","decode","tryParseObject","defaultValue","JSON","parse","_unused","tryParseArray","parseValue","_unused2","tryParseIntRequired","parseInt","_unused3","tryParseCsvFileToArray","file","resolve","reject","reader","FileReader","onload","rows","split","filter","Boolean","headers","map","h","data","slice","row","values","item","header","index","_values$index","onerror","Error","readAsText","formatFileSize","sizeInKb","toFixed","formatDuration","duration","isNotValidDuration","isNotNumber","Number","totalSeconds","Math","round","hours","floor","minutes","seconds","hoursString","padStart","minutesString","secondsString","concat","formatCurrency","parsedValue","prefix","suffix","parseFloat","e","_roundedValue$split","_roundedValue$split2","integerPart","decimalPart","formattedIntegerPart","replace","formattedValue","formatNumberWithCommas","number","toLocaleString","formatCapitalizeFirstText","_Array$from","from","_Array$from2","_toArray","first","_arrayLikeToArray","toUpperCase","formatDatetimeStyles","style1","style2","style3","formatDatetime","format","_formatDatetimeStyles","finalFormat","dayjs"],"mappings":"8MAEaA,EAAQ,SAACC,GAAW,OAAK,IAAIC,QAAQ,SAACC,GAAG,OAAKC,WAAWD,EAAKF,IAAK,EAEnEI,EAAU,WAAA,IAAAC,EAAAC,EAAAC,IAAAC,EAAG,SAAAC,EAAwBC,EAA+BV,GAAW,IAAAW,EAAAC,EAAAV,EAAA,OAAAK,IAAAM,EAAA,SAAAC,GAAA,cAAAA,EAAAC,GAAA,KAAA,EAAA,OAAAD,EAAAC,EAAA,EACtEd,QAAQe,IAAI,CAACN,IAAUX,EAAMC,KAAM,KAAA,EAA7C,OAA6CW,EAAAG,EAAAG,EAAAL,EAAAM,EAAAP,EAAA,GAAhDT,EAAGU,EAAA,GAAAE,EAAAK,EAAA,EACHjB,GAAG,EAAAO,MACX,OAAA,SAHsBW,EAAAC,GAAA,OAAAhB,EAAAiB,MAAAC,KAAAC,UAAA,CAAA,CAAA,GAKVC,EAAS,SAACC,GAErB,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X,OAAIU,IAE9CV,GAAAA,OAAUG,GAAMH,OAAGa,GAAcb,OAAGI,EACtC,EAEaU,EAAyB,SAACC,GACrC,OAAOA,EAAOC,eAAe,QAC/B,EAEaC,EAA4B,WAAuB,IAAtB9I,EAAgBF,UAAAqB,OAAA,QAAAwB,IAAA7C,UAAA,GAAAA,UAAA,GAAA,GACxD,IAAKE,EAAO,OAAOA,EACnB,IAAA+I,EAAyB1H,MAAM2H,KAAKhJ,GAAMiJ,EAAAC,EAAAH,GAAnCI,EAAKF,EAAA,GAAKlD,EAAIqD,EAAAH,GAAAjD,MAAA,GACrB,MAAA,GAAA6B,OAAUsB,EAAME,eAAaxB,OAAG9B,EAAKxE,KAAK,IAC5C,EAIa+H,EAA4D,CACvEC,OAAQ,mBACRC,OAAQ,eACRC,OAAQ,cAgBGC,EAAiB,SAAC1J,GAAiF,IAAlE2J,EAAA7J,UAAAqB,OAAA,QAAAwB,IAAA7C,UAAA,GAAAA,UAAA,GAA8C,SAC1F,IAAI,IAAA8J,EACF,IAAK5J,EAAO,MAAM,IAAIwG,MACtB,IAAMqD,EAAiED,QAAtDA,EAAGN,EAAqBK,UAA8BC,IAAAA,EAAAA,EAAID,EAC3E,OAAOG,EAAM9J,GAAO2J,OAAOE,EAC5B,CAAC,MAAOjH,GACP,MAAO,SACR,CACH"}
|
|
@@ -4,7 +4,15 @@ import type { ComponentType, FC } from 'react';
|
|
|
4
4
|
import type { IViewGridConfig, IViewGridProps } from './view-grid/types';
|
|
5
5
|
import type { TPagination, TDataSurfaceState, TRenderableNode } from './types';
|
|
6
6
|
import type { IViewListConfig, IViewListProps } from './view-list';
|
|
7
|
-
export interface IDataSurfaceSlots {
|
|
7
|
+
export interface IDataSurfaceSlots<T> {
|
|
8
|
+
listViewProps?: IViewListProps<T>;
|
|
9
|
+
gridViewProps?: IViewGridProps<T>;
|
|
10
|
+
PanelLoading?: ComponentType<{
|
|
11
|
+
viewMode: DataSurfaceViewMode;
|
|
12
|
+
}>;
|
|
13
|
+
PanelNoData?: ComponentType<{
|
|
14
|
+
viewMode: DataSurfaceViewMode;
|
|
15
|
+
}>;
|
|
8
16
|
footer?: {
|
|
9
17
|
status?: TRenderableNode;
|
|
10
18
|
range?: TRenderableNode;
|
|
@@ -39,7 +47,7 @@ export interface IDataSurfaceProps<T> {
|
|
|
39
47
|
/** Load orchestration mode. @default 'pagination' */
|
|
40
48
|
loadMode?: LoadingModeRule;
|
|
41
49
|
sx?: BoxProps['sx'];
|
|
42
|
-
slots?: IDataSurfaceSlots
|
|
50
|
+
slots?: IDataSurfaceSlots<T>;
|
|
43
51
|
/** Enable row selection with checkboxes (List view only). */
|
|
44
52
|
selectable?: boolean;
|
|
45
53
|
/** Array of selected row IDs (List view only). */
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { FC } from 'react';
|
|
2
2
|
import type { BoxProps } from '@mui/material';
|
|
3
|
-
import { TRenderableNode } from './types';
|
|
4
|
-
export declare const PanelLoading: FC<BoxProps
|
|
3
|
+
import { DataSurfaceViewMode, TRenderableNode } from './types';
|
|
4
|
+
export declare const PanelLoading: FC<BoxProps & {
|
|
5
|
+
viewMode: DataSurfaceViewMode;
|
|
6
|
+
}>;
|
|
5
7
|
export declare const PanelError: FC<{
|
|
6
8
|
error: string;
|
|
7
9
|
}>;
|
|
@@ -6,4 +6,10 @@ export declare const useMergedConfig: <T>(props: IViewGridProps<T>, config: IVie
|
|
|
6
6
|
scrollingThreshold: number;
|
|
7
7
|
sizes: Partial<Record<import("./types").TGridSize, number>>;
|
|
8
8
|
Component: import("react").FC<import("./types").IViewGridItemProps<any>> | import("react").ComponentType<import("./types").IViewGridItemProps<T>>;
|
|
9
|
+
normalOptions: {
|
|
10
|
+
autoHeight: boolean;
|
|
11
|
+
} & import("./types").IViewGridNormalOptions;
|
|
12
|
+
virtualizedOptions: {
|
|
13
|
+
overscan: number;
|
|
14
|
+
} & import("./types").IViewGridVirtualizedOptions;
|
|
9
15
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
|
-
import type { RenderStrategyRule, TGetterId } from '../types';
|
|
2
|
+
import type { DataSurfaceFeatureMode, RenderStrategyRule, TGetterId } from '../types';
|
|
3
3
|
export type TGridSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
4
4
|
export type TGridSizes = Partial<Record<TGridSize, number>>;
|
|
5
5
|
/**
|
|
@@ -12,6 +12,14 @@ export interface IViewGridItemProps<T> {
|
|
|
12
12
|
/** Zero-based position of this item in the data array. */
|
|
13
13
|
index: number;
|
|
14
14
|
}
|
|
15
|
+
export interface IViewGridNormalOptions {
|
|
16
|
+
/** When true, the grid will automatically adjust its height to fit all items. @default false */
|
|
17
|
+
autoHeight?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface IViewGridVirtualizedOptions {
|
|
20
|
+
/** Number of extra rows rendered outside the viewport as a buffer when using virtualized rendering. @default 6 */
|
|
21
|
+
overscan?: number;
|
|
22
|
+
}
|
|
15
23
|
export interface IViewGridBase<T> {
|
|
16
24
|
/** Spacing between grid items in pixels. @default 8 */
|
|
17
25
|
spacing?: number;
|
|
@@ -26,8 +34,10 @@ export interface IViewGridBase<T> {
|
|
|
26
34
|
*/
|
|
27
35
|
renderStrategy?: RenderStrategyRule;
|
|
28
36
|
Component?: ComponentType<IViewGridItemProps<T>>;
|
|
29
|
-
/**
|
|
30
|
-
|
|
37
|
+
/** Options specific to normal rendering strategy. */
|
|
38
|
+
normalOptions?: IViewGridNormalOptions;
|
|
39
|
+
/** Options specific to virtualized rendering strategy. */
|
|
40
|
+
virtualizedOptions?: IViewGridVirtualizedOptions;
|
|
31
41
|
}
|
|
32
42
|
export interface IViewGridConfig<T> extends IViewGridBase<T> {
|
|
33
43
|
getterId: TGetterId<T>;
|
|
@@ -36,6 +46,8 @@ export interface IViewGridProps<T> extends IViewGridBase<T> {
|
|
|
36
46
|
value: T[];
|
|
37
47
|
/** Called when user scrolls near the bottom of the list. Use this to trigger pagination or infinity load. */
|
|
38
48
|
onNearEnd?: () => void;
|
|
49
|
+
/** Feature mode for the data surface. */
|
|
50
|
+
featureMode?: DataSurfaceFeatureMode;
|
|
39
51
|
/** When this value changes, the scroll position resets to top (virtualized mode only). */
|
|
40
52
|
scrollResetToken?: unknown;
|
|
41
53
|
}
|
|
@@ -7,6 +7,12 @@ export declare function useMergedConfig<T>(config: IViewListConfig<T>, props: IV
|
|
|
7
7
|
rowHeight: number;
|
|
8
8
|
cellPadding: string;
|
|
9
9
|
rowSpacing: number;
|
|
10
|
+
normalOptions: {
|
|
11
|
+
autoHeight: boolean;
|
|
12
|
+
} & import("./types").IViewListNormalOptions;
|
|
13
|
+
virtualizedOptions: {
|
|
14
|
+
overscan: number;
|
|
15
|
+
} & import("./types").IViewListVirtualizedOptions;
|
|
10
16
|
rootStyle: CSSProperties;
|
|
11
17
|
};
|
|
12
18
|
/**
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
export declare const VIEW_LIST_ROW_SPACING_VAR = "--DinoViewList-rowSpacing";
|
|
3
3
|
export declare const viewListClasses: {
|
|
4
4
|
root: string;
|
|
5
|
+
normal: string;
|
|
5
6
|
virtualized: string;
|
|
7
|
+
autoHeight: string;
|
|
6
8
|
scrollContainer: string;
|
|
7
9
|
table: string;
|
|
8
10
|
tableHeader: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import { RenderStrategyRule, TGetterId } from '../types';
|
|
2
|
+
import { DataSurfaceFeatureMode, RenderStrategyRule, TGetterId } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Props received by the custom render function for each row in List view.
|
|
5
5
|
* @template T - The shape of a single data row object.
|
|
@@ -64,6 +64,14 @@ export declare const ListDensity: {
|
|
|
64
64
|
readonly comfortable: "comfortable";
|
|
65
65
|
};
|
|
66
66
|
export type ListDensity = keyof typeof ListDensity;
|
|
67
|
+
export interface IViewListNormalOptions {
|
|
68
|
+
/** When true, the list will automatically adjust its height to fit all items. @default false */
|
|
69
|
+
autoHeight?: boolean;
|
|
70
|
+
}
|
|
71
|
+
export interface IViewListVirtualizedOptions {
|
|
72
|
+
/** Number of extra rows rendered outside the viewport as a buffer when using virtualized rendering. @default 6 */
|
|
73
|
+
overscan?: number;
|
|
74
|
+
}
|
|
67
75
|
/** Base configuration for List view. */
|
|
68
76
|
export interface IViewListBase<T> {
|
|
69
77
|
/** Custom render function for list rows. If not provided, a default row layout will be used. */
|
|
@@ -81,8 +89,10 @@ export interface IViewListBase<T> {
|
|
|
81
89
|
renderStrategy?: RenderStrategyRule;
|
|
82
90
|
/** Enable row selection with checkboxes. */
|
|
83
91
|
selectable?: boolean;
|
|
84
|
-
/**
|
|
85
|
-
|
|
92
|
+
/** Options specific to normal rendering strategy. */
|
|
93
|
+
normalOptions?: IViewListNormalOptions;
|
|
94
|
+
/** Options specific to virtualized rendering strategy. */
|
|
95
|
+
virtualizedOptions?: IViewListVirtualizedOptions;
|
|
86
96
|
}
|
|
87
97
|
/** Configuration for List view. */
|
|
88
98
|
export interface IViewListConfig<T> extends IViewListBase<T> {
|
|
@@ -99,6 +109,8 @@ export interface IViewListProps<T> extends IViewListBase<T> {
|
|
|
99
109
|
selectedIds?: (string | number)[];
|
|
100
110
|
/** Callback when selection changes. */
|
|
101
111
|
onSelectionChange?: (selectedIds: (string | number)[]) => void;
|
|
112
|
+
/** Feature mode for the data surface. */
|
|
113
|
+
featureMode?: DataSurfaceFeatureMode;
|
|
102
114
|
/** When this value changes, the scroll position resets to top (virtualized mode only). */
|
|
103
115
|
scrollResetToken?: unknown;
|
|
104
116
|
}
|
|
@@ -22,7 +22,7 @@ declare class DinoDataViewBase {
|
|
|
22
22
|
seedKey: string;
|
|
23
23
|
} | null;
|
|
24
24
|
getSeedKeyFromURL: <T>(params: import("./query-param-url").IViewDataHandlerParams<T, "defaultSeedKey">) => string;
|
|
25
|
-
syncViewModeToURL: <T>(params: import("./query-param-url").IViewDataHandlerParams<T, "
|
|
25
|
+
syncViewModeToURL: <T>(params: import("./query-param-url").IViewDataHandlerParams<T, "viewMode" | "defaultViewMode">) => void;
|
|
26
26
|
getViewModeFromURL: <T>(params: import("./query-param-url").IViewDataHandlerParams<T, "defaultViewMode">) => import("./view-mode.types").EViewMode | undefined;
|
|
27
27
|
convertFilterToQueryParam: <T>(filterState?: import("./types").IFilterState<T> | undefined) => string;
|
|
28
28
|
formatterDate: (value: any, options?: IFormatterDateOptions) => string;
|
|
@@ -21,6 +21,6 @@ export declare const getQueryFromURL: <T>(params: IViewDataHandlerParams<T, "def
|
|
|
21
21
|
seedKey: string;
|
|
22
22
|
} | null;
|
|
23
23
|
export declare const getSeedKeyFromURL: <T>(params: IViewDataHandlerParams<T, "defaultSeedKey">) => string;
|
|
24
|
-
export declare const syncViewModeToURL: <T>(params: IViewDataHandlerParams<T, "
|
|
24
|
+
export declare const syncViewModeToURL: <T>(params: IViewDataHandlerParams<T, "viewMode" | "defaultViewMode">) => void;
|
|
25
25
|
export declare const getViewModeFromURL: <T>(params: IViewDataHandlerParams<T, "defaultViewMode">) => EViewMode | undefined;
|
|
26
26
|
export declare const convertFilterToQueryParam: <T>(filterState?: IFilterState<T> | undefined) => string;
|
|
@@ -22,7 +22,5 @@ interface IChipViewerProps<T> {
|
|
|
22
22
|
enableMinimalesticView?: boolean;
|
|
23
23
|
sx?: SxProps<Theme>;
|
|
24
24
|
}
|
|
25
|
-
export declare function createChipViewers<T>():
|
|
26
|
-
Group: FC<IChipViewerProps<T>>;
|
|
27
|
-
};
|
|
25
|
+
export declare function createChipViewers<T>(): FC<IChipViewerProps<T>>;
|
|
28
26
|
export {};
|
|
@@ -22,6 +22,6 @@ export interface PopperContentProps extends BoxProps {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
export declare const PopperContent: FC<PopperContentProps>;
|
|
25
|
-
export declare const PopperFooter: FC<Required<PropsWithChildren>>;
|
|
26
|
-
export declare const PopperBody: FC<Required<PropsWithChildren>>;
|
|
25
|
+
export declare const PopperFooter: FC<BoxProps & Required<PropsWithChildren>>;
|
|
26
|
+
export declare const PopperBody: FC<BoxProps & Required<PropsWithChildren>>;
|
|
27
27
|
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { ToggleButtonGroupProps } from '@mui/material';
|
|
3
|
+
import type { TLogic } from '../types';
|
|
4
|
+
interface IFilterMenuNoFieldProps {
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const FilterMenuNoField: FC<IFilterMenuNoFieldProps>;
|
|
8
|
+
export declare const ButtonBack: import("@emotion/styled").StyledComponent<import("@mui/material").IconButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
9
|
+
ref?: ((instance: HTMLButtonElement | null) => void) | import("react").RefObject<HTMLButtonElement> | null | undefined;
|
|
10
|
+
}, "classes" | "className" | "style" | "children" | "sx" | "tabIndex" | "color" | "action" | "disabled" | "size" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "edge"> & {
|
|
11
|
+
component?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
12
|
+
} & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
13
|
+
export declare const ChipDark: import("@emotion/styled").StyledComponent<import("@mui/material").ChipOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
14
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
15
|
+
}, "classes" | "className" | "style" | "children" | "sx" | "variant" | "label" | "tabIndex" | "color" | "icon" | "disabled" | "size" | "clickable" | "avatar" | "deleteIcon" | "onDelete" | "skipFocusWhenDisabled"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
16
|
+
export interface FilterLogicToggleProps {
|
|
17
|
+
value?: TLogic;
|
|
18
|
+
onChange?: (event: React.MouseEvent<HTMLElement>, value: TLogic) => void;
|
|
19
|
+
sx?: ToggleButtonGroupProps['sx'];
|
|
20
|
+
}
|
|
21
|
+
export declare const FilterLogicToggle: FC<FilterLogicToggleProps>;
|
|
22
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BoxProps } from '@mui/material';
|
|
2
2
|
import type { ComponentType, FC } from 'react';
|
|
3
3
|
import type { TFilterState } from './types';
|
|
4
|
-
import type { IFilterMenuConfig, IFilterMenuProps } from './
|
|
4
|
+
import type { IFilterMenuConfig, IFilterMenuProps } from './menu/types';
|
|
5
5
|
import type { IFilterSortConfig, IFilterSortProps } from './components/filter-sort.types';
|
|
6
6
|
import type { IFilterInputConfig, IFilterInputProps } from './components/filter-input.types';
|
|
7
7
|
import type { IFilterSummaryConfig, IFilterSummaryProps } from './components/filter-summary.types';
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { createFilterBar } from './index.create';
|
|
2
2
|
import { getFilterFromURL, isEmptyFilterState, isFilterStateEqual, removeNullValues, setFilterToURL } from './helpers';
|
|
3
|
+
import createFormFieldString from './menu/create-form-field-string';
|
|
4
|
+
import createFormFieldSelect from './menu/create-form-field-select';
|
|
5
|
+
import createFormFieldSelectMultiple from './menu/create-form-field-select-multiple';
|
|
3
6
|
export declare class DinoFilterBar {
|
|
4
7
|
createFilterBar: typeof createFilterBar;
|
|
5
8
|
createConvertToGraphQL: <TSource extends Record<string, any>, TTarget extends object>(state: import("./types").TFilterState<TSource>) => import("./convert-to-graphql").TableFileterConverter<TSource, TTarget>;
|
|
6
9
|
createLocalFilterBuilder: <T>(data: T[], filterState: import("./types").TFilterState<T>) => import("./local-filter-builder").LocalFilterBuilder<T>;
|
|
10
|
+
createFormFieldString: typeof createFormFieldString;
|
|
11
|
+
createFormFieldSelect: typeof createFormFieldSelect;
|
|
12
|
+
createFormFieldSelectMultiple: typeof createFormFieldSelectMultiple;
|
|
7
13
|
mapLogic: (logic?: import("./types").TLogic | undefined) => "Or" | "And";
|
|
8
14
|
mapDirection: (direction?: import("./types").TDirection | undefined) => "ASC" | "DESC";
|
|
9
15
|
isEmptyFilterState: typeof isEmptyFilterState;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { IFieldSelectOption } from './create-form-field-select';
|
|
3
|
+
import type { IFieldMenuConfig, IFilterMenuFormProps } from './types';
|
|
4
|
+
export interface IFormFieldSelectMultipleProps<T> extends IFilterMenuFormProps<T> {
|
|
5
|
+
}
|
|
6
|
+
export interface IFormFieldSelectMultipleParam<T> {
|
|
7
|
+
/** Optional configuration for the form field */
|
|
8
|
+
config?: IFieldMenuConfig<T>;
|
|
9
|
+
/** List of options for the select field */
|
|
10
|
+
options: IFieldSelectOption[];
|
|
11
|
+
}
|
|
12
|
+
declare function createFormFieldSelectMultiple<T>(params?: IFormFieldSelectMultipleParam<T>): FC<IFormFieldSelectMultipleProps<T>>;
|
|
13
|
+
export default createFormFieldSelectMultiple;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import type { IFieldMenuConfig, IFilterMenuFormProps } from './types';
|
|
3
|
+
import type { TFieldValid } from '../types';
|
|
4
|
+
export interface IFormFieldSelectProps<T> extends IFilterMenuFormProps<T> {
|
|
5
|
+
}
|
|
6
|
+
export interface IFieldSelectOption {
|
|
7
|
+
value: TFieldValid;
|
|
8
|
+
label?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface IFormFieldSelectParams<T> {
|
|
11
|
+
/** Optional configuration for the form field */
|
|
12
|
+
config?: IFieldMenuConfig<T>;
|
|
13
|
+
/** List of options for the select field */
|
|
14
|
+
options: IFieldSelectOption[];
|
|
15
|
+
}
|
|
16
|
+
declare function createFormFieldSelect<T>(params: IFormFieldSelectParams<T>): FC<IFormFieldSelectProps<T>>;
|
|
17
|
+
export default createFormFieldSelect;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { IFieldMenuConfig, IFilterMenuFormProps } from './types';
|
|
3
|
+
export interface IFormFieldStringProps<T> extends IFilterMenuFormProps<T> {
|
|
4
|
+
}
|
|
5
|
+
export interface IFormFieldStringParam<T> {
|
|
6
|
+
/** Optional configuration for the form field */
|
|
7
|
+
config?: IFieldMenuConfig<T>;
|
|
8
|
+
}
|
|
9
|
+
declare function createFormFieldString<T>(params?: IFormFieldStringParam<T>): FC<IFormFieldStringProps<T>>;
|
|
10
|
+
export default createFormFieldString;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FC } from 'react';
|
|
2
|
-
import type { IFilterMenuProps } from './
|
|
3
|
-
import type { IFilterMenuConfig } from './
|
|
2
|
+
import type { IFilterMenuProps } from './types';
|
|
3
|
+
import type { IFilterMenuConfig } from './types';
|
|
4
4
|
export declare function createFilterMenu<T>(config: IFilterMenuConfig<T>): FC<IFilterMenuProps<T>>;
|
|
5
5
|
export declare const filterMenuClasses: {
|
|
6
6
|
root: string;
|
|
@@ -7,10 +7,12 @@ export interface IFieldMenuConfig<T> {
|
|
|
7
7
|
label?: string;
|
|
8
8
|
singleValue?: boolean;
|
|
9
9
|
/** Default form component for the field is `String` */
|
|
10
|
-
|
|
10
|
+
FormComponent?: ComponentType<IFilterMenuFormProps<T>>;
|
|
11
11
|
}
|
|
12
12
|
export type TFieldMenuConfigs<T> = Partial<Record<TFieldType<T>, Omit<IFieldMenuConfig<T>, 'field'>>>;
|
|
13
|
+
export type TFieldMenuConfigsInternal<T> = Partial<Record<TFieldType<T>, IFieldMenuConfig<T>>>;
|
|
13
14
|
export interface IFilterMenuFormProps<T> {
|
|
15
|
+
currentConfig: IFieldMenuConfig<T>;
|
|
14
16
|
isLoading?: boolean;
|
|
15
17
|
value?: TFieldValue;
|
|
16
18
|
validator?: FormValidator<Partial<TFieldModelValid<T>>>;
|
|
@@ -32,6 +34,9 @@ export interface IFilterMenuConfig<T> extends IFilterMenuSlots {
|
|
|
32
34
|
/** Option to enable or disable quick search @default true */
|
|
33
35
|
enableQuickSearch?: boolean;
|
|
34
36
|
}
|
|
37
|
+
export interface IFilterMenuConfigInternal<T> extends Omit<IFilterMenuConfig<T>, 'fields'> {
|
|
38
|
+
fields: TFieldMenuConfigsInternal<T>;
|
|
39
|
+
}
|
|
35
40
|
export interface IFilterMenuProps<T> {
|
|
36
41
|
slots?: IFilterMenuSlots;
|
|
37
42
|
}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { TextFieldProps, SwitchProps } from '@mui/material';
|
|
2
|
+
import { TextFieldProps, SwitchProps, BoxProps } from '@mui/material';
|
|
3
3
|
import { IFormInputBase } from './types';
|
|
4
4
|
interface ISlots<T> {
|
|
5
|
+
rootProps?: BoxProps;
|
|
6
|
+
switchProps?: SwitchProps;
|
|
7
|
+
textFieldProps?: Partial<TextFieldProps>;
|
|
8
|
+
}
|
|
9
|
+
interface IDateExpiredConfig<T> extends ISlots<T> {
|
|
10
|
+
defaultValue?: any;
|
|
5
11
|
/** @default string */
|
|
6
|
-
|
|
12
|
+
inputType?: 'number' | 'string';
|
|
7
13
|
textFieldProps?: Partial<TextFieldProps>;
|
|
8
|
-
switchProps?: SwitchProps;
|
|
9
14
|
switchChecked?: boolean;
|
|
10
15
|
switchCheckedGetter?: (value: any, model?: Partial<T>) => boolean;
|
|
11
16
|
}
|
|
12
|
-
interface IProps<T> extends IFormInputBase<T> {
|
|
17
|
+
interface IProps<T> extends IFormInputBase<T>, IDateExpiredConfig<T> {
|
|
13
18
|
slots?: ISlots<T>;
|
|
14
19
|
}
|
|
15
|
-
declare function CreateDateExpired<T>(
|
|
20
|
+
declare function CreateDateExpired<T>(param?: IDateExpiredConfig<T>): React.ComponentType<IProps<T>>;
|
|
16
21
|
export default CreateDateExpired;
|
|
@@ -15,6 +15,7 @@ export interface IFormBaseConfigs<T> {
|
|
|
15
15
|
export interface IFormBaseParams<T> extends IFormBaseConfigs<T> {
|
|
16
16
|
}
|
|
17
17
|
export interface IFormBaseProps<T> extends PropsWithChildren, IFormBaseConfigs<T> {
|
|
18
|
+
className?: string;
|
|
18
19
|
onSubmit: (data: Partial<T>, e: React.FormEvent<HTMLFormElement>) => Promise<void>;
|
|
19
20
|
onError?: (error: IPartialError<T>) => void;
|
|
20
21
|
slots?: IFormBaseSlots;
|
|
@@ -9,13 +9,13 @@ export interface IFormGridLayoutConfig<T> {
|
|
|
9
9
|
placeholder?: string;
|
|
10
10
|
sizes?: RegularBreakpoints;
|
|
11
11
|
defaultValue?: any;
|
|
12
|
+
className?: string;
|
|
12
13
|
inputElement?: ComponentType<IFormInputBase<T>>;
|
|
13
14
|
}
|
|
14
15
|
export type IPreSubmitEvent<T> = (value: Partial<T>, oldValue?: T) => Partial<T>;
|
|
15
16
|
export interface IFormGridLayoutMergedConfigs<T> {
|
|
16
|
-
hiddenFields?: Partial<Record<keyof T, boolean
|
|
17
|
-
|
|
18
|
-
disabledFields?: Partial<Record<keyof T, boolean>>;
|
|
17
|
+
hiddenFields?: Partial<Record<keyof T, boolean>> | ((state: Partial<T>, model?: Partial<T>) => Partial<Record<keyof T, boolean>>);
|
|
18
|
+
disabledFields?: Partial<Record<keyof T, boolean>> | ((state: Partial<T>, model?: Partial<T>) => Partial<Record<keyof T, boolean>>);
|
|
19
19
|
}
|
|
20
20
|
export interface IFormGridLayoutSlots<T> extends IFormGridLayoutMergedConfigs<T> {
|
|
21
21
|
action?: ComponentType<IFormBase<T>>;
|
|
@@ -26,13 +26,14 @@ export interface IFormGridLayoutSlots<T> extends IFormGridLayoutMergedConfigs<T>
|
|
|
26
26
|
Success?: boolean;
|
|
27
27
|
Fail?: boolean;
|
|
28
28
|
};
|
|
29
|
-
|
|
29
|
+
rootProps?: BoxProps;
|
|
30
30
|
preSubmit?: IPreSubmitEvent<T>;
|
|
31
31
|
formSlots?: IFormBaseSlots;
|
|
32
32
|
}
|
|
33
33
|
export interface IFormGridLayoutParams<T> extends IFormGridLayoutSlots<T> {
|
|
34
34
|
configs: IFormGridLayoutConfig<T>[];
|
|
35
35
|
validate: FormValidator<Partial<T>>;
|
|
36
|
+
autoHeight?: boolean;
|
|
36
37
|
}
|
|
37
38
|
export interface IFormGridLayoutProps<T> {
|
|
38
39
|
data?: T;
|
|
@@ -42,6 +43,7 @@ export interface IFormGridLayoutProps<T> {
|
|
|
42
43
|
onClose?: () => void;
|
|
43
44
|
sx?: SxProps<Theme>;
|
|
44
45
|
slots?: IFormGridLayoutSlots<T>;
|
|
46
|
+
autoHeight?: boolean;
|
|
45
47
|
}
|
|
46
48
|
export interface IFormGridLayoutState {
|
|
47
49
|
loadding?: boolean;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
2
|
import { IFormBase } from './types';
|
|
3
|
-
export declare const
|
|
4
|
-
|
|
3
|
+
export declare const formGridLayoutClasses: {
|
|
4
|
+
root: string;
|
|
5
|
+
form: string;
|
|
6
|
+
bottomBar: string;
|
|
7
|
+
autoHeight: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const FormGridLayoutStyled: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
10
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
5
11
|
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
6
12
|
export interface IFormBottomBarProps<T> extends IFormBase<T> {
|
|
7
13
|
before?: ReactNode;
|
|
8
14
|
}
|
|
9
|
-
export declare function CreateFormBottomBar<T>():
|
|
10
|
-
export declare const FormBottomBarWrap: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<
|
|
11
|
-
ref?: ((instance: HTMLDivElement | null) => void) |
|
|
15
|
+
export declare function CreateFormBottomBar<T>(): FC<IFormBottomBarProps<T>>;
|
|
16
|
+
export declare const FormBottomBarWrap: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
17
|
+
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
12
18
|
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
2
|
import type { SelectProps } from '@mui/material';
|
|
3
|
-
import { IFormInputBase } from '
|
|
3
|
+
import type { IFormInputBase } from '../form/types';
|
|
4
4
|
import type { IRichTooltipPanelConfig } from '../components/rich-tooltip';
|
|
5
5
|
export interface ISelectSimpleOption<T extends string = string> {
|
|
6
6
|
name: string;
|
|
@@ -11,10 +11,12 @@ export interface ISelectSimpleSlots {
|
|
|
11
11
|
}
|
|
12
12
|
export interface ISelectSimpleProps<T> extends Partial<IFormInputBase<T>> {
|
|
13
13
|
options?: ISelectSimpleOption[];
|
|
14
|
+
value?: any;
|
|
14
15
|
onChange?: (value: ISelectSimpleOption) => void;
|
|
15
16
|
slots?: ISelectSimpleSlots;
|
|
16
17
|
fullWidth?: boolean;
|
|
17
18
|
tooltip?: IRichTooltipPanelConfig;
|
|
19
|
+
endAdornment?: React.ReactNode;
|
|
18
20
|
}
|
|
19
21
|
export interface ISelectSimpleState {
|
|
20
22
|
value?: string;
|
|
@@ -22,6 +24,14 @@ export interface ISelectSimpleState {
|
|
|
22
24
|
export interface ISelectSimpleParams extends ISelectSimpleSlots {
|
|
23
25
|
options?: ISelectSimpleOption[];
|
|
24
26
|
tooltip?: IRichTooltipPanelConfig;
|
|
27
|
+
endAdornment?: React.ReactNode;
|
|
25
28
|
}
|
|
26
|
-
declare function
|
|
27
|
-
export default
|
|
29
|
+
declare function createSelectSimple<T>(args?: ISelectSimpleParams): ComponentType<ISelectSimpleProps<T>>;
|
|
30
|
+
export default createSelectSimple;
|
|
31
|
+
export declare const selectSimpleClasses: {
|
|
32
|
+
root: string;
|
|
33
|
+
tooltipWrap: string;
|
|
34
|
+
small: string;
|
|
35
|
+
tooltip: string;
|
|
36
|
+
endAdornment: string;
|
|
37
|
+
};
|