@prokodo/ui 0.0.44 → 0.0.46

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.
@@ -1,4 +1,4 @@
1
- const backgroundFill = "backgroundFill";
1
+ const accordionBorderShift = "accordionBorderShift";
2
2
  const gradientMove = "gradientMove";
3
3
  const fadeInKeyframe = "fadeInKeyframe";
4
4
  const styles = {
@@ -6,10 +6,9 @@ const styles = {
6
6
  "prokodo-Accordion__item": "prokodo-Accordion__item",
7
7
  "prokodo-Accordion__item--is-expanded": "prokodo-Accordion__item--is-expanded",
8
8
  "prokodo-Accordion__header": "prokodo-Accordion__header",
9
- backgroundFill,
9
+ accordionBorderShift,
10
10
  "prokodo-Accordion__header--is-expanded": "prokodo-Accordion__header--is-expanded",
11
11
  "prokodo-Accordion__title": "prokodo-Accordion__title",
12
- "prokodo-Accordion__title--is-expanded": "prokodo-Accordion__title--is-expanded",
13
12
  "prokodo-Accordion__icon": "prokodo-Accordion__icon",
14
13
  "prokodo-Accordion__icon--is-hidden": "prokodo-Accordion__icon--is-hidden",
15
14
  "prokodo-Accordion__content": "prokodo-Accordion__content",
@@ -19,7 +18,7 @@ const styles = {
19
18
  fadeInKeyframe
20
19
  };
21
20
  export {
22
- backgroundFill,
21
+ accordionBorderShift,
23
22
  styles as default,
24
23
  fadeInKeyframe,
25
24
  gradientMove
@@ -46,9 +46,12 @@ function AccordionView({
46
46
  !isNull(renderHeader) ? renderHeader : /* @__PURE__ */ jsx(
47
47
  Headline,
48
48
  {
49
- className: bem("title", { "is-expanded": isExpanded }),
50
- size: "sm",
49
+ animated: true,
50
+ className: bem("title"),
51
+ highlight: isExpanded,
52
+ size: "xs",
51
53
  type: "h3",
54
+ variant: isExpanded ? "primary" : "inherit",
52
55
  ...item.titleOptions ?? titleOptions,
53
56
  children: title
54
57
  }
@@ -57,7 +60,7 @@ function AccordionView({
57
60
  Icon,
58
61
  {
59
62
  className: bem("icon", { "is-hidden": isExpanded }),
60
- color: "primary",
63
+ color: "inherit",
61
64
  name: "PlusSignIcon",
62
65
  size: "sm",
63
66
  ...iconProps
@@ -67,7 +70,7 @@ function AccordionView({
67
70
  Icon,
68
71
  {
69
72
  className: bem("icon", { "is-hidden": !isExpanded }),
70
- color: "white",
73
+ color: "inherit",
71
74
  name: "MinusSignIcon",
72
75
  size: "sm",
73
76
  ...iconProps
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
  import { jsx } from "react/jsx-runtime";
4
- const AnimatedTextView = /* @__PURE__ */ __name(({ text, ...spanRest }) => /* @__PURE__ */ jsx("span", { ...spanRest, children: text }), "AnimatedTextView");
4
+ const AnimatedTextView = /* @__PURE__ */ __name((({ text, ...spanRest }) => /* @__PURE__ */ jsx("span", { ...spanRest, children: text })), "AnimatedTextView");
5
5
  AnimatedTextView.displayName = "AnimatedTextView";
6
6
  export {
7
7
  AnimatedTextView
@@ -15,16 +15,26 @@ function BaseLinkView({
15
15
  let finalHref = href ?? "#";
16
16
  let kind = "local";
17
17
  if (href) {
18
- if (href.startsWith("http://") || href.startsWith("https://") || href.startsWith("//")) {
18
+ const hasProtocol = href.startsWith("http://") || href.startsWith("https://") || href.startsWith("//");
19
+ const isLocalPath = href.startsWith("/") || href.startsWith("#") || href.startsWith("?");
20
+ const appProto = /^\w+:/.test(href);
21
+ if (hasProtocol || appProto) {
19
22
  kind = "url";
23
+ } else if (isLocalPath) {
24
+ kind = "local";
20
25
  } else if (emailRE.test(href)) {
21
26
  kind = "email";
22
- finalHref = `mailto:${href.toLowerCase()}`;
27
+ finalHref = `mailto:${href}`;
23
28
  } else {
24
- const digits = href.replace(/[^\d]/g, "");
25
- if (digits.length >= 6) {
26
- kind = "tel";
27
- finalHref = `tel:${digits.startsWith("00") ? `+${digits.slice(2)}` : digits.startsWith("0") ? `+${digits.slice(1)}` : `+${digits}`}`;
29
+ const phoneLikeRE = /^\+?\d[\d\s().-]*$/;
30
+ if (phoneLikeRE.test(href)) {
31
+ const digits = href.replace(/[^\d]/g, "");
32
+ if (digits.length >= 6) {
33
+ kind = "tel";
34
+ finalHref = `tel:+${digits}`;
35
+ }
36
+ } else {
37
+ kind = "local";
28
38
  }
29
39
  }
30
40
  }
@@ -94,7 +94,7 @@ function CardView({
94
94
  {
95
95
  ...redirect,
96
96
  "aria-disabled": redirect.disabled ?? false,
97
- className: bem("link"),
97
+ className: bem("link", void 0, redirect == null ? void 0 : redirect.className),
98
98
  role,
99
99
  tabIndex,
100
100
  children: innerCard
@@ -2,6 +2,7 @@ const gradientMove = "gradientMove";
2
2
  const fadeInKeyframe = "fadeInKeyframe";
3
3
  const styles = {
4
4
  "prokodo-DynamicList": "prokodo-DynamicList",
5
+ "prokodo-DynamicList__label": "prokodo-DynamicList__label",
5
6
  "prokodo-DynamicList__list": "prokodo-DynamicList__list",
6
7
  "prokodo-DynamicList__list__item": "prokodo-DynamicList__list__item",
7
8
  "prokodo-DynamicList__list__item--is-multi": "prokodo-DynamicList__list__item--is-multi",
@@ -43,7 +43,7 @@ function DynamicListView({
43
43
  {
44
44
  ...labelProps,
45
45
  "aria-disabled": disabled,
46
- className: bem("list-label", void 0, labelProps == null ? void 0 : labelProps.className),
46
+ className: bem("label", void 0, labelProps == null ? void 0 : labelProps.className),
47
47
  error: isError,
48
48
  id: (labelProps == null ? void 0 : labelProps.id) ?? `${name}-legend`,
49
49
  label,
@@ -74,10 +74,11 @@ const FormClient = memo((props) => {
74
74
  updateSingleField(idx, { value });
75
75
  return;
76
76
  }
77
- defaultFields == null ? void 0 : defaultFields.forEach((defField, i) => {
77
+ defaultFields == null ? void 0 : defaultFields.forEach((defField) => {
78
78
  var _a;
79
79
  if (Boolean((_a = defField.conditions) == null ? void 0 : _a.some((c) => c.fieldId === field.name))) {
80
- updateSingleField(i, defaultFields[i]);
80
+ const targetIdx = formState.findIndex((f) => f.name === defField.name);
81
+ if (targetIdx >= 0) updateSingleField(targetIdx, defField);
81
82
  }
82
83
  });
83
84
  const matched = (field.conditions ?? []).filter((c) => {
@@ -161,14 +162,16 @@ const FormClient = memo((props) => {
161
162
  formMessages,
162
163
  formState,
163
164
  isFormValid,
165
+ isHoneypotEmpty: honeypotValue.length === 0,
164
166
  fieldProps: {
165
167
  onChange: handleFieldChange,
166
168
  onValidate: handleFieldValidate
167
169
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
168
170
  },
169
171
  honeypot: {
170
- value: honeypotValue,
171
- onChange: handleHpChange
172
+ defaultValue: "",
173
+ onChange: handleHpChange,
174
+ autoComplete: "off"
172
175
  },
173
176
  onFormSubmit: handleFormSubmit
174
177
  }
@@ -26,80 +26,82 @@ const FormView = /* @__PURE__ */ __name(({
26
26
  button,
27
27
  children,
28
28
  honeypot,
29
+ isHoneypotEmpty,
29
30
  onFormSubmit,
30
31
  isFormValid,
31
32
  fieldProps,
32
33
  messagesFields,
33
- ...props
34
- }) => {
35
- var _a;
36
- return /* @__PURE__ */ jsxs(
37
- "form",
38
- {
39
- ...props,
40
- noValidate: true,
41
- action,
42
- "aria-labelledby": `${id}-heading`,
43
- className: bem(void 0, void 0, className),
44
- id,
45
- onSubmit: typeof action === "function" || typeof action === "string" ? void 0 : onFormSubmit,
46
- children: [
34
+ // ⬇️ strip non-DOM props so they don't leak to <form>
35
+ fields: _fields,
36
+ defaultFields: _defaultFields,
37
+ messages: _messages,
38
+ ...htmlProps
39
+ }) => /* @__PURE__ */ jsxs(
40
+ "form",
41
+ {
42
+ ...htmlProps,
43
+ noValidate: true,
44
+ action,
45
+ "aria-labelledby": `${id}-heading`,
46
+ className: bem(void 0, void 0, className),
47
+ id,
48
+ onSubmit: typeof action === "function" || typeof action === "string" ? void 0 : onFormSubmit,
49
+ children: [
50
+ /* @__PURE__ */ jsx(
51
+ Headline,
52
+ {
53
+ type: "h2",
54
+ ...headlineProps,
55
+ id: `${id}-heading`,
56
+ className: bem("label", {
57
+ "is-hidden": Boolean(hideHeadline)
58
+ }, headlineProps == null ? void 0 : headlineProps.className),
59
+ children: label
60
+ }
61
+ ),
62
+ /* @__PURE__ */ jsxs(Grid, { className: bem("grid"), spacing: 2, children: [
63
+ isArray(formState) && formState.map((field) => /* @__PURE__ */ createElement(
64
+ FormField,
65
+ {
66
+ ...field,
67
+ key: field.name,
68
+ messagesFields,
69
+ variant,
70
+ disabled: disabled !== void 0 ? disabled : field == null ? void 0 : field.disabled,
71
+ ...fieldProps
72
+ }
73
+ )),
74
+ children,
47
75
  /* @__PURE__ */ jsx(
48
- Headline,
76
+ "input",
77
+ {
78
+ "aria-hidden": "true",
79
+ className: bem("hp"),
80
+ id: "hp",
81
+ name: "hp",
82
+ type: "text",
83
+ ...honeypot
84
+ }
85
+ )
86
+ ] }),
87
+ /* @__PURE__ */ jsxs("div", { className: bem("footer"), children: [
88
+ (hideResponse === false || hideResponse === void 0) && /* @__PURE__ */ jsx(FormResponse, { messages: formMessages }),
89
+ !isNull(button) && Boolean(isHoneypotEmpty) && /* @__PURE__ */ jsx(
90
+ Button,
49
91
  {
50
- type: "h2",
51
- ...headlineProps,
52
- id: `${id}-heading`,
53
- className: bem("label", {
54
- "is-hidden": Boolean(hideHeadline)
55
- }, headlineProps == null ? void 0 : headlineProps.className),
56
- children: label
92
+ "aria-label": "Submit form",
93
+ title: "Submit",
94
+ type: "submit",
95
+ ...button,
96
+ className: bem("footer__submit", void 0, button == null ? void 0 : button.className),
97
+ color: (button == null ? void 0 : button.color) ?? variant,
98
+ disabled: Boolean(formMessages == null ? void 0 : formMessages.errors) || !isFormValid
57
99
  }
58
- ),
59
- /* @__PURE__ */ jsxs(Grid, { className: bem("grid"), spacing: 2, children: [
60
- isArray(formState) && formState.map((field) => /* @__PURE__ */ createElement(
61
- FormField,
62
- {
63
- ...field,
64
- key: field.name,
65
- messagesFields,
66
- variant,
67
- disabled: disabled !== void 0 ? disabled : field == null ? void 0 : field.disabled,
68
- ...fieldProps
69
- }
70
- )),
71
- children,
72
- /* @__PURE__ */ jsx(
73
- "input",
74
- {
75
- "aria-hidden": "true",
76
- className: bem("hp"),
77
- id: "hp",
78
- name: "hp",
79
- type: "text",
80
- ...honeypot
81
- }
82
- )
83
- ] }),
84
- /* @__PURE__ */ jsxs("div", { className: bem("footer"), children: [
85
- (hideResponse === false || hideResponse === void 0) && /* @__PURE__ */ jsx(FormResponse, { messages: formMessages }),
86
- !isNull(button) && ((_a = honeypot == null ? void 0 : honeypot.value) == null ? void 0 : _a.length) === 0 && /* @__PURE__ */ jsx(
87
- Button,
88
- {
89
- "aria-label": "Submit form",
90
- title: "Submit",
91
- type: "submit",
92
- ...button,
93
- className: bem("footer__submit", void 0, button == null ? void 0 : button.className),
94
- color: (button == null ? void 0 : button.color) ?? variant,
95
- disabled: Boolean(formMessages == null ? void 0 : formMessages.errors) || !isFormValid
96
- }
97
- )
98
- ] })
99
- ]
100
- }
101
- );
102
- }, "FormView");
100
+ )
101
+ ] })
102
+ ]
103
+ }
104
+ ), "FormView");
103
105
  export {
104
106
  FormView
105
107
  };
@@ -34,6 +34,7 @@ function FormFieldClient({
34
34
  priority: true,
35
35
  color: variant,
36
36
  ...props,
37
+ checked: typeof (props == null ? void 0 : props.value) === "boolean" ? Boolean(props == null ? void 0 : props.value) : props.checked,
37
38
  onChange: /* @__PURE__ */ __name((_, checked) => onChange == null ? void 0 : onChange(props, checked), "onChange")
38
39
  }
39
40
  )
@@ -4,7 +4,7 @@ import { jsx } from "react/jsx-runtime";
4
4
  import { create } from "../../helpers/bem.js";
5
5
  import styles from "./Grid.module.scss.js";
6
6
  const bem = create(styles, "Grid");
7
- const Grid = /* @__PURE__ */ __name(({ spacing = 2, className, children, ...props }) => /* @__PURE__ */ jsx(
7
+ const Grid = /* @__PURE__ */ __name((({ spacing = 2, className, children, ...props }) => /* @__PURE__ */ jsx(
8
8
  "div",
9
9
  {
10
10
  className: bem(void 0, void 0, className),
@@ -14,7 +14,7 @@ const Grid = /* @__PURE__ */ __name(({ spacing = 2, className, children, ...prop
14
14
  ...props,
15
15
  children
16
16
  }
17
- ), "Grid");
17
+ )), "Grid");
18
18
  Grid.displayName = "Grid";
19
19
  export {
20
20
  Grid
@@ -4,7 +4,7 @@ import { jsx } from "react/jsx-runtime";
4
4
  import { create } from "../../helpers/bem.js";
5
5
  import styles from "./GridRow.module.scss.js";
6
6
  const bem = create(styles, "GridRow");
7
- const GridRow = /* @__PURE__ */ __name(({ align, className, children, xs, sm, md, lg, xl, ...props }) => /* @__PURE__ */ jsx(
7
+ const GridRow = /* @__PURE__ */ __name((({ align, className, children, xs, sm, md, lg, xl, ...props }) => /* @__PURE__ */ jsx(
8
8
  "div",
9
9
  {
10
10
  className: bem(
@@ -22,7 +22,7 @@ const GridRow = /* @__PURE__ */ __name(({ align, className, children, xs, sm, md
22
22
  ...props,
23
23
  children
24
24
  }
25
- ), "GridRow");
25
+ )), "GridRow");
26
26
  GridRow.displayName = "GridRow";
27
27
  export {
28
28
  GridRow
@@ -32,8 +32,9 @@ function InputView({
32
32
  type = "text",
33
33
  ...rest
34
34
  }) {
35
- delete rest.onValidate;
36
- delete rest.errorTranslations;
35
+ rest == null ? true : delete rest.onValidate;
36
+ rest == null ? true : delete rest.errorTranslations;
37
+ rest == null ? true : delete rest.customRegexPattern;
37
38
  const isError = typeof errorText === "string";
38
39
  const hasValue = value !== void 0 && value !== "" || Boolean(placeholder);
39
40
  const hasHelperText = isString(helperText);
@@ -72,7 +73,8 @@ function InputView({
72
73
  id: name,
73
74
  name,
74
75
  placeholder,
75
- rows
76
+ rows,
77
+ value: value ?? ""
76
78
  }
77
79
  ) : /* @__PURE__ */ jsx(
78
80
  "input",
@@ -40,15 +40,18 @@ const handleValidation = /* @__PURE__ */ __name((type, name, value, required, mi
40
40
  password: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).{8,}$/
41
41
  };
42
42
  if (customRegexPattern !== void 0) {
43
- const regexParts = customRegexPattern.match(/^\/(.*)\/([gimsuy]*)$/);
44
- if (regexParts) {
45
- const [, pattern = "", flags] = regexParts;
46
- const customRegex = new RegExp(pattern ?? "", flags);
47
- regexPatterns = {
48
- ...regexPatterns,
49
- [String(type)]: RegExp(customRegex)
50
- };
43
+ let customRegex;
44
+ const m = customRegexPattern.match(/^\/([\s\S]*)\/([gimsuy]*)$/);
45
+ if (m) {
46
+ const [, pattern = "", flags] = m;
47
+ customRegex = new RegExp(pattern, flags);
48
+ } else {
49
+ customRegex = new RegExp(customRegexPattern);
51
50
  }
51
+ regexPatterns = {
52
+ ...regexPatterns,
53
+ [String(type)]: RegExp(customRegex)
54
+ };
52
55
  }
53
56
  const errorMessages = {
54
57
  // text: "Text can only include letters and common punctuation.",
@@ -1,4 +1,4 @@
1
- const PROKODO_UI_VERSION = "0.0.44";
1
+ const PROKODO_UI_VERSION = "0.0.46";
2
2
  export {
3
3
  PROKODO_UI_VERSION
4
4
  };