@vuu-ui/vuu-utils 2.1.13 → 2.1.15
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/cjs/node_modules/@dnd-kit/react/hooks.js +17 -17
- package/cjs/node_modules/@dnd-kit/react/hooks.js.map +1 -1
- package/cjs/node_modules/@dnd-kit/react/index.js +24 -24
- package/cjs/node_modules/@dnd-kit/react/index.js.map +1 -1
- package/cjs/node_modules/@dnd-kit/react/sortable.js +5 -5
- package/cjs/node_modules/@dnd-kit/react/sortable.js.map +1 -1
- package/cjs/packages/vuu-utils/src/ShellContext.js +3 -3
- package/cjs/packages/vuu-utils/src/ShellContext.js.map +1 -1
- package/cjs/packages/vuu-utils/src/ThemeProvider.js +10 -10
- package/cjs/packages/vuu-utils/src/ThemeProvider.js.map +1 -1
- package/cjs/packages/vuu-utils/src/context-definitions/DataContext.js +2 -2
- package/cjs/packages/vuu-utils/src/context-definitions/DataContext.js.map +1 -1
- package/cjs/packages/vuu-utils/src/context-definitions/DataProvider.js +4 -4
- package/cjs/packages/vuu-utils/src/context-definitions/DataProvider.js.map +1 -1
- package/cjs/packages/vuu-utils/src/context-definitions/DataSourceProvider.js +5 -5
- package/cjs/packages/vuu-utils/src/context-definitions/DataSourceProvider.js.map +1 -1
- package/cjs/packages/vuu-utils/src/context-definitions/WorkspaceContext.js +3 -3
- package/cjs/packages/vuu-utils/src/context-definitions/WorkspaceContext.js.map +1 -1
- package/cjs/packages/vuu-utils/src/data-editing/DataEditingProvider.js +5 -5
- package/cjs/packages/vuu-utils/src/data-editing/DataEditingProvider.js.map +1 -1
- package/cjs/packages/vuu-utils/src/data-editing/EditButtons.js +12 -15
- package/cjs/packages/vuu-utils/src/data-editing/EditButtons.js.map +1 -1
- package/cjs/packages/vuu-utils/src/data-editing/EditSession.js +52 -130
- package/cjs/packages/vuu-utils/src/data-editing/EditSession.js.map +1 -1
- package/cjs/packages/vuu-utils/src/data-editing/edit-utils.js +1 -32
- package/cjs/packages/vuu-utils/src/data-editing/edit-utils.js.map +1 -1
- package/cjs/packages/vuu-utils/src/data-editing/useEditableTable.js +15 -23
- package/cjs/packages/vuu-utils/src/data-editing/useEditableTable.js.map +1 -1
- package/cjs/packages/vuu-utils/src/datasource/BaseDataSource.js +3 -2
- package/cjs/packages/vuu-utils/src/datasource/BaseDataSource.js.map +1 -1
- package/cjs/packages/vuu-utils/src/datasource/datasource-filter-utils.js +3 -3
- package/cjs/packages/vuu-utils/src/datasource/datasource-filter-utils.js.map +1 -1
- package/cjs/packages/vuu-utils/src/date/date-utils.js +2 -2
- package/cjs/packages/vuu-utils/src/date/date-utils.js.map +1 -1
- package/cjs/packages/vuu-utils/src/date/formatter.js +2 -2
- package/cjs/packages/vuu-utils/src/date/formatter.js.map +1 -1
- package/cjs/packages/vuu-utils/src/feature-utils.js +2 -2
- package/cjs/packages/vuu-utils/src/feature-utils.js.map +1 -1
- package/cjs/packages/vuu-utils/src/index.js +2 -9
- package/cjs/packages/vuu-utils/src/index.js.map +1 -1
- package/cjs/packages/vuu-utils/src/protocol-message-utils.js +0 -10
- package/cjs/packages/vuu-utils/src/protocol-message-utils.js.map +1 -1
- package/cjs/packages/vuu-utils/src/react-utils.js +8 -8
- package/cjs/packages/vuu-utils/src/react-utils.js.map +1 -1
- package/cjs/packages/vuu-utils/src/theme-utils.js +3 -3
- package/cjs/packages/vuu-utils/src/theme-utils.js.map +1 -1
- package/cjs/packages/vuu-utils/src/useId.js +2 -2
- package/cjs/packages/vuu-utils/src/useId.js.map +1 -1
- package/cjs/packages/vuu-utils/src/useLayoutEffectSkipFirst.js +3 -3
- package/cjs/packages/vuu-utils/src/useLayoutEffectSkipFirst.js.map +1 -1
- package/cjs/packages/vuu-utils/src/useResizeObserver.js +5 -5
- package/cjs/packages/vuu-utils/src/useResizeObserver.js.map +1 -1
- package/cjs/packages/vuu-utils/src/useStateRef.js +4 -4
- package/cjs/packages/vuu-utils/src/useStateRef.js.map +1 -1
- package/esm/packages/vuu-utils/src/ThemeProvider.js +2 -2
- package/esm/packages/vuu-utils/src/ThemeProvider.js.map +1 -1
- package/esm/packages/vuu-utils/src/context-definitions/WorkspaceContext.js +2 -2
- package/esm/packages/vuu-utils/src/context-definitions/WorkspaceContext.js.map +1 -1
- package/esm/packages/vuu-utils/src/data-editing/EditButtons.js +4 -7
- package/esm/packages/vuu-utils/src/data-editing/EditButtons.js.map +1 -1
- package/esm/packages/vuu-utils/src/data-editing/EditSession.js +53 -130
- package/esm/packages/vuu-utils/src/data-editing/EditSession.js.map +1 -1
- package/esm/packages/vuu-utils/src/data-editing/edit-utils.js +2 -32
- package/esm/packages/vuu-utils/src/data-editing/edit-utils.js.map +1 -1
- package/esm/packages/vuu-utils/src/data-editing/useEditableTable.js +9 -17
- package/esm/packages/vuu-utils/src/data-editing/useEditableTable.js.map +1 -1
- package/esm/packages/vuu-utils/src/datasource/BaseDataSource.js +1 -0
- package/esm/packages/vuu-utils/src/datasource/BaseDataSource.js.map +1 -1
- package/esm/packages/vuu-utils/src/feature-utils.js +2 -2
- package/esm/packages/vuu-utils/src/feature-utils.js.map +1 -1
- package/esm/packages/vuu-utils/src/index.js +3 -3
- package/esm/packages/vuu-utils/src/protocol-message-utils.js +1 -6
- package/esm/packages/vuu-utils/src/protocol-message-utils.js.map +1 -1
- package/package.json +6 -6
- package/types/data-editing/EditButtons.d.ts +1 -1
- package/types/data-editing/EditSession.d.ts +6 -30
- package/types/data-editing/edit-utils.d.ts +0 -2
- package/types/data-editing/useEditableTable.d.ts +1 -1
- package/types/filters/filter-utils.d.ts +1 -2
- package/types/index.d.ts +2 -3
- package/types/protocol-message-utils.d.ts +1 -6
- package/cjs/packages/vuu-utils/dist/index.js +0 -6004
- package/cjs/packages/vuu-utils/dist/index.js.map +0 -1
- package/esm/packages/vuu-utils/dist/index.js +0 -5979
- package/esm/packages/vuu-utils/dist/index.js.map +0 -1
|
@@ -18,7 +18,6 @@ const InvalidLoginMessages = [
|
|
|
18
18
|
INVALID_TOKEN,
|
|
19
19
|
TOKEN_EXPIRED
|
|
20
20
|
];
|
|
21
|
-
const isErrorMessage = (message) => typeof message == "object" && message?.type === "ERROR";
|
|
22
21
|
const isLoginErrorMessage = (message) => typeof message === "string" && InvalidLoginMessages.includes(message);
|
|
23
22
|
const isSelectRequest = (message) => message && typeof message === "object" && "type" in message && (message.type === "SELECT_ROW" || message.type === "DESELECT_ROW" || message.type === "SELECT_ROW_RANGE" || message.type === "SELECT_ALL" || message.type === "DESELECT_ALL");
|
|
24
23
|
const isSelectSuccessWithRowCount = (response) => [
|
|
@@ -68,10 +67,6 @@ const numericTypes = [
|
|
|
68
67
|
function isNumericType(dataType) {
|
|
69
68
|
return numericTypes.includes(dataType);
|
|
70
69
|
}
|
|
71
|
-
const isAddRowRpcRequest = (rpcRequest) => rpcRequest.rpcName === "addRow";
|
|
72
|
-
const isEditCellRpcRequest = (rpcRequest) => rpcRequest.rpcName === "editCell";
|
|
73
|
-
const isBeginEditSessionRpcRequest = (rpcRequest) => rpcRequest.rpcName === "beginEditSession";
|
|
74
|
-
const isEndEditSessionRpcRequest = (rpcRequest) => rpcRequest.rpcName === "endEditSession";
|
|
75
70
|
|
|
76
71
|
exports.INVALID_SESSION = INVALID_SESSION;
|
|
77
72
|
exports.INVALID_TOKEN = INVALID_TOKEN;
|
|
@@ -79,13 +74,8 @@ exports.SESSION_LIMIT_EXCEEDED = SESSION_LIMIT_EXCEEDED;
|
|
|
79
74
|
exports.TOKEN_EXPIRED = TOKEN_EXPIRED;
|
|
80
75
|
exports.hasViewPortContext = hasViewPortContext;
|
|
81
76
|
exports.isActionMessage = isActionMessage;
|
|
82
|
-
exports.isAddRowRpcRequest = isAddRowRpcRequest;
|
|
83
|
-
exports.isBeginEditSessionRpcRequest = isBeginEditSessionRpcRequest;
|
|
84
77
|
exports.isCreateVpSuccess = isCreateVpSuccess;
|
|
85
78
|
exports.isCustomComponentActionMessage = isCustomComponentActionMessage;
|
|
86
|
-
exports.isEditCellRpcRequest = isEditCellRpcRequest;
|
|
87
|
-
exports.isEndEditSessionRpcRequest = isEndEditSessionRpcRequest;
|
|
88
|
-
exports.isErrorMessage = isErrorMessage;
|
|
89
79
|
exports.isLoginErrorMessage = isLoginErrorMessage;
|
|
90
80
|
exports.isLoginResponse = isLoginResponse;
|
|
91
81
|
exports.isNumericType = isNumericType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-message-utils.js","sources":["../../../../../../packages/vuu-utils/src/protocol-message-utils.ts"],"sourcesContent":["import type {\n MenuRpcAction,\n MenuRpcResponse,\n OpenDialogActionWithSchema,\n RpcResponse,\n TableSchema,\n VuuUiMessageInRequestResponse,\n} from \"@vuu-ui/vuu-data-types\";\nimport {\n VuuRpcMenuRequest,\n OpenDialogAction,\n VuuRpcRequest,\n VuuRpcResponse,\n VuuRpcMenuSuccess,\n VuuTable,\n VuuViewportRpcTypeaheadRequest,\n VuuRpcServiceRequest,\n ViewportRpcContext,\n OpenComponentInDialogAction,\n VuuLoginSuccessResponse,\n SelectRequest,\n SelectResponse,\n SelectSuccessWithRowCount,\n VuuViewportCreateSuccessResponse,\n VuuViewportCreateResponse,\n InvalidTokenReason,\n InvalidSessionReason,\n LoginErrorMessage,\n RpcResult,\n RpcResultSuccess,\n RpcResultError,\n VuuColumnDataType,\n VuuNumericType,\n AddRowRpcServiceRequest,\n EndEditSessionRpcServiceRequest,\n EditCellRpcServiceRequest,\n BeginEditSessionRpcServiceRequest,\n ServerToClientError,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { isView as componentInRegistry } from \"./component-registry\";\n\nconst MENU_RPC_TYPES = [\n \"VIEW_PORT_MENUS_SELECT_RPC\",\n \"VIEW_PORT_MENU_TABLE_RPC\",\n \"VIEW_PORT_MENU_ROW_RPC\",\n \"VIEW_PORT_MENU_CELL_RPC\",\n];\n\nexport const INVALID_SESSION: InvalidSessionReason = \"Invalid session\";\nexport const SESSION_LIMIT_EXCEEDED: InvalidSessionReason =\n \"User session limit exceeded\";\nexport const INVALID_TOKEN: InvalidTokenReason = \"Invalid token\";\nexport const TOKEN_EXPIRED: InvalidTokenReason = \"Token has expired\";\n\nconst InvalidLoginMessages: string[] = [\n INVALID_SESSION,\n SESSION_LIMIT_EXCEEDED,\n INVALID_TOKEN,\n TOKEN_EXPIRED,\n];\n\nexport const isErrorMessage = (\n message: unknown,\n): message is ServerToClientError =>\n typeof message == \"object\" &&\n (message as ServerToClientError)?.type === \"ERROR\";\n\nexport const isLoginErrorMessage = (\n message: unknown,\n): message is LoginErrorMessage =>\n typeof message === \"string\" && InvalidLoginMessages.includes(message);\n\nexport const isSelectRequest = (message: object): message is SelectRequest =>\n message &&\n typeof message === \"object\" &&\n \"type\" in message &&\n (message.type === \"SELECT_ROW\" ||\n message.type === \"DESELECT_ROW\" ||\n message.type === \"SELECT_ROW_RANGE\" ||\n message.type === \"SELECT_ALL\" ||\n message.type === \"DESELECT_ALL\");\n\nexport const isSelectSuccessWithRowCount = (\n response: SelectResponse | SelectSuccessWithRowCount,\n): response is SelectSuccessWithRowCount =>\n [\n \"SELECT_ROW_SUCCESS\",\n \"DESELECT_ROW_SUCCESS\",\n \"SELECT_ROW_RANGE_SUCCESS\",\n \"SELECT_ALL_SUCCESS\",\n \"DESELECT_ALL_SUCCESS\",\n ].includes(response.type ?? \"\") &&\n typeof (response as SelectSuccessWithRowCount).selectedRowCount === \"number\";\n\nexport const isRpcServiceRequest = (message: {\n type: string;\n}): message is VuuRpcServiceRequest | Omit<VuuRpcServiceRequest, \"context\"> =>\n message.type === \"RPC_REQUEST\";\n\nexport const hasViewPortContext = (\n message: VuuRpcServiceRequest,\n): message is VuuRpcServiceRequest<ViewportRpcContext> =>\n message.context.type === \"VIEWPORT_CONTEXT\";\n\nexport const isVuuMenuRpcRequest = (\n message: VuuRpcRequest | Omit<VuuRpcRequest, \"vpId\">,\n): message is VuuRpcMenuRequest => MENU_RPC_TYPES.includes(message[\"type\"]);\n\nexport const isLoginResponse = (\n message: unknown,\n): message is VuuLoginSuccessResponse =>\n message !== null &&\n typeof message === \"object\" &&\n \"type\" in message &&\n (message.type === \"LOGIN_SUCCESS\" || message.type === \"LOGIN_FAIL\");\n\nexport const isRpcSuccess = (\n rpcResult?: RpcResult,\n): rpcResult is RpcResultSuccess => rpcResult?.type === \"SUCCESS_RESULT\";\n\nexport const isRpcError = (\n rpcResult?: RpcResult,\n): rpcResult is RpcResultError => rpcResult?.type === \"ERROR_RESULT\";\n\nexport const isRequestResponse = (\n message: object,\n): message is VuuUiMessageInRequestResponse => \"requestId\" in message;\n\nexport const isOpenSessionTableDialogMessage = (\n rpcResponse: RpcResponse,\n): rpcResponse is MenuRpcResponse<OpenDialogActionWithSchema> =>\n rpcResponse.type === \"VIEW_PORT_MENU_RESP\" &&\n isOpenDialogAction(rpcResponse.action) &&\n \"tableSchema\" in rpcResponse.action;\n\nexport const isOpenDialogAction = (\n action?: MenuRpcAction,\n): action is OpenDialogAction =>\n action !== undefined && action.type === \"OPEN_DIALOG_ACTION\";\n\nexport const isTypeaheadRequest = (\n request: Omit<VuuRpcRequest, \"vpId\">,\n): request is Omit<VuuViewportRpcTypeaheadRequest, \"vpId\"> => {\n return (\n isRpcServiceRequest(request) &&\n (request.rpcName === \"getUniqueFieldValues\" ||\n request.rpcName === \"getUniqueFieldValuesStartingWith\")\n );\n};\n\nexport const isCreateVpSuccess = (\n response: VuuViewportCreateResponse,\n): response is VuuViewportCreateSuccessResponse =>\n response.type === \"CREATE_VP_SUCCESS\";\n\nexport const isSessionTable = (table?: unknown) => {\n if (\n table !== null &&\n typeof table === \"object\" &&\n \"table\" in table &&\n \"module\" in table\n ) {\n return (table as VuuTable).table.startsWith(\"session\");\n }\n return false;\n};\n\nexport function isActionMessage(\n rpcResponse: VuuRpcResponse,\n): rpcResponse is VuuRpcMenuSuccess;\nexport function isActionMessage(\n rpcResponse: Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is Omit<VuuRpcMenuSuccess, \"vpId\">;\nexport function isActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n) {\n return rpcResponse.type === \"VIEW_PORT_MENU_RESP\";\n}\n\nexport function isSessionTableActionMessage(\n rpcResponse: VuuRpcResponse,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n>;\nexport function isSessionTableActionMessage(\n rpcResponse: Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is Omit<\n VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n >,\n \"vpId\"\n>;\nexport function isSessionTableActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n> {\n return (\n isActionMessage(rpcResponse) &&\n isOpenDialogAction(rpcResponse.action) &&\n isSessionTable(rpcResponse.action.table) &&\n (rpcResponse.action?.renderComponent === \"inline-form\" ||\n rpcResponse.action?.renderComponent === \"grid\")\n );\n}\n\nexport function isCustomComponentActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenComponentInDialogAction & {\n tableSchema: TableSchema;\n }\n> {\n return (\n isActionMessage(rpcResponse) &&\n isOpenDialogAction(rpcResponse.action) &&\n isSessionTable(rpcResponse.action.table) &&\n typeof rpcResponse.action.renderComponent === \"string\" &&\n componentInRegistry(rpcResponse.action.renderComponent)\n );\n}\n\nconst numericTypes: VuuNumericType[] = [\n \"int\",\n \"long\",\n \"double\",\n \"scaleddecimal2\",\n \"scaleddecimal4\",\n \"scaleddecimal6\",\n \"scaleddecimal8\",\n];\n\nexport function isNumericType(\n dataType?: VuuColumnDataType,\n): dataType is VuuNumericType {\n return numericTypes.includes(dataType as VuuNumericType);\n}\n\nexport const isAddRowRpcRequest = (\n rpcRequest: VuuRpcServiceRequest,\n): rpcRequest is AddRowRpcServiceRequest => rpcRequest.rpcName === \"addRow\";\nexport const isEditCellRpcRequest = (\n rpcRequest: VuuRpcServiceRequest,\n): rpcRequest is EditCellRpcServiceRequest => rpcRequest.rpcName === \"editCell\";\nexport const isBeginEditSessionRpcRequest = (\n rpcRequest: VuuRpcServiceRequest,\n): rpcRequest is BeginEditSessionRpcServiceRequest =>\n rpcRequest.rpcName === \"beginEditSession\";\nexport const isEndEditSessionRpcRequest = (\n rpcRequest: VuuRpcServiceRequest,\n): rpcRequest is EndEditSessionRpcServiceRequest =>\n rpcRequest.rpcName === \"endEditSession\";\n"],"names":["componentInRegistry"],"mappings":";;;;AAyCA,MAAM,cAAiB,GAAA;AAAA,EACrB,4BAAA;AAAA,EACA,0BAAA;AAAA,EACA,wBAAA;AAAA,EACA;AACF,CAAA;AAEO,MAAM,eAAwC,GAAA;AAC9C,MAAM,sBACX,GAAA;AACK,MAAM,aAAoC,GAAA;AAC1C,MAAM,aAAoC,GAAA;AAEjD,MAAM,oBAAiC,GAAA;AAAA,EACrC,eAAA;AAAA,EACA,sBAAA;AAAA,EACA,aAAA;AAAA,EACA;AACF,CAAA;AAEO,MAAM,iBAAiB,CAC5B,OAAA,KAEA,OAAO,OAAW,IAAA,QAAA,IACjB,SAAiC,IAAS,KAAA;AAEhC,MAAA,mBAAA,GAAsB,CACjC,OAEA,KAAA,OAAO,YAAY,QAAY,IAAA,oBAAA,CAAqB,SAAS,OAAO;AAEzD,MAAA,eAAA,GAAkB,CAAC,OAC9B,KAAA,OAAA,IACA,OAAO,OAAY,KAAA,QAAA,IACnB,MAAU,IAAA,OAAA,KACT,OAAQ,CAAA,IAAA,KAAS,gBAChB,OAAQ,CAAA,IAAA,KAAS,kBACjB,OAAQ,CAAA,IAAA,KAAS,sBACjB,OAAQ,CAAA,IAAA,KAAS,YACjB,IAAA,OAAA,CAAQ,IAAS,KAAA,cAAA;AAER,MAAA,2BAAA,GAA8B,CACzC,QAEA,KAAA;AAAA,EACE,oBAAA;AAAA,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9D,MAAM,4BAA+B,GAAA,CAC1C,UAEA,KAAA,UAAA,CAAW,OAAY,KAAA;AAClB,MAAM,0BAA6B,GAAA,CACxC,UAEA,KAAA,UAAA,CAAW,OAAY,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"protocol-message-utils.js","sources":["../../../../../../packages/vuu-utils/src/protocol-message-utils.ts"],"sourcesContent":["import type {\n MenuRpcAction,\n MenuRpcResponse,\n OpenDialogActionWithSchema,\n RpcResponse,\n TableSchema,\n VuuUiMessageInRequestResponse,\n} from \"@vuu-ui/vuu-data-types\";\nimport {\n VuuRpcMenuRequest,\n OpenDialogAction,\n VuuRpcRequest,\n VuuRpcResponse,\n VuuRpcMenuSuccess,\n VuuTable,\n VuuViewportRpcTypeaheadRequest,\n VuuRpcServiceRequest,\n ViewportRpcContext,\n OpenComponentInDialogAction,\n VuuLoginSuccessResponse,\n SelectRequest,\n SelectResponse,\n SelectSuccessWithRowCount,\n VuuViewportCreateSuccessResponse,\n VuuViewportCreateResponse,\n InvalidTokenReason,\n InvalidSessionReason,\n LoginErrorMessage,\n RpcResult,\n RpcResultSuccess,\n RpcResultError,\n VuuColumnDataType,\n VuuNumericType,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { isView as componentInRegistry } from \"./component-registry\";\n\nconst MENU_RPC_TYPES = [\n \"VIEW_PORT_MENUS_SELECT_RPC\",\n \"VIEW_PORT_MENU_TABLE_RPC\",\n \"VIEW_PORT_MENU_ROW_RPC\",\n \"VIEW_PORT_MENU_CELL_RPC\",\n];\n\nexport const INVALID_SESSION: InvalidSessionReason = \"Invalid session\";\nexport const SESSION_LIMIT_EXCEEDED: InvalidSessionReason =\n \"User session limit exceeded\";\nexport const INVALID_TOKEN: InvalidTokenReason = \"Invalid token\";\nexport const TOKEN_EXPIRED: InvalidTokenReason = \"Token has expired\";\n\nconst InvalidLoginMessages: string[] = [\n INVALID_SESSION,\n SESSION_LIMIT_EXCEEDED,\n INVALID_TOKEN,\n TOKEN_EXPIRED,\n];\n\nexport const isLoginErrorMessage = (\n message: unknown,\n): message is LoginErrorMessage =>\n typeof message === \"string\" && InvalidLoginMessages.includes(message);\n\nexport const isSelectRequest = (message: object): message is SelectRequest =>\n message &&\n typeof message === \"object\" &&\n \"type\" in message &&\n (message.type === \"SELECT_ROW\" ||\n message.type === \"DESELECT_ROW\" ||\n message.type === \"SELECT_ROW_RANGE\" ||\n message.type === \"SELECT_ALL\" ||\n message.type === \"DESELECT_ALL\");\n\nexport const isSelectSuccessWithRowCount = (\n response: SelectResponse | SelectSuccessWithRowCount,\n): response is SelectSuccessWithRowCount =>\n [\n \"SELECT_ROW_SUCCESS\",\n \"DESELECT_ROW_SUCCESS\",\n \"SELECT_ROW_RANGE_SUCCESS\",\n \"SELECT_ALL_SUCCESS\",\n \"DESELECT_ALL_SUCCESS\",\n ].includes(response.type ?? \"\") &&\n typeof (response as SelectSuccessWithRowCount).selectedRowCount === \"number\";\n\nexport const isRpcServiceRequest = (message: {\n type: string;\n}): message is VuuRpcServiceRequest | Omit<VuuRpcServiceRequest, \"context\"> =>\n message.type === \"RPC_REQUEST\";\n\nexport const hasViewPortContext = (\n message: VuuRpcServiceRequest,\n): message is VuuRpcServiceRequest<ViewportRpcContext> =>\n message.context.type === \"VIEWPORT_CONTEXT\";\n\nexport const isVuuMenuRpcRequest = (\n message: VuuRpcRequest | Omit<VuuRpcRequest, \"vpId\">,\n): message is VuuRpcMenuRequest => MENU_RPC_TYPES.includes(message[\"type\"]);\n\nexport const isLoginResponse = (\n message: unknown,\n): message is VuuLoginSuccessResponse =>\n message !== null &&\n typeof message === \"object\" &&\n \"type\" in message &&\n (message.type === \"LOGIN_SUCCESS\" || message.type === \"LOGIN_FAIL\");\n\nexport const isRpcSuccess = (\n rpcResult?: RpcResult,\n): rpcResult is RpcResultSuccess => rpcResult?.type === \"SUCCESS_RESULT\";\n\nexport const isRpcError = (\n rpcResult?: RpcResult,\n): rpcResult is RpcResultError => rpcResult?.type === \"ERROR_RESULT\";\n\nexport const isRequestResponse = (\n message: object,\n): message is VuuUiMessageInRequestResponse => \"requestId\" in message;\n\nexport const isOpenSessionTableDialogMessage = (\n rpcResponse: RpcResponse,\n): rpcResponse is MenuRpcResponse<OpenDialogActionWithSchema> =>\n rpcResponse.type === \"VIEW_PORT_MENU_RESP\" &&\n isOpenDialogAction(rpcResponse.action) &&\n \"tableSchema\" in rpcResponse.action;\n\nexport const isOpenDialogAction = (\n action?: MenuRpcAction,\n): action is OpenDialogAction =>\n action !== undefined && action.type === \"OPEN_DIALOG_ACTION\";\n\nexport const isTypeaheadRequest = (\n request: Omit<VuuRpcRequest, \"vpId\">,\n): request is Omit<VuuViewportRpcTypeaheadRequest, \"vpId\"> => {\n return (\n isRpcServiceRequest(request) &&\n (request.rpcName === \"getUniqueFieldValues\" ||\n request.rpcName === \"getUniqueFieldValuesStartingWith\")\n );\n};\n\nexport const isCreateVpSuccess = (\n response: VuuViewportCreateResponse,\n): response is VuuViewportCreateSuccessResponse =>\n response.type === \"CREATE_VP_SUCCESS\";\n\nexport const isSessionTable = (table?: unknown) => {\n if (\n table !== null &&\n typeof table === \"object\" &&\n \"table\" in table &&\n \"module\" in table\n ) {\n return (table as VuuTable).table.startsWith(\"session\");\n }\n return false;\n};\n\nexport function isActionMessage(\n rpcResponse: VuuRpcResponse,\n): rpcResponse is VuuRpcMenuSuccess;\nexport function isActionMessage(\n rpcResponse: Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is Omit<VuuRpcMenuSuccess, \"vpId\">;\nexport function isActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n) {\n return rpcResponse.type === \"VIEW_PORT_MENU_RESP\";\n}\n\nexport function isSessionTableActionMessage(\n rpcResponse: VuuRpcResponse,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n>;\nexport function isSessionTableActionMessage(\n rpcResponse: Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is Omit<\n VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n >,\n \"vpId\"\n>;\nexport function isSessionTableActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenDialogAction & {\n tableSchema: TableSchema;\n }\n> {\n return (\n isActionMessage(rpcResponse) &&\n isOpenDialogAction(rpcResponse.action) &&\n isSessionTable(rpcResponse.action.table) &&\n (rpcResponse.action?.renderComponent === \"inline-form\" ||\n rpcResponse.action?.renderComponent === \"grid\")\n );\n}\n\nexport function isCustomComponentActionMessage(\n rpcResponse: VuuRpcResponse | Omit<VuuRpcResponse, \"vpId\">,\n): rpcResponse is VuuRpcMenuSuccess<\n OpenComponentInDialogAction & {\n tableSchema: TableSchema;\n }\n> {\n return (\n isActionMessage(rpcResponse) &&\n isOpenDialogAction(rpcResponse.action) &&\n isSessionTable(rpcResponse.action.table) &&\n typeof rpcResponse.action.renderComponent === \"string\" &&\n componentInRegistry(rpcResponse.action.renderComponent)\n );\n}\n\nconst numericTypes: VuuNumericType[] = [\n \"int\",\n \"long\",\n \"double\",\n \"scaleddecimal2\",\n \"scaleddecimal4\",\n \"scaleddecimal6\",\n \"scaleddecimal8\",\n];\n\nexport function isNumericType(\n dataType?: VuuColumnDataType,\n): dataType is VuuNumericType {\n return numericTypes.includes(dataType as VuuNumericType);\n}\n"],"names":["componentInRegistry"],"mappings":";;;;AAoCA,MAAM,cAAiB,GAAA;AAAA,EACrB,4BAAA;AAAA,EACA,0BAAA;AAAA,EACA,wBAAA;AAAA,EACA;AACF,CAAA;AAEO,MAAM,eAAwC,GAAA;AAC9C,MAAM,sBACX,GAAA;AACK,MAAM,aAAoC,GAAA;AAC1C,MAAM,aAAoC,GAAA;AAEjD,MAAM,oBAAiC,GAAA;AAAA,EACrC,eAAA;AAAA,EACA,sBAAA;AAAA,EACA,aAAA;AAAA,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A,KAAoB,YAC9CA,wBAAoB,CAAA,WAAA,CAAY,OAAO,eAAe,CAAA;AAE1D;AAEA,MAAM,YAAiC,GAAA;AAAA,EACrC,KAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA,gBAAA;AAAA,EACA,gBAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACF,CAAA;AAEO,SAAS,cACd,QAC4B,EAAA;AAC5B,EAAO,OAAA,YAAA,CAAa,SAAS,QAA0B,CAAA;AACzD;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React = require('react');
|
|
4
4
|
|
|
5
5
|
const EMPTY_ARRAY = [];
|
|
6
6
|
const asReactElements = (children) => {
|
|
7
7
|
const isArray = Array.isArray(children);
|
|
8
|
-
const count = isArray ? children.length :
|
|
9
|
-
if (isArray && children.every(
|
|
8
|
+
const count = isArray ? children.length : React.Children.count(children);
|
|
9
|
+
if (isArray && children.every(React.isValidElement)) {
|
|
10
10
|
return children;
|
|
11
|
-
} else if (count === 1 && !isArray &&
|
|
11
|
+
} else if (count === 1 && !isArray && React.isValidElement(children)) {
|
|
12
12
|
return [children];
|
|
13
13
|
} else if (count > 1) {
|
|
14
14
|
return children;
|
|
@@ -17,8 +17,8 @@ const asReactElements = (children) => {
|
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
const useIsMounted = (id = "") => {
|
|
20
|
-
const isMountedRef =
|
|
21
|
-
|
|
20
|
+
const isMountedRef = React.useRef(false);
|
|
21
|
+
React.useEffect(() => {
|
|
22
22
|
console.log(`is MOUNTED ${id}`);
|
|
23
23
|
isMountedRef.current = true;
|
|
24
24
|
return () => {
|
|
@@ -59,8 +59,8 @@ const createSyntheticEvent = (event) => {
|
|
|
59
59
|
};
|
|
60
60
|
};
|
|
61
61
|
const useStableReference = (value) => {
|
|
62
|
-
const referenceToProp =
|
|
63
|
-
|
|
62
|
+
const referenceToProp = React.useRef(value);
|
|
63
|
+
React.useMemo(() => referenceToProp.current = value, [value]);
|
|
64
64
|
return referenceToProp;
|
|
65
65
|
};
|
|
66
66
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-utils.js","sources":["../../../../../../packages/vuu-utils/src/react-utils.ts"],"sourcesContent":["import {\n Children,\n isValidElement,\n ReactElement,\n ReactNode,\n SetStateAction,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\n\nconst EMPTY_ARRAY: ReactElement[] = [];\n\nexport const asReactElements = (children: ReactNode): ReactElement[] => {\n const isArray = Array.isArray(children);\n const count = isArray ? children.length : Children.count(children);\n if (isArray && children.every(isValidElement)) {\n return children;\n } else if (count === 1 && !isArray && isValidElement(children)) {\n return [children];\n } else if (count > 1) {\n return children as ReactElement[];\n } else {\n return EMPTY_ARRAY;\n }\n};\n\nexport const useIsMounted = (id = \"\") => {\n const isMountedRef = useRef(false);\n useEffect(() => {\n console.log(`is MOUNTED ${id}`);\n isMountedRef.current = true;\n return () => {\n console.log(`is UNMOUNTED ${id}`);\n isMountedRef.current = false;\n };\n }, [id]);\n\n return isMountedRef;\n};\n\nexport const isSimpleStateValue = <T>(arg: SetStateAction<T>): arg is T =>\n typeof arg !== \"function\";\n\n/**\n * From an example by stack overflow user Maxim G\n */\nexport const createSyntheticEvent = <T extends Element, E extends Event>(\n event: E,\n): React.SyntheticEvent<T, E> => {\n let isDefaultPrevented = false;\n let isPropagationStopped = false;\n const preventDefault = () => {\n isDefaultPrevented = true;\n event.preventDefault();\n };\n const stopPropagation = () => {\n isPropagationStopped = true;\n event.stopPropagation();\n };\n return {\n nativeEvent: event,\n currentTarget: event.currentTarget as EventTarget & T,\n target: event.target as EventTarget & T,\n bubbles: event.bubbles,\n cancelable: event.cancelable,\n defaultPrevented: event.defaultPrevented,\n eventPhase: event.eventPhase,\n isTrusted: event.isTrusted,\n preventDefault,\n isDefaultPrevented: () => isDefaultPrevented,\n stopPropagation,\n isPropagationStopped: () => isPropagationStopped,\n persist: () => undefined,\n timeStamp: event.timeStamp,\n type: event.type,\n };\n};\n\n/**\n * Store a value in a RefObject and update that ref whenever the value changes.\n * Use to maintain a stable reference to a changing value that we need to use\n * within a hook, but when that hook does not need to be triggered just because\n * this value changes.\n */\nexport const useStableReference = <T>(value: T) => {\n const referenceToProp = useRef<T>(value);\n useMemo(() => (referenceToProp.current = value), [value]);\n return referenceToProp;\n};\n"],"names":["Children","isValidElement","useRef","useEffect","useMemo"],"mappings":";;;;AAWA,MAAM,cAA8B,EAAC;AAExB,MAAA,eAAA,GAAkB,CAAC,QAAwC,KAAA;AACtE,EAAM,MAAA,OAAA,GAAU,KAAM,CAAA,OAAA,CAAQ,QAAQ,CAAA;AACtC,EAAA,MAAM,QAAQ,OAAU,GAAA,QAAA,CAAS,MAAS,GAAAA,
|
|
1
|
+
{"version":3,"file":"react-utils.js","sources":["../../../../../../packages/vuu-utils/src/react-utils.ts"],"sourcesContent":["import {\n Children,\n isValidElement,\n ReactElement,\n ReactNode,\n SetStateAction,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\n\nconst EMPTY_ARRAY: ReactElement[] = [];\n\nexport const asReactElements = (children: ReactNode): ReactElement[] => {\n const isArray = Array.isArray(children);\n const count = isArray ? children.length : Children.count(children);\n if (isArray && children.every(isValidElement)) {\n return children;\n } else if (count === 1 && !isArray && isValidElement(children)) {\n return [children];\n } else if (count > 1) {\n return children as ReactElement[];\n } else {\n return EMPTY_ARRAY;\n }\n};\n\nexport const useIsMounted = (id = \"\") => {\n const isMountedRef = useRef(false);\n useEffect(() => {\n console.log(`is MOUNTED ${id}`);\n isMountedRef.current = true;\n return () => {\n console.log(`is UNMOUNTED ${id}`);\n isMountedRef.current = false;\n };\n }, [id]);\n\n return isMountedRef;\n};\n\nexport const isSimpleStateValue = <T>(arg: SetStateAction<T>): arg is T =>\n typeof arg !== \"function\";\n\n/**\n * From an example by stack overflow user Maxim G\n */\nexport const createSyntheticEvent = <T extends Element, E extends Event>(\n event: E,\n): React.SyntheticEvent<T, E> => {\n let isDefaultPrevented = false;\n let isPropagationStopped = false;\n const preventDefault = () => {\n isDefaultPrevented = true;\n event.preventDefault();\n };\n const stopPropagation = () => {\n isPropagationStopped = true;\n event.stopPropagation();\n };\n return {\n nativeEvent: event,\n currentTarget: event.currentTarget as EventTarget & T,\n target: event.target as EventTarget & T,\n bubbles: event.bubbles,\n cancelable: event.cancelable,\n defaultPrevented: event.defaultPrevented,\n eventPhase: event.eventPhase,\n isTrusted: event.isTrusted,\n preventDefault,\n isDefaultPrevented: () => isDefaultPrevented,\n stopPropagation,\n isPropagationStopped: () => isPropagationStopped,\n persist: () => undefined,\n timeStamp: event.timeStamp,\n type: event.type,\n };\n};\n\n/**\n * Store a value in a RefObject and update that ref whenever the value changes.\n * Use to maintain a stable reference to a changing value that we need to use\n * within a hook, but when that hook does not need to be triggered just because\n * this value changes.\n */\nexport const useStableReference = <T>(value: T) => {\n const referenceToProp = useRef<T>(value);\n useMemo(() => (referenceToProp.current = value), [value]);\n return referenceToProp;\n};\n"],"names":["Children","isValidElement","useRef","useEffect","useMemo"],"mappings":";;;;AAWA,MAAM,cAA8B,EAAC;AAExB,MAAA,eAAA,GAAkB,CAAC,QAAwC,KAAA;AACtE,EAAM,MAAA,OAAA,GAAU,KAAM,CAAA,OAAA,CAAQ,QAAQ,CAAA;AACtC,EAAA,MAAM,QAAQ,OAAU,GAAA,QAAA,CAAS,MAAS,GAAAA,cAAA,CAAS,MAAM,QAAQ,CAAA;AACjE,EAAA,IAAI,OAAW,IAAA,QAAA,CAAS,KAAM,CAAAC,oBAAc,CAAG,EAAA;AAC7C,IAAO,OAAA,QAAA;AAAA,aACE,KAAU,KAAA,CAAA,IAAK,CAAC,OAAW,IAAAA,oBAAA,CAAe,QAAQ,CAAG,EAAA;AAC9D,IAAA,OAAO,CAAC,QAAQ,CAAA;AAAA,GAClB,MAAA,IAAW,QAAQ,CAAG,EAAA;AACp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UAAA;AAAA,IAClB,WAAW,KAAM,CAAA,SAAA;AAAA,IACjB,cAAA;AAAA,IACA,oBAAoB,MAAM,kBAAA;AAAA,IAC1B,eAAA;AAAA,IACA,sBAAsB,MAAM,oBAAA;AAAA,IAC5B,SAAS,MAAM,KAAA,CAAA;AAAA,IACf,WAAW,KAAM,CAAA,SAAA;AAAA,IACjB,MAAM,KAAM,CAAA;AAAA,GACd;AACF;AAQa,MAAA,kBAAA,GAAqB,CAAI,KAAa,KAAA;AACjD,EAAM,MAAA,eAAA,GAAkBD,aAAU,KAAK,CAAA;AACvC,EAAAE,aAAA,CAAQ,MAAO,eAAgB,CAAA,OAAA,GAAU,KAAQ,EAAA,CAAC,KAAK,CAAC,CAAA;AACxD,EAAO,OAAA,eAAA;AACT;;;;;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React = require('react');
|
|
4
4
|
|
|
5
5
|
const checkCssToken = (tokenName) => new Promise((resolve) => {
|
|
6
6
|
requestAnimationFrame(() => {
|
|
@@ -15,8 +15,8 @@ const ThemeLoadChecker = ({
|
|
|
15
15
|
cssToken = "--salt-spacing-100",
|
|
16
16
|
theme
|
|
17
17
|
}) => {
|
|
18
|
-
const [ready, setReady] =
|
|
19
|
-
|
|
18
|
+
const [ready, setReady] = React.useState(false);
|
|
19
|
+
React.useMemo(async () => {
|
|
20
20
|
let ready2 = await checkCssToken(cssToken);
|
|
21
21
|
while (!ready2) {
|
|
22
22
|
ready2 = await checkCssToken(cssToken);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-utils.js","sources":["../../../../../../packages/vuu-utils/src/theme-utils.ts"],"sourcesContent":["import { ReactNode, useMemo, useState } from \"react\";\n\nconst checkCssToken = (tokenName: string): Promise<boolean> =>\n new Promise((resolve) => {\n requestAnimationFrame(() => {\n const saltSpacing100 = getComputedStyle(\n document.documentElement,\n ).getPropertyValue(tokenName);\n resolve(saltSpacing100 !== \"\");\n });\n });\n\n/**\n * Checks that a theme is loaded by making sure a known css variable\n * returns a value. Not normally needed except for cases where a theme\n * is loaded dynamically on startup and there may be components that\n * may fail if theme is not in place (eg component that rely on taking dom\n * measurements).\n * Used by Showcase.\n */\nexport const ThemeLoadChecker = ({\n children,\n cssToken = \"--salt-spacing-100\",\n theme,\n}: {\n children: ReactNode;\n cssToken?: string;\n theme: string;\n}) => {\n const [ready, setReady] = useState(false);\n\n useMemo(async () => {\n let ready = await checkCssToken(cssToken);\n while (!ready) {\n ready = await checkCssToken(cssToken);\n }\n setReady(true);\n }, [cssToken]);\n\n if (theme === \"no-theme\") {\n return children;\n }\n\n if (ready === false) {\n return null;\n }\n\n return children;\n};\n"],"names":["useState","useMemo","ready"],"mappings":";;;;AAEA,MAAM,gBAAgB,CAAC,SAAA,KACrB,IAAI,OAAA,CAAQ,CAAC,OAAY,KAAA;AACvB,EAAA,qBAAA,CAAsB,MAAM;AAC1B,IAAA,MAAM,cAAiB,GAAA,gBAAA;AAAA,MACrB,QAAS,CAAA;AAAA,KACX,CAAE,iBAAiB,SAAS,CAAA;AAC5B,IAAA,OAAA,CAAQ,mBAAmB,EAAE,CAAA;AAAA,GAC9B,CAAA;AACH,CAAC,CAAA;AAUI,MAAM,mBAAmB,CAAC;AAAA,EAC/B,QAAA;AAAA,EACA,QAAW,GAAA,oBAAA;AAAA,EACX;AACF,CAIM,KAAA;AACJ,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAIA,
|
|
1
|
+
{"version":3,"file":"theme-utils.js","sources":["../../../../../../packages/vuu-utils/src/theme-utils.ts"],"sourcesContent":["import { ReactNode, useMemo, useState } from \"react\";\n\nconst checkCssToken = (tokenName: string): Promise<boolean> =>\n new Promise((resolve) => {\n requestAnimationFrame(() => {\n const saltSpacing100 = getComputedStyle(\n document.documentElement,\n ).getPropertyValue(tokenName);\n resolve(saltSpacing100 !== \"\");\n });\n });\n\n/**\n * Checks that a theme is loaded by making sure a known css variable\n * returns a value. Not normally needed except for cases where a theme\n * is loaded dynamically on startup and there may be components that\n * may fail if theme is not in place (eg component that rely on taking dom\n * measurements).\n * Used by Showcase.\n */\nexport const ThemeLoadChecker = ({\n children,\n cssToken = \"--salt-spacing-100\",\n theme,\n}: {\n children: ReactNode;\n cssToken?: string;\n theme: string;\n}) => {\n const [ready, setReady] = useState(false);\n\n useMemo(async () => {\n let ready = await checkCssToken(cssToken);\n while (!ready) {\n ready = await checkCssToken(cssToken);\n }\n setReady(true);\n }, [cssToken]);\n\n if (theme === \"no-theme\") {\n return children;\n }\n\n if (ready === false) {\n return null;\n }\n\n return children;\n};\n"],"names":["useState","useMemo","ready"],"mappings":";;;;AAEA,MAAM,gBAAgB,CAAC,SAAA,KACrB,IAAI,OAAA,CAAQ,CAAC,OAAY,KAAA;AACvB,EAAA,qBAAA,CAAsB,MAAM;AAC1B,IAAA,MAAM,cAAiB,GAAA,gBAAA;AAAA,MACrB,QAAS,CAAA;AAAA,KACX,CAAE,iBAAiB,SAAS,CAAA;AAC5B,IAAA,OAAA,CAAQ,mBAAmB,EAAE,CAAA;AAAA,GAC9B,CAAA;AACH,CAAC,CAAA;AAUI,MAAM,mBAAmB,CAAC;AAAA,EAC/B,QAAA;AAAA,EACA,QAAW,GAAA,oBAAA;AAAA,EACX;AACF,CAIM,KAAA;AACJ,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAIA,eAAS,KAAK,CAAA;AAExC,EAAAC,aAAA,CAAQ,YAAY;AAClB,IAAIC,IAAAA,MAAAA,GAAQ,MAAM,aAAA,CAAc,QAAQ,CAAA;AACxC,IAAA,OAAO,CAACA,MAAO,EAAA;AACb,MAAAA,MAAAA,GAAQ,MAAM,aAAA,CAAc,QAAQ,CAAA;AAAA;AAEtC,IAAA,QAAA,CAAS,IAAI,CAAA;AAAA,GACf,EAAG,CAAC,QAAQ,CAAC,CAAA;AAEb,EAAA,IAAI,UAAU,UAAY,EAAA;AACxB,IAAO,OAAA,QAAA;AAAA;AAGT,EAAA,IAAI,UAAU,KAAO,EAAA;AACnB,IAAO,OAAA,IAAA;AAAA;AAGT,EAAO,OAAA,QAAA;AACT;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React = require('react');
|
|
4
4
|
|
|
5
5
|
let vuuComponentIdCount = 0;
|
|
6
|
-
const useId = (id) =>
|
|
6
|
+
const useId = (id) => React.useMemo(() => id ?? `vuu-${++vuuComponentIdCount}`, [id]);
|
|
7
7
|
|
|
8
8
|
exports.useId = useId;
|
|
9
9
|
//# sourceMappingURL=useId.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useId.js","sources":["../../../../../../packages/vuu-utils/src/useId.ts"],"sourcesContent":["import { useMemo } from \"react\";\n\nlet vuuComponentIdCount = 0;\n\nexport const useId = (id?: string) =>\n useMemo(() => id ?? `vuu-${++vuuComponentIdCount}`, [id]);\n"],"names":["useMemo"],"mappings":";;;;AAEA,IAAI,mBAAsB,GAAA,CAAA;AAEnB,MAAM,KAAQ,GAAA,CAAC,EACpB,KAAAA,
|
|
1
|
+
{"version":3,"file":"useId.js","sources":["../../../../../../packages/vuu-utils/src/useId.ts"],"sourcesContent":["import { useMemo } from \"react\";\n\nlet vuuComponentIdCount = 0;\n\nexport const useId = (id?: string) =>\n useMemo(() => id ?? `vuu-${++vuuComponentIdCount}`, [id]);\n"],"names":["useMemo"],"mappings":";;;;AAEA,IAAI,mBAAsB,GAAA,CAAA;AAEnB,MAAM,KAAQ,GAAA,CAAC,EACpB,KAAAA,aAAA,CAAQ,MAAM,EAAA,IAAM,CAAO,IAAA,EAAA,EAAE,mBAAmB,CAAA,CAAA,EAAI,CAAC,EAAE,CAAC;;;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React = require('react');
|
|
4
4
|
|
|
5
5
|
const useLayoutEffectSkipFirst = (func, deps) => {
|
|
6
|
-
const goodToGo =
|
|
7
|
-
|
|
6
|
+
const goodToGo = React.useRef(false);
|
|
7
|
+
React.useLayoutEffect(() => {
|
|
8
8
|
if (goodToGo.current) {
|
|
9
9
|
func();
|
|
10
10
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLayoutEffectSkipFirst.js","sources":["../../../../../../packages/vuu-utils/src/useLayoutEffectSkipFirst.ts"],"sourcesContent":["import { DependencyList, EffectCallback, useLayoutEffect, useRef } from \"react\";\n\nexport const useLayoutEffectSkipFirst = (\n func: EffectCallback,\n deps: DependencyList\n) => {\n const goodToGo = useRef(false);\n useLayoutEffect(() => {\n if (goodToGo.current) {\n func();\n } else {\n goodToGo.current = true;\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n};\n"],"names":["useRef","useLayoutEffect"],"mappings":";;;;AAEa,MAAA,wBAAA,GAA2B,CACtC,IAAA,EACA,IACG,KAAA;AACH,EAAM,MAAA,QAAA,GAAWA,
|
|
1
|
+
{"version":3,"file":"useLayoutEffectSkipFirst.js","sources":["../../../../../../packages/vuu-utils/src/useLayoutEffectSkipFirst.ts"],"sourcesContent":["import { DependencyList, EffectCallback, useLayoutEffect, useRef } from \"react\";\n\nexport const useLayoutEffectSkipFirst = (\n func: EffectCallback,\n deps: DependencyList\n) => {\n const goodToGo = useRef(false);\n useLayoutEffect(() => {\n if (goodToGo.current) {\n func();\n } else {\n goodToGo.current = true;\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n};\n"],"names":["useRef","useLayoutEffect"],"mappings":";;;;AAEa,MAAA,wBAAA,GAA2B,CACtC,IAAA,EACA,IACG,KAAA;AACH,EAAM,MAAA,QAAA,GAAWA,aAAO,KAAK,CAAA;AAC7B,EAAAC,qBAAA,CAAgB,MAAM;AACpB,IAAA,IAAI,SAAS,OAAS,EAAA;AACpB,MAAK,IAAA,EAAA;AAAA,KACA,MAAA;AACL,MAAA,QAAA,CAAS,OAAU,GAAA,IAAA;AAAA;AACrB,KAEC,IAAI,CAAA;AACT;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React = require('react');
|
|
4
4
|
|
|
5
5
|
const WidthHeight = ["height", "width"];
|
|
6
6
|
const WidthOnly = ["width"];
|
|
@@ -54,8 +54,8 @@ const resizeObserver = new ResizeObserver((entries) => {
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
function useResizeObserver(ref, dimensions, onResize, reportInitialSize = false) {
|
|
57
|
-
const dimensionsRef =
|
|
58
|
-
const measure =
|
|
57
|
+
const dimensionsRef = React.useRef(dimensions);
|
|
58
|
+
const measure = React.useCallback((target) => {
|
|
59
59
|
const { width, height } = target.getBoundingClientRect();
|
|
60
60
|
const { clientWidth: contentWidth, clientHeight: contentHeight } = target;
|
|
61
61
|
const flooredHeight = Math.floor(height);
|
|
@@ -77,7 +77,7 @@ function useResizeObserver(ref, dimensions, onResize, reportInitialSize = false)
|
|
|
77
77
|
{}
|
|
78
78
|
);
|
|
79
79
|
}, []);
|
|
80
|
-
|
|
80
|
+
React.useEffect(() => {
|
|
81
81
|
const target = ref.current;
|
|
82
82
|
async function registerObserver() {
|
|
83
83
|
observedMap.set(target, { measurements: {} });
|
|
@@ -114,7 +114,7 @@ function useResizeObserver(ref, dimensions, onResize, reportInitialSize = false)
|
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
116
|
}, [measure, ref]);
|
|
117
|
-
|
|
117
|
+
React.useEffect(() => {
|
|
118
118
|
const target = ref.current;
|
|
119
119
|
const record = observedMap.get(target);
|
|
120
120
|
if (record) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResizeObserver.js","sources":["../../../../../../packages/vuu-utils/src/useResizeObserver.ts"],"sourcesContent":["import { RefObject, useCallback, useEffect, useRef } from \"react\";\n\nexport const WidthHeight = [\"height\", \"width\"];\nexport const WidthOnly = [\"width\"];\n\nexport type measurements<T = string | number> = {\n height?: T;\n clientHeight?: number;\n clientWidth?: number;\n contentHeight?: number;\n contentWidth?: number;\n scrollHeight?: number;\n scrollWidth?: number;\n width?: T;\n};\ntype measuredDimension = keyof measurements<number>;\n\nexport type ResizeHandler = (measurements: measurements<number>) => void;\n\ntype observedDetails = {\n onResize?: ResizeHandler;\n measurements: measurements<number>;\n};\nconst observedMap = new Map<HTMLElement, observedDetails>();\n\nconst getTargetSize = (\n element: HTMLElement,\n size: {\n height: number;\n width: number;\n contentHeight: number;\n contentWidth: number;\n },\n dimension: measuredDimension,\n): number => {\n switch (dimension) {\n case \"height\":\n return size.height;\n case \"clientHeight\":\n return Math.floor(element.clientHeight);\n case \"clientWidth\":\n return Math.floor(element.clientWidth);\n case \"contentHeight\":\n return size.contentHeight;\n case \"contentWidth\":\n return size.contentWidth;\n case \"scrollHeight\":\n return Math.ceil(Math.floor(element.scrollHeight));\n case \"scrollWidth\":\n return Math.ceil(Math.floor(element.scrollWidth));\n case \"width\":\n return size.width;\n default:\n return 0;\n }\n};\n\n// TODO should we make this create-on-demand\nconst resizeObserver = new ResizeObserver((entries: ResizeObserverEntry[]) => {\n for (const entry of entries) {\n const { target, borderBoxSize, contentBoxSize } = entry;\n const observedTarget = observedMap.get(target as HTMLElement);\n if (observedTarget) {\n const [{ blockSize: height, inlineSize: width }] = borderBoxSize;\n const [{ blockSize: contentHeight, inlineSize: contentWidth }] =\n contentBoxSize;\n const { onResize, measurements } = observedTarget;\n let sizeChanged = false;\n for (const [dimension, size] of Object.entries(measurements)) {\n const newSize = getTargetSize(\n target as HTMLElement,\n { height, width, contentHeight, contentWidth },\n dimension as measuredDimension,\n );\n\n if (newSize !== size) {\n sizeChanged = true;\n measurements[dimension as measuredDimension] = newSize;\n }\n }\n if (sizeChanged) {\n // TODO only return measured sizes\n onResize && onResize(measurements);\n }\n }\n }\n});\n\n// TODO use an optional lag (default to false) to ask to fire onResize\n// with initial size\nexport function useResizeObserver(\n ref: RefObject<Element | HTMLElement | null>,\n dimensions: readonly string[],\n onResize: ResizeHandler,\n reportInitialSize = false,\n) {\n const dimensionsRef = useRef(dimensions);\n\n const measure = useCallback((target: HTMLElement): measurements<number> => {\n const { width, height } = target.getBoundingClientRect();\n const { clientWidth: contentWidth, clientHeight: contentHeight } = target;\n const flooredHeight = Math.floor(height);\n const flooredWidth = Math.floor(width);\n\n return dimensionsRef.current.reduce(\n (map: { [key: string]: number }, dim) => {\n map[dim] = getTargetSize(\n target,\n {\n width: flooredWidth,\n height: flooredHeight,\n contentHeight,\n contentWidth,\n },\n dim as measuredDimension,\n );\n return map;\n },\n {},\n );\n }, []);\n\n // TODO use ref to store resizeHandler here\n // resize handler registered with REsizeObserver will never change\n // use ref to store user onResize callback here\n // resizeHandler will call user callback.current\n\n // Keep this effect separate in case user inadvertently passes different\n // dimensions or callback instance each time - we only ever want to\n // initiate new observation when ref changes.\n useEffect(() => {\n const target = ref.current as HTMLElement;\n async function registerObserver() {\n // Create the map entry immediately. useEffect may fire below\n // before fonts are ready and attempt to update entry\n observedMap.set(target, { measurements: {} as measurements<number> });\n // await document.fonts.ready;\n const observedTarget = observedMap.get(target);\n if (observedTarget) {\n const measurements = measure(target);\n observedTarget.measurements = measurements;\n resizeObserver.observe(target);\n if (reportInitialSize) {\n onResize(measurements);\n }\n } else {\n console.log(\n `%cuseResizeObserver an target expected to be under observation wa snot found. This warrants investigation`,\n \"font-weight:bold; color:red;\",\n );\n }\n }\n\n if (target) {\n // TODO might we want multiple callers to attach a listener to the same element ?\n if (observedMap.has(target)) {\n console.log(\n `useResizeObserver attemping to observe same element twice`,\n {\n target,\n },\n );\n // throw Error(\n // \"useResizeObserver attemping to observe same element twice\"\n // );\n }\n // TODO set a pending entry on map\n registerObserver();\n }\n return () => {\n if (target && observedMap.has(target)) {\n resizeObserver.unobserve(target);\n observedMap.delete(target);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [measure, ref]);\n\n useEffect(() => {\n const target = ref.current as HTMLElement;\n const record = observedMap.get(target);\n if (record) {\n if (dimensionsRef.current !== dimensions) {\n dimensionsRef.current = dimensions;\n const measurements = measure(target);\n record.measurements = measurements;\n }\n // Might not have changed, but no harm ...\n record.onResize = onResize;\n }\n }, [dimensions, measure, ref, onResize]);\n}\n"],"names":["useRef","useCallback","useEffect"],"mappings":";;;;AAEa,MAAA,WAAA,GAAc,CAAC,QAAA,EAAU,OAAO;AAChC,MAAA,SAAA,GAAY,CAAC,OAAO;AAoBjC,MAAM,WAAA,uBAAkB,GAAkC,EAAA;AAE1D,MAAM,aAAgB,GAAA,CACpB,OACA,EAAA,IAAA,EAMA,SACW,KAAA;AACX,EAAA,QAAQ,SAAW;AAAA,IACjB,KAAK,QAAA;AACH,MAAA,OAAO,IAAK,CAAA,MAAA;AAAA,IACd,KAAK,cAAA;AACH,MAAO,OAAA,IAAA,CAAK,KAAM,CAAA,OAAA,CAAQ,YAAY,CAAA;AAAA,IACxC,KAAK,aAAA;AACH,MAAO,OAAA,IAAA,CAAK,KAAM,CAAA,OAAA,CAAQ,WAAW,CAAA;AAAA,IACvC,KAAK,eAAA;AACH,MAAA,OAAO,IAAK,CAAA,aAAA;AAAA,IACd,KAAK,cAAA;AACH,MAAA,OAAO,IAAK,CAAA,YAAA;AAAA,IACd,KAAK,cAAA;AACH,MAAA,OAAO,KAAK,IAAK,CAAA,IAAA,CAAK,KAAM,CAAA,OAAA,CAAQ,YAAY,CAAC,CAAA;AAAA,IACnD,KAAK,aAAA;AACH,MAAA,OAAO,KAAK,IAAK,CAAA,IAAA,CAAK,KAAM,CAAA,OAAA,CAAQ,WAAW,CAAC,CAAA;AAAA,IAClD,KAAK,OAAA;AACH,MAAA,OAAO,IAAK,CAAA,KAAA;AAAA,IACd;AACE,MAAO,OAAA,CAAA;AAAA;AAEb,CAAA;AAGA,MAAM,cAAiB,GAAA,IAAI,cAAe,CAAA,C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,EAAA;AAEV,MAAI,IAAA,WAAA,CAAY,GAAI,CAAA,MAAM,CAAG,EAAA;AAC3B,QAAQ,OAAA,CAAA,GAAA;AAAA,UACN,CAAA,yDAAA,CAAA;AAAA,UACA;AAAA,YACE;AAAA;AACF,SACF;AAAA;AAMF,MAAiB,gBAAA,EAAA;AAAA;AAEnB,IAAA,OAAO,MAAM;AACX,MAAA,IAAI,MAAU,IAAA,WAAA,CAAY,GAAI,CAAA,MAAM,CAAG,EAAA;AACrC,QAAA,cAAA,CAAe,UAAU,MAAM,CAAA;AAC/B,QAAA,WAAA,CAAY,OAAO,MAAM,CAAA;AAAA;AAC3B,KACF;AAAA,GAEC,EAAA,CAAC,OAAS,EAAA,GAAG,CAAC,CAAA;AAEjB,EAAAA,2CAAA,CAAU,MAAM;AACd,IAAA,MAAM,SAAS,GAAI,CAAA,OAAA;AACnB,IAAM,MAAA,MAAA,GAAS,WAAY,CAAA,GAAA,CAAI,MAAM,CAAA;AACrC,IAAA,IAAI,MAAQ,EAAA;AACV,MAAI,IAAA,aAAA,CAAc,YAAY,UAAY,EAAA;AACxC,QAAA,aAAA,CAAc,OAAU,GAAA,UAAA;AACxB,QAAM,MAAA,YAAA,GAAe,QAAQ,MAAM,CAAA;AACnC,QAAA,MAAA,CAAO,YAAe,GAAA,YAAA;AAAA;AAGxB,MAAA,MAAA,CAAO,QAAW,GAAA,QAAA;AAAA;AACpB,KACC,CAAC,UAAA,EAAY,OAAS,EAAA,GAAA,EAAK,QAAQ,CAAC,CAAA;AACzC;;;;;;"}
|
|
1
|
+
{"version":3,"file":"useResizeObserver.js","sources":["../../../../../../packages/vuu-utils/src/useResizeObserver.ts"],"sourcesContent":["import { RefObject, useCallback, useEffect, useRef } from \"react\";\n\nexport const WidthHeight = [\"height\", \"width\"];\nexport const WidthOnly = [\"width\"];\n\nexport type measurements<T = string | number> = {\n height?: T;\n clientHeight?: number;\n clientWidth?: number;\n contentHeight?: number;\n contentWidth?: number;\n scrollHeight?: number;\n scrollWidth?: number;\n width?: T;\n};\ntype measuredDimension = keyof measurements<number>;\n\nexport type ResizeHandler = (measurements: measurements<number>) => void;\n\ntype observedDetails = {\n onResize?: ResizeHandler;\n measurements: measurements<number>;\n};\nconst observedMap = new Map<HTMLElement, observedDetails>();\n\nconst getTargetSize = (\n element: HTMLElement,\n size: {\n height: number;\n width: number;\n contentHeight: number;\n contentWidth: number;\n },\n dimension: measuredDimension,\n): number => {\n switch (dimension) {\n case \"height\":\n return size.height;\n case \"clientHeight\":\n return Math.floor(element.clientHeight);\n case \"clientWidth\":\n return Math.floor(element.clientWidth);\n case \"contentHeight\":\n return size.contentHeight;\n case \"contentWidth\":\n return size.contentWidth;\n case \"scrollHeight\":\n return Math.ceil(Math.floor(element.scrollHeight));\n case \"scrollWidth\":\n return Math.ceil(Math.floor(element.scrollWidth));\n case \"width\":\n return size.width;\n default:\n return 0;\n }\n};\n\n// TODO should we make this create-on-demand\nconst resizeObserver = new ResizeObserver((entries: ResizeObserverEntry[]) => {\n for (const entry of entries) {\n const { target, borderBoxSize, contentBoxSize } = entry;\n const observedTarget = observedMap.get(target as HTMLElement);\n if (observedTarget) {\n const [{ blockSize: height, inlineSize: width }] = borderBoxSize;\n const [{ blockSize: contentHeight, inlineSize: contentWidth }] =\n contentBoxSize;\n const { onResize, measurements } = observedTarget;\n let sizeChanged = false;\n for (const [dimension, size] of Object.entries(measurements)) {\n const newSize = getTargetSize(\n target as HTMLElement,\n { height, width, contentHeight, contentWidth },\n dimension as measuredDimension,\n );\n\n if (newSize !== size) {\n sizeChanged = true;\n measurements[dimension as measuredDimension] = newSize;\n }\n }\n if (sizeChanged) {\n // TODO only return measured sizes\n onResize && onResize(measurements);\n }\n }\n }\n});\n\n// TODO use an optional lag (default to false) to ask to fire onResize\n// with initial size\nexport function useResizeObserver(\n ref: RefObject<Element | HTMLElement | null>,\n dimensions: readonly string[],\n onResize: ResizeHandler,\n reportInitialSize = false,\n) {\n const dimensionsRef = useRef(dimensions);\n\n const measure = useCallback((target: HTMLElement): measurements<number> => {\n const { width, height } = target.getBoundingClientRect();\n const { clientWidth: contentWidth, clientHeight: contentHeight } = target;\n const flooredHeight = Math.floor(height);\n const flooredWidth = Math.floor(width);\n\n return dimensionsRef.current.reduce(\n (map: { [key: string]: number }, dim) => {\n map[dim] = getTargetSize(\n target,\n {\n width: flooredWidth,\n height: flooredHeight,\n contentHeight,\n contentWidth,\n },\n dim as measuredDimension,\n );\n return map;\n },\n {},\n );\n }, []);\n\n // TODO use ref to store resizeHandler here\n // resize handler registered with REsizeObserver will never change\n // use ref to store user onResize callback here\n // resizeHandler will call user callback.current\n\n // Keep this effect separate in case user inadvertently passes different\n // dimensions or callback instance each time - we only ever want to\n // initiate new observation when ref changes.\n useEffect(() => {\n const target = ref.current as HTMLElement;\n async function registerObserver() {\n // Create the map entry immediately. useEffect may fire below\n // before fonts are ready and attempt to update entry\n observedMap.set(target, { measurements: {} as measurements<number> });\n // await document.fonts.ready;\n const observedTarget = observedMap.get(target);\n if (observedTarget) {\n const measurements = measure(target);\n observedTarget.measurements = measurements;\n resizeObserver.observe(target);\n if (reportInitialSize) {\n onResize(measurements);\n }\n } else {\n console.log(\n `%cuseResizeObserver an target expected to be under observation wa snot found. This warrants investigation`,\n \"font-weight:bold; color:red;\",\n );\n }\n }\n\n if (target) {\n // TODO might we want multiple callers to attach a listener to the same element ?\n if (observedMap.has(target)) {\n console.log(\n `useResizeObserver attemping to observe same element twice`,\n {\n target,\n },\n );\n // throw Error(\n // \"useResizeObserver attemping to observe same element twice\"\n // );\n }\n // TODO set a pending entry on map\n registerObserver();\n }\n return () => {\n if (target && observedMap.has(target)) {\n resizeObserver.unobserve(target);\n observedMap.delete(target);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [measure, ref]);\n\n useEffect(() => {\n const target = ref.current as HTMLElement;\n const record = observedMap.get(target);\n if (record) {\n if (dimensionsRef.current !== dimensions) {\n dimensionsRef.current = dimensions;\n const measurements = measure(target);\n record.measurements = measurements;\n }\n // Might not have changed, but no harm ...\n record.onResize = onResize;\n }\n }, [dimensions, measure, ref, onResize]);\n}\n"],"names":["useRef","useCallback","useEffect"],"mappings":";;;;AAEa,MAAA,WAAA,GAAc,CAAC,QAAA,EAAU,OAAO;AAChC,MAAA,SAAA,GAAY,CAAC,OAAO;AAoBjC,MAAM,WAAA,uBAAkB,GAAkC,EAAA;AAE1D,MAAM,aAAgB,GAAA,CACpB,OACA,EAAA,IAAA,EAMA,SACW,KAAA;AACX,EAAA,QAAQ,SAAW;AAAA,IACjB,KAAK,QAAA;AACH,MAAA,OAAO,IAAK,CAAA,MAAA;AAAA,IACd,KAAK,cAAA;AACH,MAAO,OAAA,IAAA,CAAK,KAAM,CAAA,OAAA,CAAQ,YAAY,CAAA;AAAA,IACxC,KAAK,aAAA;AACH,MAAO,OAAA,IAAA,CAAK,KAAM,CAAA,OAAA,CAAQ,WAAW,CAAA;AAAA,IACvC,KAAK,eAAA;AACH,MAAA,OAAO,IAAK,CAAA,aAAA;AAAA,IACd,KAAK,cAAA;AACH,MAAA,OAAO,IAAK,CAAA,YAAA;AAAA,IACd,KAAK,cAAA;AACH,MAAA,OAAO,KAAK,IAAK,CAAA,IAAA,CAAK,KAAM,CAAA,OAAA,CAAQ,YAAY,CAAC,CAAA;AAAA,IACnD,KAAK,aAAA;AACH,MAAA,OAAO,KAAK,IAAK,CAAA,IAAA,CAAK,KAAM,CAAA,OAAA,CAAQ,WAAW,CAAC,CAAA;AAAA,IAClD,KAAK,OAAA;AACH,MAAA,OAAO,IAAK,CAAA,KAAA;AAAA,IACd;AACE,MAAO,OAAA,CAAA;AAAA;AAEb,CAAA;AAGA,MAAM,cAAiB,GAAA,IAAI,cAAe,CAAA,CAAC,OAAmC,KAAA;AAC5E,EAAA,KAAA,MAAW,SAAS,OAAS,EAAA;AAC3B,IAAA,MAAM,EAAE,MAAA,EAAQ,aAAe,EAAA,cAAA,EAAmB,GAAA,KAAA;AAClD,IAAM,MAAA,cAAA,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ACF;AAAA;AAMF,MAAiB,gBAAA,EAAA;AAAA;AAEnB,IAAA,OAAO,MAAM;AACX,MAAA,IAAI,MAAU,IAAA,WAAA,CAAY,GAAI,CAAA,MAAM,CAAG,EAAA;AACrC,QAAA,cAAA,CAAe,UAAU,MAAM,CAAA;AAC/B,QAAA,WAAA,CAAY,OAAO,MAAM,CAAA;AAAA;AAC3B,KACF;AAAA,GAEC,EAAA,CAAC,OAAS,EAAA,GAAG,CAAC,CAAA;AAEjB,EAAAA,eAAA,CAAU,MAAM;AACd,IAAA,MAAM,SAAS,GAAI,CAAA,OAAA;AACnB,IAAM,MAAA,MAAA,GAAS,WAAY,CAAA,GAAA,CAAI,MAAM,CAAA;AACrC,IAAA,IAAI,MAAQ,EAAA;AACV,MAAI,IAAA,aAAA,CAAc,YAAY,UAAY,EAAA;AACxC,QAAA,aAAA,CAAc,OAAU,GAAA,UAAA;AACxB,QAAM,MAAA,YAAA,GAAe,QAAQ,MAAM,CAAA;AACnC,QAAA,MAAA,CAAO,YAAe,GAAA,YAAA;AAAA;AAGxB,MAAA,MAAA,CAAO,QAAW,GAAA,QAAA;AAAA;AACpB,KACC,CAAC,UAAA,EAAY,OAAS,EAAA,GAAA,EAAK,QAAQ,CAAC,CAAA;AACzC;;;;;;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React = require('react');
|
|
4
4
|
|
|
5
5
|
const isSimpleStateValue = (arg) => typeof arg !== "function";
|
|
6
6
|
const useStateRef = (initialValue) => {
|
|
7
|
-
const [value, _setValue] =
|
|
8
|
-
const ref =
|
|
9
|
-
const setValue =
|
|
7
|
+
const [value, _setValue] = React.useState(initialValue);
|
|
8
|
+
const ref = React.useRef(value);
|
|
9
|
+
const setValue = React.useCallback((arg) => {
|
|
10
10
|
if (isSimpleStateValue(arg)) {
|
|
11
11
|
ref.current = arg;
|
|
12
12
|
_setValue(arg);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStateRef.js","sources":["../../../../../../packages/vuu-utils/src/useStateRef.ts"],"sourcesContent":["import {\n Dispatch,\n RefObject,\n SetStateAction,\n useCallback,\n useRef,\n useState,\n} from \"react\";\n\n/**\n * Extension to useState that maintains a ref for the\n * current state value. Useful where use of the ref can\n * avoid referencing the state vale in a dependency array\n * eg on a native event handler.\n *\n * @param value the initial value to store\n */\n\nconst isSimpleStateValue = <T>(arg: SetStateAction<T>): arg is T =>\n typeof arg !== \"function\";\n\n// Keeps a ref value in sync with a state value\nexport const useStateRef = <T = string>(\n initialValue: T,\n): [RefObject<T>, Dispatch<SetStateAction<T>>] => {\n const [value, _setValue] = useState<T>(initialValue);\n const ref = useRef<T>(value);\n\n const setValue = useCallback<Dispatch<SetStateAction<T>>>((arg) => {\n if (isSimpleStateValue(arg)) {\n ref.current = arg;\n _setValue(arg);\n } else {\n const { current: prev } = ref;\n ref.current = arg(prev);\n _setValue(ref.current);\n }\n }, []);\n return [ref, setValue];\n};\n"],"names":["useState","useRef","useCallback"],"mappings":";;;;AAkBA,MAAM,kBAAqB,GAAA,CAAI,GAC7B,KAAA,OAAO,GAAQ,KAAA,UAAA;AAGJ,MAAA,WAAA,GAAc,CACzB,YACgD,KAAA;AAChD,EAAA,MAAM,CAAC,KAAA,EAAO,SAAS,CAAA,GAAIA,
|
|
1
|
+
{"version":3,"file":"useStateRef.js","sources":["../../../../../../packages/vuu-utils/src/useStateRef.ts"],"sourcesContent":["import {\n Dispatch,\n RefObject,\n SetStateAction,\n useCallback,\n useRef,\n useState,\n} from \"react\";\n\n/**\n * Extension to useState that maintains a ref for the\n * current state value. Useful where use of the ref can\n * avoid referencing the state vale in a dependency array\n * eg on a native event handler.\n *\n * @param value the initial value to store\n */\n\nconst isSimpleStateValue = <T>(arg: SetStateAction<T>): arg is T =>\n typeof arg !== \"function\";\n\n// Keeps a ref value in sync with a state value\nexport const useStateRef = <T = string>(\n initialValue: T,\n): [RefObject<T>, Dispatch<SetStateAction<T>>] => {\n const [value, _setValue] = useState<T>(initialValue);\n const ref = useRef<T>(value);\n\n const setValue = useCallback<Dispatch<SetStateAction<T>>>((arg) => {\n if (isSimpleStateValue(arg)) {\n ref.current = arg;\n _setValue(arg);\n } else {\n const { current: prev } = ref;\n ref.current = arg(prev);\n _setValue(ref.current);\n }\n }, []);\n return [ref, setValue];\n};\n"],"names":["useState","useRef","useCallback"],"mappings":";;;;AAkBA,MAAM,kBAAqB,GAAA,CAAI,GAC7B,KAAA,OAAO,GAAQ,KAAA,UAAA;AAGJ,MAAA,WAAA,GAAc,CACzB,YACgD,KAAA;AAChD,EAAA,MAAM,CAAC,KAAA,EAAO,SAAS,CAAA,GAAIA,eAAY,YAAY,CAAA;AACnD,EAAM,MAAA,GAAA,GAAMC,aAAU,KAAK,CAAA;AAE3B,EAAM,MAAA,QAAA,GAAWC,iBAAyC,CAAA,CAAC,GAAQ,KAAA;AACjE,IAAI,IAAA,kBAAA,CAAmB,GAAG,CAAG,EAAA;AAC3B,MAAA,GAAA,CAAI,OAAU,GAAA,GAAA;AACd,MAAA,SAAA,CAAU,GAAG,CAAA;AAAA,KACR,MAAA;AACL,MAAM,MAAA,EAAE,OAAS,EAAA,IAAA,EAAS,GAAA,GAAA;AAC1B,MAAI,GAAA,CAAA,OAAA,GAAU,IAAI,IAAI,CAAA;AACtB,MAAA,SAAA,CAAU,IAAI,OAAO,CAAA;AAAA;AACvB,GACF,EAAG,EAAE,CAAA;AACL,EAAO,OAAA,CAAC,KAAK,QAAQ,CAAA;AACvB;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { createContext, useContext, isValidElement, cloneElement } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import cx from 'clsx';
|
|
4
4
|
|
|
5
5
|
const DEFAULT_DENSITY = "medium";
|
|
6
6
|
const DEFAULT_THEME = "salt-theme";
|
|
@@ -35,7 +35,7 @@ const useThemeAttributes = (themeAttributes) => {
|
|
|
35
35
|
const createThemedChildren = (children, theme, themeMode, density) => {
|
|
36
36
|
if (isValidElement(children)) {
|
|
37
37
|
return cloneElement(children, {
|
|
38
|
-
className:
|
|
38
|
+
className: cx(
|
|
39
39
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
40
40
|
children.props?.className,
|
|
41
41
|
`${theme}-theme`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.js","sources":["../../../../../../packages/vuu-utils/src/ThemeProvider.tsx"],"sourcesContent":["import React, {\n createContext,\n HTMLAttributes,\n ReactNode,\n isValidElement,\n cloneElement,\n useContext,\n} from \"react\";\nimport cx from \"clsx\";\n\nexport const DEFAULT_DENSITY: Density = \"medium\";\nexport const DEFAULT_THEME = \"salt-theme\";\nexport const DEFAULT_THEME_MODE: ThemeMode = \"light\";\n\nexport type Density = \"high\" | \"medium\" | \"low\" | \"touch\";\nexport type ThemeMode = \"light\" | \"dark\";\nexport type TargetElement = \"root\" | \"scope\" | \"child\";\n\nexport interface ThemeContextProps {\n density: Density;\n theme: string;\n themeMode: ThemeMode;\n}\n\nexport const ThemeContext = createContext<ThemeContextProps>({\n density: \"high\",\n theme: \"vuu\",\n themeMode: \"light\",\n});\n\nexport type ThemeClasses = [string, string, ThemeMode];\n\nconst DEFAULT_THEME_ATTRIBUTES: ThemeClasses = [\n \"vuu\",\n \"salt-density-high\",\n \"light\" as ThemeMode,\n];\n\nexport type ThemeAttributes = {\n themeClass: string;\n densityClass: string;\n dataMode: ThemeMode;\n};\n\nexport const useThemeAttributes = (\n themeAttributes?: ThemeAttributes\n): [string, string, ThemeMode] => {\n const context = useContext(ThemeContext);\n if (themeAttributes) {\n return [\n themeAttributes.themeClass,\n themeAttributes.densityClass,\n themeAttributes.dataMode,\n ];\n } else if (context) {\n return [\n `${context.theme}-theme`,\n `salt-density-${context.density}`,\n context.themeMode,\n ];\n }\n return DEFAULT_THEME_ATTRIBUTES;\n};\n\nconst createThemedChildren = (\n children: ReactNode,\n theme: string,\n themeMode: ThemeMode,\n density: Density\n) => {\n if (isValidElement<HTMLAttributes<HTMLElement>>(children)) {\n return cloneElement(children, {\n className: cx(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n children.props?.className,\n `${theme}-theme`,\n `salt-density-${density}`\n ),\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n \"data-mode\": themeMode,\n });\n } else {\n console.warn(\n `\\nThemeProvider can only apply CSS classes for theming to a single nested child element of the ThemeProvider.\n Wrap elements with a single container`\n );\n return children;\n }\n};\n\ninterface ThemeProviderProps {\n applyThemeClasses?: boolean;\n children: ReactNode;\n density?: Density;\n theme?: string;\n themeMode?: ThemeMode;\n}\n\nexport const ThemeProvider = ({\n applyThemeClasses = false,\n children,\n theme: themeProp,\n themeMode: themeModeProp,\n density: densityProp,\n}: ThemeProviderProps) => {\n const {\n density: inheritedDensity,\n themeMode: inheritedThemeMode,\n theme: inheritedTheme,\n } = useContext(ThemeContext);\n const density = densityProp ?? inheritedDensity ?? DEFAULT_DENSITY;\n const themeMode = themeModeProp ?? inheritedThemeMode ?? DEFAULT_THEME_MODE;\n const theme = themeProp ?? inheritedTheme ?? DEFAULT_THEME;\n const themedChildren = applyThemeClasses\n ? createThemedChildren(children, theme, themeMode, density)\n : children;\n\n return (\n <ThemeContext.Provider value={{ themeMode, density, theme }}>\n {themedChildren}\n </ThemeContext.Provider>\n );\n};\n\nThemeProvider.displayName = \"ThemeProvider\";\n"],"names":[
|
|
1
|
+
{"version":3,"file":"ThemeProvider.js","sources":["../../../../../../packages/vuu-utils/src/ThemeProvider.tsx"],"sourcesContent":["import React, {\n createContext,\n HTMLAttributes,\n ReactNode,\n isValidElement,\n cloneElement,\n useContext,\n} from \"react\";\nimport cx from \"clsx\";\n\nexport const DEFAULT_DENSITY: Density = \"medium\";\nexport const DEFAULT_THEME = \"salt-theme\";\nexport const DEFAULT_THEME_MODE: ThemeMode = \"light\";\n\nexport type Density = \"high\" | \"medium\" | \"low\" | \"touch\";\nexport type ThemeMode = \"light\" | \"dark\";\nexport type TargetElement = \"root\" | \"scope\" | \"child\";\n\nexport interface ThemeContextProps {\n density: Density;\n theme: string;\n themeMode: ThemeMode;\n}\n\nexport const ThemeContext = createContext<ThemeContextProps>({\n density: \"high\",\n theme: \"vuu\",\n themeMode: \"light\",\n});\n\nexport type ThemeClasses = [string, string, ThemeMode];\n\nconst DEFAULT_THEME_ATTRIBUTES: ThemeClasses = [\n \"vuu\",\n \"salt-density-high\",\n \"light\" as ThemeMode,\n];\n\nexport type ThemeAttributes = {\n themeClass: string;\n densityClass: string;\n dataMode: ThemeMode;\n};\n\nexport const useThemeAttributes = (\n themeAttributes?: ThemeAttributes\n): [string, string, ThemeMode] => {\n const context = useContext(ThemeContext);\n if (themeAttributes) {\n return [\n themeAttributes.themeClass,\n themeAttributes.densityClass,\n themeAttributes.dataMode,\n ];\n } else if (context) {\n return [\n `${context.theme}-theme`,\n `salt-density-${context.density}`,\n context.themeMode,\n ];\n }\n return DEFAULT_THEME_ATTRIBUTES;\n};\n\nconst createThemedChildren = (\n children: ReactNode,\n theme: string,\n themeMode: ThemeMode,\n density: Density\n) => {\n if (isValidElement<HTMLAttributes<HTMLElement>>(children)) {\n return cloneElement(children, {\n className: cx(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n children.props?.className,\n `${theme}-theme`,\n `salt-density-${density}`\n ),\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n \"data-mode\": themeMode,\n });\n } else {\n console.warn(\n `\\nThemeProvider can only apply CSS classes for theming to a single nested child element of the ThemeProvider.\n Wrap elements with a single container`\n );\n return children;\n }\n};\n\ninterface ThemeProviderProps {\n applyThemeClasses?: boolean;\n children: ReactNode;\n density?: Density;\n theme?: string;\n themeMode?: ThemeMode;\n}\n\nexport const ThemeProvider = ({\n applyThemeClasses = false,\n children,\n theme: themeProp,\n themeMode: themeModeProp,\n density: densityProp,\n}: ThemeProviderProps) => {\n const {\n density: inheritedDensity,\n themeMode: inheritedThemeMode,\n theme: inheritedTheme,\n } = useContext(ThemeContext);\n const density = densityProp ?? inheritedDensity ?? DEFAULT_DENSITY;\n const themeMode = themeModeProp ?? inheritedThemeMode ?? DEFAULT_THEME_MODE;\n const theme = themeProp ?? inheritedTheme ?? DEFAULT_THEME;\n const themedChildren = applyThemeClasses\n ? createThemedChildren(children, theme, themeMode, density)\n : children;\n\n return (\n <ThemeContext.Provider value={{ themeMode, density, theme }}>\n {themedChildren}\n </ThemeContext.Provider>\n );\n};\n\nThemeProvider.displayName = \"ThemeProvider\";\n"],"names":[],"mappings":";;;;AAUO,MAAM,eAA2B,GAAA;AACjC,MAAM,aAAgB,GAAA;AACtB,MAAM,kBAAgC,GAAA;AAYtC,MAAM,eAAe,aAAiC,CAAA;AAAA,EAC3D,OAAS,EAAA,MAAA;AAAA,EACT,KAAO,EAAA,KAAA;AAAA,EACP,SAAW,EAAA;AACb,CAAC;AAID,MAAM,wBAAyC,GAAA;AAAA,EAC7C,KAAA;AAAA,EACA,mBAAA;AAAA,EACA;AACF,CAAA;AAQa,MAAA,kBAAA,GAAqB,CAChC,eACgC,KAAA;AAChC,EAAM,MAAA,OAAA,GAAU,WAAW,YAAY,CAAA;AACvC,EAAA,IAAI,eAAiB,EAAA;AACnB,IAAO,OAAA;AAAA,MACL,eAAgB,CAAA,UAAA;AAAA,MAChB,eAAgB,CAAA,YAAA;AAAA,MAChB,eAAgB,CAAA;AAAA,KAClB;AAAA,aACS,OAAS,EAAA;AAClB,IAAO,OAAA;AAAA,MACL,CAAA,EAAG,QAAQ,KAAK,CAAA,MAAA,CAAA;AAAA,MAChB,CAAA,aAAA,EAAgB,QAAQ,OAAO,CAAA,CAAA;AAAA,MAC/B,OAAQ,CAAA;AAAA,KACV;AAAA;AAEF,EAAO,OAAA,wBAAA;AACT;AAEA,MAAM,oBAAuB,GAAA,CAC3B,QACA,EAAA,KAAA,EAC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AAA;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
2
|
|
|
3
|
-
const WorkspaceContext =
|
|
3
|
+
const WorkspaceContext = React.createContext({
|
|
4
4
|
getApplicationSettings: () => void 0,
|
|
5
5
|
layoutMetadata: [],
|
|
6
6
|
saveLayout: () => void 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkspaceContext.js","sources":["../../../../../../../packages/vuu-utils/src/context-definitions/WorkspaceContext.tsx"],"sourcesContent":["import React, { useContext } from \"react\";\nimport {\n ApplicationSetting,\n ApplicationSettings,\n LayoutJSON\n} from \"../json-types\";\nimport { LayoutMetadata, LayoutMetadataDto } from \"../layout-types\";\n\nexport interface WorkspaceContextProps {\n layoutMetadata: LayoutMetadata[];\n layoutPlaceholderJSON?: LayoutJSON;\n getApplicationSettings: (\n key?: keyof ApplicationSettings\n ) => ApplicationSettings | ApplicationSetting | undefined;\n loadLayoutById: (id: string) => void;\n saveApplicationSettings: (\n settings: ApplicationSettings | ApplicationSetting,\n key?: keyof ApplicationSettings\n ) => void;\n saveLayout: (n: LayoutMetadataDto) => void;\n saveApplicationLayout: (layout: LayoutJSON) => void;\n workspaceJSON?: LayoutJSON | LayoutJSON[];\n}\n\nexport const WorkspaceContext = React.createContext<WorkspaceContextProps>({\n getApplicationSettings: () => undefined,\n layoutMetadata: [],\n saveLayout: () => undefined,\n saveApplicationLayout: () => undefined,\n saveApplicationSettings: () => undefined,\n loadLayoutById: () => undefined\n});\n\nexport const usePlaceholderJSON = () => {\n const { layoutPlaceholderJSON } = useContext(WorkspaceContext);\n return layoutPlaceholderJSON;\n};\n"],"names":[
|
|
1
|
+
{"version":3,"file":"WorkspaceContext.js","sources":["../../../../../../../packages/vuu-utils/src/context-definitions/WorkspaceContext.tsx"],"sourcesContent":["import React, { useContext } from \"react\";\nimport {\n ApplicationSetting,\n ApplicationSettings,\n LayoutJSON\n} from \"../json-types\";\nimport { LayoutMetadata, LayoutMetadataDto } from \"../layout-types\";\n\nexport interface WorkspaceContextProps {\n layoutMetadata: LayoutMetadata[];\n layoutPlaceholderJSON?: LayoutJSON;\n getApplicationSettings: (\n key?: keyof ApplicationSettings\n ) => ApplicationSettings | ApplicationSetting | undefined;\n loadLayoutById: (id: string) => void;\n saveApplicationSettings: (\n settings: ApplicationSettings | ApplicationSetting,\n key?: keyof ApplicationSettings\n ) => void;\n saveLayout: (n: LayoutMetadataDto) => void;\n saveApplicationLayout: (layout: LayoutJSON) => void;\n workspaceJSON?: LayoutJSON | LayoutJSON[];\n}\n\nexport const WorkspaceContext = React.createContext<WorkspaceContextProps>({\n getApplicationSettings: () => undefined,\n layoutMetadata: [],\n saveLayout: () => undefined,\n saveApplicationLayout: () => undefined,\n saveApplicationSettings: () => undefined,\n loadLayoutById: () => undefined\n});\n\nexport const usePlaceholderJSON = () => {\n const { layoutPlaceholderJSON } = useContext(WorkspaceContext);\n return layoutPlaceholderJSON;\n};\n"],"names":[],"mappings":";;AAwBa,MAAA,gBAAA,GAAmB,MAAM,aAAqC,CAAA;AAAA,EACzE,wBAAwB,MAAM,KAAA,CAAA;AAAA,EAC9B,gBAAgB,EAAC;AAAA,EACjB,YAAY,MAAM,KAAA,CAAA;AAAA,EAClB,uBAAuB,MAAM,KAAA,CAAA;AAAA,EAC7B,yBAAyB,MAAM,KAAA,CAAA;AAAA,EAC/B,gBAAgB,MAAM,KAAA;AACxB,CAAC;AAEM,MAAM,qBAAqB,MAAM;AACtC,EAAA,MAAM,EAAE,qBAAA,EAA0B,GAAA,UAAA,CAAW,gBAAgB,CAAA;AAC7D,EAAO,OAAA,qBAAA;AACT;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { Button } from '@salt-ds/core';
|
|
3
|
-
import { useState,
|
|
3
|
+
import { useState, useMemo } from 'react';
|
|
4
4
|
|
|
5
5
|
const EditButtons = ({
|
|
6
6
|
editSession,
|
|
@@ -8,9 +8,6 @@ const EditButtons = ({
|
|
|
8
8
|
onSave
|
|
9
9
|
}) => {
|
|
10
10
|
const [editState, setEditState] = useState("clean");
|
|
11
|
-
const handleSave = useCallback(() => {
|
|
12
|
-
onSave(editState === "stale");
|
|
13
|
-
}, [editState, onSave]);
|
|
14
11
|
useMemo(() => {
|
|
15
12
|
editSession?.on("editState", setEditState);
|
|
16
13
|
}, [editSession]);
|
|
@@ -18,10 +15,10 @@ const EditButtons = ({
|
|
|
18
15
|
/* @__PURE__ */ jsx(
|
|
19
16
|
Button,
|
|
20
17
|
{
|
|
21
|
-
disabled: editState === "clean"
|
|
22
|
-
onClick:
|
|
18
|
+
disabled: editState === "clean",
|
|
19
|
+
onClick: onSave,
|
|
23
20
|
sentiment: "accented",
|
|
24
|
-
children:
|
|
21
|
+
children: "Save"
|
|
25
22
|
}
|
|
26
23
|
),
|
|
27
24
|
/* @__PURE__ */ jsx(Button, { onClick: onCancel, children: "Cancel" })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditButtons.js","sources":["../../../../../../../packages/vuu-utils/src/data-editing/EditButtons.tsx"],"sourcesContent":["import { Button } from \"@salt-ds/core\";\nimport { EditState, EditSession } from \"./EditSession\";\nimport {
|
|
1
|
+
{"version":3,"file":"EditButtons.js","sources":["../../../../../../../packages/vuu-utils/src/data-editing/EditButtons.tsx"],"sourcesContent":["import { Button } from \"@salt-ds/core\";\nimport { EditState, EditSession } from \"./EditSession\";\nimport { useMemo, useState } from \"react\";\n\nexport interface EditButtonProps {\n editSession?: EditSession;\n onCancel: () => void;\n onSave: () => void;\n}\n\nexport const EditButtons = ({\n editSession,\n onCancel,\n onSave,\n}: EditButtonProps) => {\n const [editState, setEditState] = useState<EditState>(\"clean\");\n\n useMemo(() => {\n editSession?.on(\"editState\", setEditState);\n }, [editSession]);\n\n return (\n <>\n <Button\n disabled={editState === \"clean\"}\n onClick={onSave}\n sentiment=\"accented\"\n >\n Save\n </Button>\n <Button onClick={onCancel}>Cancel</Button>\n </>\n );\n};\n"],"names":[],"mappings":";;;;AAUO,MAAM,cAAc,CAAC;AAAA,EAC1B,WAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAuB,KAAA;AACrB,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAI,SAAoB,OAAO,CAAA;AAE7D,EAAA,OAAA,CAAQ,MAAM;AACZ,IAAa,WAAA,EAAA,EAAA,CAAG,aAAa,YAAY,CAAA;AAAA,GAC3C,EAAG,CAAC,WAAW,CAAC,CAAA;AAEhB,EAAA,uBAEI,IAAA,CAAA,QAAA,EAAA,EAAA,QAAA,EAAA;AAAA,oBAAA,GAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,UAAU,SAAc,KAAA,OAAA;AAAA,QACxB,OAAS,EAAA,MAAA;AAAA,QACT,SAAU,EAAA,UAAA;AAAA,QACX,QAAA,EAAA;AAAA;AAAA,KAED;AAAA,oBACC,GAAA,CAAA,MAAA,EAAA,EAAO,OAAS,EAAA,QAAA,EAAU,QAAM,EAAA,QAAA,EAAA;AAAA,GACnC,EAAA,CAAA;AAEJ;;;;"}
|