@universe-platform/ui 0.1.0-beta.14 → 0.1.0-beta.16

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/index.d.mts CHANGED
@@ -3,9 +3,13 @@ import { ColumnDef } from './columns';
3
3
  export { BaseColumnDef, COLUMN_CAPABILITIES, COLUMN_DEFAULT_INPUT_CONFIG, COLUMN_TYPES, COLUMN_TYPE_LABELS, ColumnCapabilities, ColumnConfig, ColumnConfigMap, ColumnDef, ColumnDefaultInputConfig, ColumnInfo, ColumnType, CurrencyConfig, ExtendedColumnInfo, GoogleContactConfig, GoogleContactNamePart, PhoneConfig, RelationConfig, SubTableConfig, TEXT_REPRESENTABLE_TYPES, TextRepresentableColumnType, TypedColumnDef, isTextRepresentable } from './columns';
4
4
  import { RecordData, CellValue } from './records';
5
5
  export { CellValue, ColumnValueMap, DriveFileValue, GoogleContactValue, LinkValue, RecordData, SubTableEntryValue, SubTableResolvedEntryValue } from './records';
6
- export { BaseComponent, ComponentType, EditorApp, EditorPage, PageComponent, PageInput, TableComponent } from './pages';
6
+ import { WhatsAppConfig } from './pages';
7
+ export { BaseComponent, ComponentType, EditorApp, EditorPage, PageComponent, PageInput, TableComponent, WhatsAppConfig } from './pages';
7
8
  import { SchemaDef } from './schema';
8
9
  export { SchemaDef, TableMeta } from './schema';
10
+ import { TemplateIdentity } from './whatsappValidation';
11
+ export * from './whatsappValidation';
12
+ export { StatusConfig, TemplateIdentity, TemplateValidationParams, TemplateValidationResult, extractUniqueVariableIndices, extractVariableIndices, findVariableAtPosition, formatFileSize, getNextVariableIndex, getStatusConfig, hasBracketSpaces, hasConsecutiveVariables, hasFloatingVariables, hasInsufficientContextBetweenVariables, isDuplicateTemplate, isDuplicateTemplateName, isValidTemplateName, isWordToken, reindexVariables, sanitizeTemplateNameInput, seamlessVariableEngine, validateSequentialVariables, validateTemplateBody, validateWhatsAppTemplate, validateWordToVariableRatio } from './whatsappValidation';
9
13
  import * as react_jsx_runtime from 'react/jsx-runtime';
10
14
  import * as react from 'react';
11
15
  import react__default, { ReactNode } from 'react';
@@ -26,6 +30,36 @@ declare function openWhatsAppChat(phone: string, defaultCountryCode?: string): v
26
30
  */
27
31
  declare function formatPhoneDisplay(phone: string): string;
28
32
 
