@kapaai/support-form-deflector 0.2.2 → 0.3.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/dist/answer/answer-box.d.ts +3 -0
- package/dist/answer/answer-box.d.ts.map +1 -0
- package/dist/answer/error-indicator.d.ts.map +1 -1
- package/dist/answer/index.d.ts.map +1 -1
- package/dist/answer/info.d.ts +3 -0
- package/dist/answer/info.d.ts.map +1 -0
- package/dist/answer/loading-indicator.d.ts +2 -1
- package/dist/answer/loading-indicator.d.ts.map +1 -1
- package/dist/config/config-provider.d.ts +12 -0
- package/dist/config/config-provider.d.ts.map +1 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/parse-config.d.ts +8 -0
- package/dist/config/parse-config.d.ts.map +1 -0
- package/dist/config/style-parser.d.ts +68 -0
- package/dist/config/style-parser.d.ts.map +1 -0
- package/dist/config/types.d.ts +74 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/kapa-support-form-deflector.bundle.js +1 -1
- package/dist/state.d.ts +1 -1
- package/dist/state.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/answer/answer-renderer.d.ts +0 -6
- package/dist/answer/answer-renderer.d.ts.map +0 -1
- package/dist/answer/info-texts.d.ts +0 -4
- package/dist/answer/info-texts.d.ts.map +0 -1
- package/dist/config-provider.d.ts +0 -33
- package/dist/config-provider.d.ts.map +0 -1
- package/dist/icons/sparkles.d.ts +0 -3
- package/dist/icons/sparkles.d.ts.map +0 -1
- package/dist/icons/types.d.ts +0 -9
- package/dist/icons/types.d.ts.map +0 -1
- package/dist/utils/errors.d.ts +0 -7
- package/dist/utils/errors.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answer-box.d.ts","sourceRoot":"","sources":["../../src/answer/answer-box.tsx"],"names":[],"mappings":"AAGA,OAAO,EAML,cAAc,EAEf,MAAM,WAAW,CAAC;AAuEnB,eAAO,MAAM,SAAS,cAAe,cAAc,4CAmDlD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-indicator.d.ts","sourceRoot":"","sources":["../../src/answer/error-indicator.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"error-indicator.d.ts","sourceRoot":"","sources":["../../src/answer/error-indicator.tsx"],"names":[],"mappings":"AAEA,QAAA,MAAM,cAAc,+CAOnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/answer/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/answer/index.tsx"],"names":[],"mappings":"AA2BA,QAAA,MAAM,aAAa,+CA0BlB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../../src/answer/info.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,MAAM,WAAW,CAAC;AAGjD,eAAO,MAAM,IAAI,oBAAqB,SAAS,mDAQ9C,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { LoadingIndicatorProps } from "../config";
|
|
2
|
+
declare const LoadingIndicator: ({ loadingTexts, style }: LoadingIndicatorProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
3
|
export default LoadingIndicator;
|
|
3
4
|
//# sourceMappingURL=loading-indicator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loading-indicator.d.ts","sourceRoot":"","sources":["../../src/answer/loading-indicator.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loading-indicator.d.ts","sourceRoot":"","sources":["../../src/answer/loading-indicator.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AA8DlD,QAAA,MAAM,gBAAgB,4BAA6B,qBAAqB,4CAyCvE,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { DeflectorConfig, DeflectorProps } from "./types";
|
|
3
|
+
export declare const ConfigProvider: React.FC<{
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
props: DeflectorProps;
|
|
6
|
+
config: DeflectorConfig;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const useConfig: () => {
|
|
9
|
+
config: DeflectorConfig;
|
|
10
|
+
props: DeflectorProps;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=config-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-provider.d.ts","sourceRoot":"","sources":["../../src/config/config-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAW1D,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC;IACpC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,EAAE,eAAe,CAAC;CACzB,CAIA,CAAC;AAEF,eAAO,MAAM,SAAS;YAjBR,eAAe;WAChB,cAAc;CAsB1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-config.d.ts","sourceRoot":"","sources":["../../src/config/parse-config.tsx"],"names":[],"mappings":"AAAA,OAAO,EASL,MAAM,EAEP,MAAM,SAAS,CAAC;AAIjB;;;;GAIG;AACH,eAAO,MAAM,WAAW,cAAe,iBAAiB,KAAG,MAkR1D,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Sx } from "@mantine/core";
|
|
3
|
+
import { ThemeConfig } from "./types";
|
|
4
|
+
interface PaddingX {
|
|
5
|
+
paddingLeft: React.CSSProperties["paddingLeft"];
|
|
6
|
+
paddingRight: React.CSSProperties["paddingLeft"];
|
|
7
|
+
}
|
|
8
|
+
interface PaddingY {
|
|
9
|
+
paddingTop: React.CSSProperties["paddingLeft"];
|
|
10
|
+
paddingBottom: React.CSSProperties["paddingLeft"];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* List of available component attribute names for the script tag
|
|
14
|
+
*/
|
|
15
|
+
type ComponentAttributes = "answer-box" | "answer-box-footer" | "answer-box-footer-text" | "answer-box-header" | "answer-box-header-title" | "answer-box-header-icon" | "info-text" | "pre-submit-info" | "post-submit-info" | "loading-info" | "loading-indicator";
|
|
16
|
+
/**
|
|
17
|
+
* List of available style attribute names for the script tag
|
|
18
|
+
* that are extracted if provided
|
|
19
|
+
*/
|
|
20
|
+
type StyleAttributeNames = "background-color" | "color" | "font-size" | "font-weight" | "border" | "border-radius" | "opacity" | "padding-x" | "padding-y";
|
|
21
|
+
/**
|
|
22
|
+
* Helper class to extract consistent style options for the
|
|
23
|
+
* components' style configurations. Essentially this helps parsing
|
|
24
|
+
* the `StyleAttributeNames` that are passed to the script tag
|
|
25
|
+
* for every one of the components defined in `ComponentAttributes`.
|
|
26
|
+
* The goal here is to expose the same style configurations for
|
|
27
|
+
* all components and avoid inconsistencies. So every component (attribute)
|
|
28
|
+
* that we have defined, e.g. `answer-box`, supports the following
|
|
29
|
+
* script attributes automatically to configure its styling:
|
|
30
|
+
* - `data-answer-box-background-color`,
|
|
31
|
+
* - `data-answer-box-color`,
|
|
32
|
+
* - `data-answer-font-size`,
|
|
33
|
+
* ...
|
|
34
|
+
*/
|
|
35
|
+
export declare class StyleParser {
|
|
36
|
+
private scriptTag;
|
|
37
|
+
private theme;
|
|
38
|
+
constructor(scriptTag: HTMLScriptElement, theme: ThemeConfig);
|
|
39
|
+
getDefault<T extends Record<string, string>>(obj: T, value: string | null): string | null;
|
|
40
|
+
/**
|
|
41
|
+
* Extracts the component attribute from the script tag
|
|
42
|
+
*/
|
|
43
|
+
getAttribute(componentAttributeName: string, styleAttributeName: StyleAttributeNames): string | null;
|
|
44
|
+
/**
|
|
45
|
+
* Extracts the padding left and padding right from the padding-x attribute.
|
|
46
|
+
* @param attributeName the name of the script attribute. E.g data-answer-box
|
|
47
|
+
* @param defaultValue
|
|
48
|
+
* @returns
|
|
49
|
+
*/
|
|
50
|
+
getPaddingX(componentAttributeName: string): PaddingX | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Extracts the padding top and padding bottom from the padding-y attribute.
|
|
53
|
+
* @param attributeName the name of the script attribute. E.g data-answer-box
|
|
54
|
+
* @param defaultValue
|
|
55
|
+
* @returns
|
|
56
|
+
*/
|
|
57
|
+
getPaddingY(componentAttributeName: string): PaddingY | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Parses basic CSS parameters that we want to expose for every component
|
|
60
|
+
* to maintain consistency.
|
|
61
|
+
* @param componentAttributeName the component attribute name as parsed in the script tag. E.g.: answer-box, info-text...
|
|
62
|
+
* @param defaults default styles
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
getComponentStyles(componentAttributeName: ComponentAttributes, defaults?: Sx): Sx;
|
|
66
|
+
}
|
|
67
|
+
export {};
|
|
68
|
+
//# sourceMappingURL=style-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-parser.d.ts","sourceRoot":"","sources":["../../src/config/style-parser.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAgB,EAAE,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEt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AsB,EAAE,mBAAmB,EAC3C,QAAQ,GAAE,EAAO,GAChB,EAAE;CAiCN"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type MantineThemeColors, type MantineTheme, type Sx } from "@mantine/core";
|
|
2
|
+
/**
|
|
3
|
+
* DEFLECTOR COMPONENT PROPS
|
|
4
|
+
*
|
|
5
|
+
* This defines the properties of all the components that we want to expose in
|
|
6
|
+
* the deflector for users to configure them in a modularized way.
|
|
7
|
+
* All components inherit `style` prop, which is of type Sx that works with Mantine.
|
|
8
|
+
* More info on the Sx prop is here: https://v5.mantine.dev/styles/sx/.
|
|
9
|
+
* Generally, it is recommended to modularize components depending on the configuration
|
|
10
|
+
* needs of the customer and use "inheritance" if possible.
|
|
11
|
+
* E.g. we may have a general-use `Info` properties that has certain default styles
|
|
12
|
+
* and other properties like the `text`. We may then also define a `PostSubmit` and `PreSubmit`
|
|
13
|
+
* component, that inhertit the `Info` component's props and default values (e.g. fontSize: "sm"),
|
|
14
|
+
* but can be overwritten with more specific values.
|
|
15
|
+
*/
|
|
16
|
+
interface BaseProps {
|
|
17
|
+
style: Sx;
|
|
18
|
+
}
|
|
19
|
+
export interface AnswerBoxProps extends BaseProps {
|
|
20
|
+
}
|
|
21
|
+
export interface AnswerBoxHeaderProps extends BaseProps {
|
|
22
|
+
}
|
|
23
|
+
export interface AnswerBoxHeaderTitleProps extends BaseProps {
|
|
24
|
+
text: string;
|
|
25
|
+
}
|
|
26
|
+
export interface AnswerBoxHeaderIconProps extends BaseProps {
|
|
27
|
+
hidden: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface AnswerBoxFooterProps extends BaseProps {
|
|
30
|
+
}
|
|
31
|
+
export interface AnswerBoxFooterTextProps extends BaseProps {
|
|
32
|
+
}
|
|
33
|
+
export interface LoadingIndicatorProps extends BaseProps {
|
|
34
|
+
loadingTexts: string[];
|
|
35
|
+
}
|
|
36
|
+
export interface InfoProps extends BaseProps {
|
|
37
|
+
text?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface DeflectorProps {
|
|
40
|
+
AnswerBox: AnswerBoxProps;
|
|
41
|
+
AnswerBoxHeader: AnswerBoxHeaderProps;
|
|
42
|
+
AnswerBoxHeaderTitle: AnswerBoxHeaderTitleProps;
|
|
43
|
+
AnswerBoxHeaderIcon: AnswerBoxHeaderIconProps;
|
|
44
|
+
AnswerBoxFooter: AnswerBoxFooterProps;
|
|
45
|
+
AnswerBoxFooterText: AnswerBoxFooterTextProps;
|
|
46
|
+
LoadingIndicator: LoadingIndicatorProps;
|
|
47
|
+
Info: InfoProps;
|
|
48
|
+
PreSubmitInfo: InfoProps;
|
|
49
|
+
PostSubmitInfo: InfoProps;
|
|
50
|
+
LoadingInfo: InfoProps;
|
|
51
|
+
}
|
|
52
|
+
export type DeflectorConfig = {
|
|
53
|
+
mainInputQuerySelector: string;
|
|
54
|
+
extraInputQuerySelectors: string[];
|
|
55
|
+
integrationId: string;
|
|
56
|
+
submitElementQuerySelector: string;
|
|
57
|
+
submitElementEventType: "onSubmit" | "onClick";
|
|
58
|
+
runsOriginalEventAutomatically?: boolean;
|
|
59
|
+
submitButtonTextQuerySelector?: string;
|
|
60
|
+
submitButtonTextOverride?: string;
|
|
61
|
+
};
|
|
62
|
+
export interface ThemeConfig extends Partial<Omit<MantineTheme, "colors">> {
|
|
63
|
+
colors: Partial<MantineThemeColors>;
|
|
64
|
+
other: {
|
|
65
|
+
textColor: string;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export interface Config {
|
|
69
|
+
config: DeflectorConfig;
|
|
70
|
+
props: DeflectorProps;
|
|
71
|
+
theme: ThemeConfig;
|
|
72
|
+
}
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,YAAY,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