@pushwoosh/smart-components-kit 0.1.0 → 0.2.0

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/_devel/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { type PushwooshSPAContextType } from '../context';
1
+ import { type SPAContextType } from '../context';
2
2
  export type ParcelResult<P> = {
3
3
  render: (props: P) => void;
4
4
  unmount: () => void;
5
5
  };
6
6
  export type ParcelProps = {
7
- context: PushwooshSPAContextType;
7
+ context: SPAContextType;
8
8
  };
9
9
  export declare function parcel(container: HTMLElement): ParcelResult<ParcelProps>;
package/_devel/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { createRoot } from 'react-dom/client';
3
3
  import { Router, Route, Switch, Link } from 'react-router-dom';
4
- import { PushwooshSPAContextProvider } from '../context';
4
+ import { SPAContextProvider } from '../context';
5
5
  import { Lib } from './lib';
6
6
  import { TestPlace } from './test-place';
7
7
  export function parcel(container) {
@@ -10,7 +10,7 @@ export function parcel(container) {
10
10
  render(props) {
11
11
  root.render(React.createElement(Router, {
12
12
  history: props.context.history
13
- }, React.createElement(PushwooshSPAContextProvider, {
13
+ }, React.createElement(SPAContextProvider, {
14
14
  value: props.context
15
15
  }, React.createElement(Switch, null, React.createElement(Route, {
16
16
  path: "/:url",
@@ -2,7 +2,7 @@ import { type History } from 'history';
2
2
  import type { GrpcBridge } from '@pushwoosh/grpc-bridge';
3
3
  import type { HttpClient, RpcClient, GrpcClient } from '@pushwoosh/http-client';
4
4
  import type { SessionStore } from '@pushwoosh/session-store';
5
- export type PushwooshSPAContextType = {
5
+ export type SPAContextType = {
6
6
  readonly history: History;
7
7
  readonly httpClient: HttpClient;
8
8
  readonly rpcClient: RpcClient;
@@ -10,6 +10,6 @@ export type PushwooshSPAContextType = {
10
10
  readonly grpcBridge: GrpcBridge;
11
11
  readonly sessionStore: SessionStore;
12
12
  };
13
- export declare const PushwooshSPAContext: import("react").Context<PushwooshSPAContextType | undefined>;
14
- export declare const PushwooshSPAContextProvider: import("react").Provider<PushwooshSPAContextType | undefined>;
15
- export declare function usePushwooshSPAContext(): PushwooshSPAContextType;
13
+ export declare const SPAContext: import("react").Context<SPAContextType | undefined>;
14
+ export declare const SPAContextProvider: import("react").Provider<SPAContextType | undefined>;
15
+ export declare function useSPAContext(): SPAContextType;
package/context/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { createContext, useContext } from 'react';
2
- export const PushwooshSPAContext = createContext(undefined);
3
- export const PushwooshSPAContextProvider = PushwooshSPAContext.Provider;
4
- export function usePushwooshSPAContext() {
5
- const contextValue = useContext(PushwooshSPAContext);
2
+ export const SPAContext = createContext(undefined);
3
+ export const SPAContextProvider = SPAContext.Provider;
4
+ export function useSPAContext() {
5
+ const contextValue = useContext(SPAContext);
6
6
  if (!contextValue) {
7
- throw new Error('usePushwooshSPAContext must be used within a PushwooshSPAContextProvider');
7
+ throw new Error('useSPAContext must be used within a SPAContextProvider');
8
8
  }
9
9
  return contextValue;
10
10
  }
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
- import { Vertical } from '@pushwoosh/kit-helpers';
2
+ import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
3
3
  import { TextInputField } from '@pushwoosh/kit-text-input';
4
4
  import { NativeSelect } from '@pushwoosh/kit-select';
5
+ import { Spinner } from '@pushwoosh/kit-spinner';
5
6
  import { useDynamicContentTags } from './hooks';
6
7
  import { FieldTitle, TagPickerDiv } from './styled';
7
8
  export const Field = ({
@@ -24,7 +25,12 @@ export const DynamicContentPicker = ({
24
25
  }) => {
25
26
  const asyncResult = useDynamicContentTags();
26
27
  if (asyncResult.loading) {
27
- return React.createElement("div", null);
28
+ return React.createElement(TagPickerDiv, null, React.createElement(Horizontal, {
29
+ "$placeItems": "center",
30
+ "$padding": 36
31
+ }, React.createElement(Spinner, {
32
+ size: "medium"
33
+ })));
28
34
  }
29
35
  const tags = asyncResult.value || [];
30
36
  const currentTag = tags.find(tag => tag.name === dc.tagName) || {
@@ -1,6 +1,6 @@
1
- import { PushwooshSPAContextType } from '../context';
1
+ import { SPAContextType } from '../context';
2
2
  import type { FullTagData } from './DynamicContentPicker.types';
3
- export declare function fetchDynamicContentTags(context: PushwooshSPAContextType): Promise<FullTagData[]>;
3
+ export declare function fetchDynamicContentTags(context: SPAContextType): Promise<FullTagData[]>;
4
4
  export declare function useDynamicContentTags(): {
5
5
  loading: boolean;
6
6
  error?: undefined;
@@ -1,7 +1,7 @@
1
1
  import { useContext } from 'react';
2
2
  import { useAsync } from '@pushwoosh/kit-helpers';
3
3
  import { collectPaginatedData } from '../asyncHelpers';
4
- import { PushwooshSPAContext } from '../context';
4
+ import { SPAContext } from '../context';
5
5
  const ignoreTagTypes = ['boolean', 'list'];
6
6
  const numberTypes = ['integer', 'decimal'];
7
7
  export async function fetchDynamicContentTags(context) {
@@ -23,7 +23,7 @@ export async function fetchDynamicContentTags(context) {
23
23
  }));
24
24
  }
25
25
  export function useDynamicContentTags() {
26
- const context = useContext(PushwooshSPAContext);
26
+ const context = useContext(SPAContext);
27
27
  return useAsync(async () => {
28
28
  return fetchDynamicContentTags(context);
29
29
  }, [context]);
package/package.json CHANGED
@@ -50,5 +50,5 @@
50
50
  "engines": {
51
51
  "node": ">= 18"
52
52
  },
53
- "version": "0.1.0"
53
+ "version": "0.2.0"
54
54
  }