33
+ /**
34
+ * Phone number sanitization, validation, and WhatsApp link generation utilities.
35
+ * Pure functions with zero React or DOM dependencies for universal (server & client) usage.
36
+ */
37
+ /**
38
+ * Sanitizes phone numbers by stripping whitespace, dashes, and non-numeric characters,
39
+ * preserving a leading '+' if present.
40
+ */
41
+ declare function sanitizePhoneNumber(phone: string): string;
42
+ /**
43
+ * Validates whether a phone number is valid (after sanitization).
44
+ * Supports Israeli formats (e.g. 0501234567, 031234567) and international formats (+972..., 9-15 digits).
45
+ */
46
+ declare function isValidPhoneNumber(phone: string): boolean;
47
+ /**
48
+ * Generates an official wa.me WhatsApp direct message link.
49
+ *
50
+ * @param phone Raw or sanitized phone number
51
+ * @param defaultCountryCode Defaults to Israeli code '972'
52
+ * @returns WhatsApp URL or null if phone is empty
53
+ */
54
+ declare function generateWhatsAppLink(phone: string, defaultCountryCode?: string): string | null;
55
+ /**
56
+ * Normalizes a phone number for WhatsApp sending (E.164 without leading '+').
57
+ * - Strips spaces, dashes, and special characters.
58
+ * - If it starts with '05' (10 digits), replaces the leading '0' with '972' (e.g., '0586812807' -> '972586812807').
59
+ * - If it starts with '+', strips the '+'.
60
+ */
61
+ declare function normalizePhoneForWhatsApp(phone: string): string;
62
+
29
63
  interface PastelPalette {
30
64
  bg: string;
31
65
  text: string;
@@ -83,11 +117,17 @@ declare function getRolePermissions(role?: OrgRole | string | null): RolePermiss
83
117
  interface TableConfig extends SchemaDef {
84
118
  }
85
119
  type TableData = RecordData[];
120
+ type RowStatusType = "success" | "failed" | "skipped" | "partial";
86
121
  interface TableBlockProps extends Partial<BaseComponentProps<TableData, TableConfig>> {
87
122
  exportAction?: (payload: any) => Promise<any>;
88
123
  role?: OrgRole | string;
89
124
  permissions?: ComponentPermissions;
90
125
  readOnly?: boolean;
126
+ onSelectionChange?: (selectedIds: string[]) => void;
127
+ rowStatusMap?: Record<string, {
128
+ status: RowStatusType;
129
+ tooltip?: string;
130
+ } | RowStatusType>;
91
131
  }
92
132
  interface CreateRecordPayload {
93
133
  records: RecordData[];
@@ -264,13 +304,65 @@ interface RelationFilterPopoverProps {
264
304
  }
265
305
  declare function RelationFilterPopover({ isOpen, onClose, column, triggerRect, options, filterValue, selectedValues, onSelectionChange, isLoading, }: RelationFilterPopoverProps): react_jsx_runtime.JSX.Element | null;
266
306
 
307
+ interface MetaTemplateComponent {
308
+ type: "HEADER" | "BODY" | "FOOTER" | "BUTTONS" | string;
309
+ format?: "TEXT" | "IMAGE" | "DOCUMENT" | "VIDEO" | string;
310
+ text?: string;
311
+ example?: {
312
+ header_handle?: string[];
313
+ body_text?: string[][];
314
+ [key: string]: any;
315
+ };
316
+ [key: string]: any;
317
+ }
318
+ interface MetaWhatsAppTemplate {
319
+ id: string;
320
+ name: string;
321
+ status: "APPROVED" | "PENDING" | "IN_REVIEW" | "REJECTED" | "PAUSED" | string;
322
+ category: "MARKETING" | "UTILITY" | string;
323
+ language: string;
324
+ components?: MetaTemplateComponent[];
325
+ [key: string]: any;
326
+ }
327
+ type WhatsAppData = any;
328
+ interface WhatsAppComponentProps extends Partial<BaseComponentProps<WhatsAppData, WhatsAppConfig>> {
329
+ permissions?: ComponentPermissions;
330
+ orgId?: string;
331
+ organizationId?: string;
332
+ }
333
+
334
+ /**
335
+ * WhatsAppComponent
336
+ * High-level orchestrator for the WhatsApp messaging interface.
337
+ * Coordinates template selection, dynamic filters, recipient settings/actions,
338
+ * and the embedded data grid.
339
+ */
340
+ declare function WhatsAppComponent(props: WhatsAppComponentProps): react_jsx_runtime.JSX.Element;
341
+
342
+ interface CreateTemplateModalProps {
343
+ isOpen: boolean;
344
+ onClose: () => void;
345
+ onSuccess: () => void;
346
+ existingTemplateNames?: string[];
347
+ existingTemplates?: TemplateIdentity[];
348
+ executeAction?: (actionType: string, payload: Record<string, any>) => Promise<any>;
349
+ orgId?: string;
350
+ }
351
+ /**
352
+ * CreateTemplateModal
353
+ * Enterprise modal dialog for authoring and submitting WhatsApp message templates
354
+ * with atomic variable deletion, flexible editing, and strict word-to-variable ratio validation.
355
+ */
356
+ declare function CreateTemplateModal({ isOpen, onClose, onSuccess, existingTemplateNames, existingTemplates, executeAction, orgId, }: CreateTemplateModalProps): react_jsx_runtime.JSX.Element | null;
357
+
267
358
  /**
268
359
  * UNIVERSE_COMPONENTS
269
- * Dynamic Component Registry dictionary mapping component type strings (e.g., "TABLE")
360
+ * Dynamic Component Registry dictionary mapping component type strings (e.g., "TABLE", "WHATSAPP")
270
361
  * to their respective React component implementation.
271
362
  */
272
363
  declare const UNIVERSE_COMPONENTS: {
273
364
  readonly TABLE: typeof TableBlock;
365
+ readonly WHATSAPP: typeof WhatsAppComponent;
274
366
  };
275
367
  type ComponentRegistry = typeof UNIVERSE_COMPONENTS;
276
368
  type UniverseComponentType = keyof ComponentRegistry;
@@ -295,4 +387,4 @@ declare function ToastProvider({ children }: {
295
387
 
296
388
  declare function useToast(): ToastContextType;
297
389
 
298
- export { type BaseComponentProps, ColumnHeaderTitle, type ColumnHeaderTitleProps, type ComponentCommunication, type ComponentConfig, type ComponentData, type ComponentPermissions, type ComponentRegistry, type ComponentState, type CreateRecordPayload, DatePickerCell, type DeleteRecordPayload, LinkPickerCell, type OrgRole, PASTEL_PALETTES, type PastelPalette, type RelationFilterOption, type RelationFilterPayload, RelationFilterPopover, type RelationFilterPopoverProps, RelationPickerCell, type RolePermissions, type SplitTitleResult, TableBlock, type TableBlockProps, type TableConfig, type TableData, TimePickerCell, ToastContext, type ToastContextType, type ToastItem, ToastProvider, UNIVERSE_COMPONENTS, type UniverseComponentType, type UpdateRecordPayload, type UseColumnReorderOptions, type UseColumnResizeOptions, calculateMinColumnWidth, cn, formatConflictCellValue, formatPhoneDisplay, formatTimeInput, formatTimeIso, getDeterministicPastelBadge, getRolePermissions, measureTextWidth, normalizeRelationValue, openWhatsAppChat, parseLinkValue, parseTimeParts, resolveProtocol, splitHeaderTitle, useColumnReorder, useColumnResize, useToast };
390
+ export { type BaseComponentProps, ColumnHeaderTitle, type ColumnHeaderTitleProps, type ComponentCommunication, type ComponentConfig, type ComponentData, type ComponentPermissions, type ComponentRegistry, type ComponentState, type CreateRecordPayload, CreateTemplateModal, type CreateTemplateModalProps, DatePickerCell, type DeleteRecordPayload, LinkPickerCell, type MetaTemplateComponent, type MetaWhatsAppTemplate, type OrgRole, PASTEL_PALETTES, type PastelPalette, type RelationFilterOption, type RelationFilterPayload, RelationFilterPopover, type RelationFilterPopoverProps, RelationPickerCell, type RolePermissions, type RowStatusType, type SplitTitleResult, TableBlock, type TableBlockProps, type TableConfig, type TableData, TimePickerCell, ToastContext, type ToastContextType, type ToastItem, ToastProvider, UNIVERSE_COMPONENTS, type UniverseComponentType, type UpdateRecordPayload, type UseColumnReorderOptions, type UseColumnResizeOptions, WhatsAppComponent, type WhatsAppComponentProps, type WhatsAppData, calculateMinColumnWidth, cn, formatConflictCellValue, formatPhoneDisplay, formatTimeInput, formatTimeIso, generateWhatsAppLink, getDeterministicPastelBadge, getRolePermissions, isValidPhoneNumber, measureTextWidth, normalizePhoneForWhatsApp, normalizeRelationValue, openWhatsAppChat, parseLinkValue, parseTimeParts, resolveProtocol, sanitizePhoneNumber, splitHeaderTitle, useColumnReorder, useColumnResize, useToast };
package/dist/index.d.ts CHANGED
@@ -3,9 +3,13 @@ import { ColumnDef } from './columns';
3
3
  export { BaseColumnDef, COLUMN_CAPABILITIES, COLUMN_DEFAULT_INPUT_CONFIG, COLUMN_TYPES, COLUMN_TYPE_LABELS, ColumnCapabilities, ColumnConfig, ColumnConfigMap, ColumnDef, ColumnDefaultInputConfig, ColumnInfo, ColumnType, CurrencyConfig, ExtendedColumnInfo, GoogleContactConfig, GoogleContactNamePart, PhoneConfig, RelationConfig, SubTableConfig, TEXT_REPRESENTABLE_TYPES, TextRepresentableColumnType, TypedColumnDef, isTextRepresentable } from './columns';
4
4
  import { RecordData, CellValue } from './records';
5
5
  export { CellValue, ColumnValueMap, DriveFileValue, GoogleContactValue, LinkValue, RecordData, SubTableEntryValue, SubTableResolvedEntryValue } from './records';
6
- export { BaseComponent, ComponentType, EditorApp, EditorPage, PageComponent, PageInput, TableComponent } from './pages';
6
+ import { WhatsAppConfig } from './pages';
7
+ export { BaseComponent, ComponentType, EditorApp, EditorPage, PageComponent, PageInput, TableComponent, WhatsAppConfig } from './pages';
7
8
  import { SchemaDef } from './schema';
8
9
  export { SchemaDef, TableMeta } from './schema';
10
+ import { TemplateIdentity } from './whatsappValidation';
11
+ export * from './whatsappValidation';
12
+ export { StatusConfig, TemplateIdentity, TemplateValidationParams, TemplateValidationResult, extractUniqueVariableIndices, extractVariableIndices, findVariableAtPosition, formatFileSize, getNextVariableIndex, getStatusConfig, hasBracketSpaces, hasConsecutiveVariables, hasFloatingVariables, hasInsufficientContextBetweenVariables, isDuplicateTemplate, isDuplicateTemplateName, isValidTemplateName, isWordToken, reindexVariables, sanitizeTemplateNameInput, seamlessVariableEngine, validateSequentialVariables, validateTemplateBody, validateWhatsAppTemplate, validateWordToVariableRatio } from './whatsappValidation';
9
13
  import * as react_jsx_runtime from 'react/jsx-runtime';
10
14
  import * as react from 'react';
11
15
  import react__default, { ReactNode } from 'react';
@@ -26,6 +30,36 @@ declare function openWhatsAppChat(phone: string, defaultCountryCode?: string): v
26
30
  */
27
31
  declare function formatPhoneDisplay(phone: string): string;
28
32
 
33
+ /**
34
+ * Phone number sanitization, validation, and WhatsApp link generation utilities.
35
+ * Pure functions with zero React or DOM dependencies for universal (server & client) usage.
36
+ */
37
+ /**
38
+ * Sanitizes phone numbers by stripping whitespace, dashes, and non-numeric characters,
39
+ * preserving a leading '+' if present.
40
+ */
41
+ declare function sanitizePhoneNumber(phone: string): string;
42
+ /**
43
+ * Validates whether a phone number is valid (after sanitization).
44
+ * Supports Israeli formats (e.g. 0501234567, 031234567) and international formats (+972..., 9-15 digits).
45
+ */
46
+ declare function isValidPhoneNumber(phone: string): boolean;
47
+ /**
48
+ * Generates an official wa.me WhatsApp direct message link.
49
+ *
50
+ * @param phone Raw or sanitized phone number
51
+ * @param defaultCountryCode Defaults to Israeli code '972'
52
+ * @returns WhatsApp URL or null if phone is empty
53
+ */
54
+ declare function generateWhatsAppLink(phone: string, defaultCountryCode?: string): string | null;
55
+ /**
56
+ * Normalizes a phone number for WhatsApp sending (E.164 without leading '+').
57
+ * - Strips spaces, dashes, and special characters.
58
+ * - If it starts with '05' (10 digits), replaces the leading '0' with '972' (e.g., '0586812807' -> '972586812807').
59
+ * - If it starts with '+', strips the '+'.
60
+ */
61
+ declare function normalizePhoneForWhatsApp(phone: string): string;
62
+
29
63
  interface PastelPalette {
30
64
  bg: string;
31
65
  text: string;
@@ -83,11 +117,17 @@ declare function getRolePermissions(role?: OrgRole | string | null): RolePermiss
83
117
  interface TableConfig extends SchemaDef {
84
118
  }
85
119
  type TableData = RecordData[];
120
+ type RowStatusType = "success" | "failed" | "skipped" | "partial";
86
121
  interface TableBlockProps extends Partial<BaseComponentProps<TableData, TableConfig>> {
87
122
  exportAction?: (payload: any) => Promise<any>;
88
123
  role?: OrgRole | string;
89
124
  permissions?: ComponentPermissions;
90
125
  readOnly?: boolean;
126
+ onSelectionChange?: (selectedIds: string[]) => void;
127
+ rowStatusMap?: Record<string, {
128
+ status: RowStatusType;
129
+ tooltip?: string;
130
+ } | RowStatusType>;
91
131
  }
92
132
  interface CreateRecordPayload {
93
133
  records: RecordData[];
@@ -264,13 +304,65 @@ interface RelationFilterPopoverProps {
264
304
  }
265
305
  declare function RelationFilterPopover({ isOpen, onClose, column, triggerRect, options, filterValue, selectedValues, onSelectionChange, isLoading, }: RelationFilterPopoverProps): react_jsx_runtime.JSX.Element | null;
266
306
 
307
+ interface MetaTemplateComponent {
308
+ type: "HEADER" | "BODY" | "FOOTER" | "BUTTONS" | string;
309
+ format?: "TEXT" | "IMAGE" | "DOCUMENT" | "VIDEO" | string;
310
+ text?: string;
311
+ example?: {
312
+ header_handle?: string[];
313
+ body_text?: string[][];
314
+ [key: string]: any;
315
+ };
316
+ [key: string]: any;
317
+ }
318
+ interface MetaWhatsAppTemplate {
319
+ id: string;
320
+ name: string;
321
+ status: "APPROVED" | "PENDING" | "IN_REVIEW" | "REJECTED" | "PAUSED" | string;
322
+ category: "MARKETING" | "UTILITY" | string;
323
+ language: string;
324
+ components?: MetaTemplateComponent[];
325
+ [key: string]: any;
326
+ }
327
+ type WhatsAppData = any;
328
+ interface WhatsAppComponentProps extends Partial<BaseComponentProps<WhatsAppData, WhatsAppConfig>> {
329
+ permissions?: ComponentPermissions;
330
+ orgId?: string;
331
+ organizationId?: string;
332
+ }
333
+
334
+ /**
335
+ * WhatsAppComponent
336
+ * High-level orchestrator for the WhatsApp messaging interface.
337
+ * Coordinates template selection, dynamic filters, recipient settings/actions,
338
+ * and the embedded data grid.
339
+ */
340
+ declare function WhatsAppComponent(props: WhatsAppComponentProps): react_jsx_runtime.JSX.Element;
341
+
342
+ interface CreateTemplateModalProps {
343
+ isOpen: boolean;
344
+ onClose: () => void;
345
+ onSuccess: () => void;
346
+ existingTemplateNames?: string[];
347
+ existingTemplates?: TemplateIdentity[];
348
+ executeAction?: (actionType: string, payload: Record<string, any>) => Promise<any>;
349
+ orgId?: string;
350
+ }
351
+ /**
352
+ * CreateTemplateModal
353
+ * Enterprise modal dialog for authoring and submitting WhatsApp message templates
354
+ * with atomic variable deletion, flexible editing, and strict word-to-variable ratio validation.
355
+ */
356
+ declare function CreateTemplateModal({ isOpen, onClose, onSuccess, existingTemplateNames, existingTemplates, executeAction, orgId, }: CreateTemplateModalProps): react_jsx_runtime.JSX.Element | null;
357
+
267
358
  /**
268
359
  * UNIVERSE_COMPONENTS
269
- * Dynamic Component Registry dictionary mapping component type strings (e.g., "TABLE")
360
+ * Dynamic Component Registry dictionary mapping component type strings (e.g., "TABLE", "WHATSAPP")
270
361
  * to their respective React component implementation.
271
362
  */
272
363
  declare const UNIVERSE_COMPONENTS: {
273
364
  readonly TABLE: typeof TableBlock;
365
+ readonly WHATSAPP: typeof WhatsAppComponent;
274
366
  };
275
367
  type ComponentRegistry = typeof UNIVERSE_COMPONENTS;
276
368
  type UniverseComponentType = keyof ComponentRegistry;
@@ -295,4 +387,4 @@ declare function ToastProvider({ children }: {
295
387
 
296
388
  declare function useToast(): ToastContextType;
297
389
 
298
- export { type BaseComponentProps, ColumnHeaderTitle, type ColumnHeaderTitleProps, type ComponentCommunication, type ComponentConfig, type ComponentData, type ComponentPermissions, type ComponentRegistry, type ComponentState, type CreateRecordPayload, DatePickerCell, type DeleteRecordPayload, LinkPickerCell, type OrgRole, PASTEL_PALETTES, type PastelPalette, type RelationFilterOption, type RelationFilterPayload, RelationFilterPopover, type RelationFilterPopoverProps, RelationPickerCell, type RolePermissions, type SplitTitleResult, TableBlock, type TableBlockProps, type TableConfig, type TableData, TimePickerCell, ToastContext, type ToastContextType, type ToastItem, ToastProvider, UNIVERSE_COMPONENTS, type UniverseComponentType, type UpdateRecordPayload, type UseColumnReorderOptions, type UseColumnResizeOptions, calculateMinColumnWidth, cn, formatConflictCellValue, formatPhoneDisplay, formatTimeInput, formatTimeIso, getDeterministicPastelBadge, getRolePermissions, measureTextWidth, normalizeRelationValue, openWhatsAppChat, parseLinkValue, parseTimeParts, resolveProtocol, splitHeaderTitle, useColumnReorder, useColumnResize, useToast };
390
+ export { type BaseComponentProps, ColumnHeaderTitle, type ColumnHeaderTitleProps, type ComponentCommunication, type ComponentConfig, type ComponentData, type ComponentPermissions, type ComponentRegistry, type ComponentState, type CreateRecordPayload, CreateTemplateModal, type CreateTemplateModalProps, DatePickerCell, type DeleteRecordPayload, LinkPickerCell, type MetaTemplateComponent, type MetaWhatsAppTemplate, type OrgRole, PASTEL_PALETTES, type PastelPalette, type RelationFilterOption, type RelationFilterPayload, RelationFilterPopover, type RelationFilterPopoverProps, RelationPickerCell, type RolePermissions, type RowStatusType, type SplitTitleResult, TableBlock, type TableBlockProps, type TableConfig, type TableData, TimePickerCell, ToastContext, type ToastContextType, type ToastItem, ToastProvider, UNIVERSE_COMPONENTS, type UniverseComponentType, type UpdateRecordPayload, type UseColumnReorderOptions, type UseColumnResizeOptions, WhatsAppComponent, type WhatsAppComponentProps, type WhatsAppData, calculateMinColumnWidth, cn, formatConflictCellValue, formatPhoneDisplay, formatTimeInput, formatTimeIso, generateWhatsAppLink, getDeterministicPastelBadge, getRolePermissions, isValidPhoneNumber, measureTextWidth, normalizePhoneForWhatsApp, normalizeRelationValue, openWhatsAppChat, parseLinkValue, parseTimeParts, resolveProtocol, sanitizePhoneNumber, splitHeaderTitle, useColumnReorder, useColumnResize, useToast };