@public-ui/sample-react 1.7.14 → 1.7.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.
Files changed (81) hide show
  1. package/dist/104.js +1 -1
  2. package/dist/1296.js +1 -1
  3. package/dist/1461.js +1 -1
  4. package/dist/1684.js +1 -1
  5. package/dist/1720.js +1 -1
  6. package/dist/{392.js → 176.js} +2 -2
  7. package/dist/{3044.js → 1760.js} +2 -2
  8. package/dist/1888.js +1 -1
  9. package/dist/2120.js +1 -1
  10. package/dist/2240.js +1 -1
  11. package/dist/2444.js +1 -1
  12. package/dist/2628.js +1 -1
  13. package/dist/2740.js +1 -1
  14. package/dist/2764.js +1 -1
  15. package/dist/2782.js +1 -1
  16. package/dist/2812.js +1 -1
  17. package/dist/3200.js +1 -1
  18. package/dist/3204.js +1 -1
  19. package/dist/352.js +1 -1
  20. package/dist/3564.js +1 -1
  21. package/dist/3920.js +1 -1
  22. package/dist/4064.js +1 -1
  23. package/dist/4136.js +1 -1
  24. package/dist/4184.js +1 -1
  25. package/dist/4544.js +1 -1
  26. package/dist/4688.js +1 -0
  27. package/dist/4728.js +1 -1
  28. package/dist/4915.js +1 -1
  29. package/dist/4988.js +1 -1
  30. package/dist/5376.js +1 -1
  31. package/dist/5456.js +1 -1
  32. package/dist/5615.js +1 -1
  33. package/dist/5628.js +1 -1
  34. package/dist/5744.js +1 -1
  35. package/dist/5768.js +1 -1
  36. package/dist/5839.js +1 -1
  37. package/dist/5956.js +1 -1
  38. package/dist/5972.js +1 -1
  39. package/dist/6040.js +1 -1
  40. package/dist/6272.js +1 -1
  41. package/dist/7192.js +1 -1
  42. package/dist/7312.js +1 -1
  43. package/dist/7344.js +1 -1
  44. package/dist/736.js +1 -1
  45. package/dist/7496.js +1 -1
  46. package/dist/7508.js +1 -1
  47. package/dist/7596.js +1 -1
  48. package/dist/{5496.js → 7668.js} +2 -2
  49. package/dist/7712.js +1 -1
  50. package/dist/7808.js +1 -1
  51. package/dist/8188.js +1 -1
  52. package/dist/8232.js +1 -1
  53. package/dist/8248.js +1 -1
  54. package/dist/828.js +1 -1
  55. package/dist/8476.js +1 -1
  56. package/dist/8524.js +1 -1
  57. package/dist/9088.js +1 -1
  58. package/dist/9404.js +1 -1
  59. package/dist/9424.js +1 -1
  60. package/dist/9496.js +1 -1
  61. package/dist/9544.js +1 -1
  62. package/dist/9680.js +1 -1
  63. package/dist/9888.js +1 -1
  64. package/dist/9984.js +1 -1
  65. package/dist/main.js +1 -1
  66. package/dist/main.js.LICENSE.txt +2 -2
  67. package/package.json +13 -13
  68. package/src/App.tsx +1 -1
  69. package/src/components/Sidebar.tsx +1 -1
  70. package/src/react.main.tsx +10 -3
  71. package/src/scenarios/appointment-form/AppointmentForm.tsx +0 -1
  72. package/src/scenarios/appointment-form/AvailableAppointmentsForm.tsx +11 -4
  73. package/src/scenarios/appointment-form/DistrictForm.tsx +9 -2
  74. package/src/scenarios/appointment-form/PersonalInformationForm.tsx +9 -2
  75. package/src/scenarios/appointment-form/formUtils.ts +6 -0
  76. package/src/scenarios/static-form.tsx +15 -0
  77. package/dist/12.js +0 -2
  78. package/dist/5496.js.LICENSE.txt +0 -3
  79. /package/dist/{12.js.LICENSE.txt → 176.js.LICENSE.txt} +0 -0
  80. /package/dist/{3044.js.LICENSE.txt → 1760.js.LICENSE.txt} +0 -0
  81. /package/dist/{392.js.LICENSE.txt → 7668.js.LICENSE.txt} +0 -0
@@ -33,7 +33,7 @@
33
33
  */
34
34
 
35
35
  /**
36
- * @remix-run/router v1.15.1
36
+ * @remix-run/router v1.15.3
37
37
  *
38
38
  * Copyright (c) Remix Software Inc.
39
39
  *
@@ -44,7 +44,7 @@
44
44
  */
45
45
 
46
46
  /**
47
- * React Router v6.22.1
47
+ * React Router v6.22.3
48
48
  *
49
49
  * Copyright (c) Remix Software Inc.
50
50
  *
package/package.json CHANGED
@@ -1,37 +1,37 @@
1
1
  {
2
2
  "name": "@public-ui/sample-react",
3
- "version": "1.7.14",
3
+ "version": "1.7.15",
4
4
  "description": "This app contains samples for the KoliBri/Public UI",
5
5
  "license": "EUPL-1.2",
6
6
  "dependencies": {
7
7
  "@leanup/stack": "1.3.49",
8
8
  "@leanup/stack-react": "1.3.49",
9
9
  "@leanup/stack-webpack": "1.3.49",
10
- "@public-ui/components": "1.7.14",
11
- "@public-ui/react": "1.7.14",
12
- "@public-ui/themes": "1.7.14",
13
- "@types/node": "20.11.19",
14
- "@types/react": "18.2.57",
15
- "@types/react-dom": "18.2.19",
10
+ "@public-ui/components": "1.7.15",
11
+ "@public-ui/react": "1.7.15",
12
+ "@public-ui/themes": "1.7.15",
13
+ "@types/node": "20.11.25",
14
+ "@types/react": "18.2.64",
15
+ "@types/react-dom": "18.2.21",
16
16
  "@unocss/preset-uno": "0.58.5",
17
17
  "@unocss/webpack": "0.58.5",
18
18
  "ajv": "8.12.0",
19
- "chromedriver": "121.0.2",
19
+ "chromedriver": "122.0.4",
20
20
  "cpy-cli": "5.0.0",
21
21
  "eslint-plugin-jsx-a11y": "6.8.0",
22
- "eslint-plugin-react": "7.33.2",
22
+ "eslint-plugin-react": "7.34.0",
23
23
  "formik": "2.4.5",
24
24
  "nightwatch-axe-verbose": "2.3.0",
25
25
  "npm-run-all": "4.1.5",
26
26
  "react": "18.2.0",
27
27
  "react-dom": "18.2.0",
28
- "react-router": "6.22.1",
29
- "react-router-dom": "6.22.1",
28
+ "react-router": "6.22.3",
29
+ "react-router-dom": "6.22.3",
30
30
  "rimraf": "3.0.2",
31
31
  "ts-prune": "0.10.3",
32
- "typescript": "5.3.3",
32
+ "typescript": "5.4.2",
33
33
  "world_countries_lists": "2.9.0",
34
- "yup": "1.3.3"
34
+ "yup": "1.4.0"
35
35
  },
36
36
  "files": [
37
37
  ".eslintignore",
package/src/App.tsx CHANGED
@@ -134,7 +134,7 @@ export const App: FC = () => {
134
134
  {!hideMenus && isDraftTheme(theme) && <KolBadge className="mb-3" _label="DRAFT" _color="#db5461" />}
135
135
  <Routes>
136
136
  {ROUTE_TREE}
137
- <Route path="*" element={<KolAlert _type="info">This code example has not been migrated yet - it&#39;s coming soon!</KolAlert>} />
137
+ <Route path="*" element={<Navigate to={ROUTE_LIST[0]} replace />} />
138
138
  <Route path="back-page" element={<BackPage />} />
139
139
  </Routes>
140
140
  </div>
@@ -44,7 +44,7 @@ export const Sidebar: FC<Props> = ({ version, theme, routes, routeList, sample,
44
44
 
45
45
  const handlePreviousClick = () => {
46
46
  const currentIndex = getIndexOfSample();
47
- const nextIndex = currentIndex === 0 ? routeList.length - 1 : currentIndex - 1;
47
+ const nextIndex = currentIndex <= 0 ? routeList.length - 1 : currentIndex - 1;
48
48
  location.replace(`#${routeList[nextIndex]}`);
49
49
  };
50
50
 
@@ -2,7 +2,7 @@ import React, { StrictMode } from 'react';
2
2
  import { createRoot } from 'react-dom/client';
3
3
  import { HashRouter as Router } from 'react-router-dom';
4
4
 
5
- import { register } from '@public-ui/components';
5
+ import { bootstrap } from '@public-ui/components';
6
6
  import { defineCustomElements } from '@public-ui/components/dist/loader';
7
7
  import { BMF, DEFAULT, ECL_EC, ECL_EU, ITZBund } from '@public-ui/themes';
8
8
  import type { Generic } from 'adopted-style-sheets';
@@ -15,17 +15,24 @@ void (async () => {
15
15
  /* Visual regression testing mode: Themes are overridden with a certain theme module, that should be used instead. */
16
16
  const { [(process.env.THEME_EXPORT as string) ?? 'default']: theme } = (await import(process.env.THEME_MODULE)) as Record<string, Theme>;
17
17
  try {
18
- await register([theme], defineCustomElements);
18
+ await bootstrap([theme], defineCustomElements, {
19
+ translation: {
20
+ name: 'de',
21
+ },
22
+ });
19
23
  } catch (error) {
20
24
  console.warn('Theme registration failed:', error);
21
25
  }
22
26
  } else {
23
27
  /* Regular mode: Register all known themes. */
24
28
  try {
25
- await register([BMF, DEFAULT, ECL_EC, ECL_EU, ITZBund], defineCustomElements, {
29
+ await bootstrap([BMF, DEFAULT, ECL_EC, ECL_EU, ITZBund], defineCustomElements, {
26
30
  theme: {
27
31
  detect: 'auto',
28
32
  },
33
+ translation: {
34
+ name: 'de',
35
+ },
29
36
  });
30
37
  } catch (error) {
31
38
  console.warn('Theme registration failed:', error);
@@ -77,7 +77,6 @@ export function AppointmentForm() {
77
77
  }, [activeFormSection]);
78
78
 
79
79
  const handleSubmit = async (_values: FormValues, formik: FormikHelpers<FormValues>) => {
80
- console.log(_values, formik);
81
80
  const currentSectionIndex = formSectionSequence.indexOf(activeFormSection);
82
81
  const nextSection = formSectionSequence[currentSectionIndex + 1];
83
82
  if (nextSection !== undefined) {
@@ -1,22 +1,27 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import React, { useEffect, useState, useRef } from 'react';
2
2
  import { KolButton, KolForm, KolHeading, KolInputDate, KolInputRadio, KolSpin } from '@public-ui/react';
3
3
  import { FormValues } from './AppointmentForm';
4
4
  import { Field, FieldProps, useFormikContext } from 'formik';
5
5
  import { fetchAvailableTimes } from './appointmentService';
6
6
  import { Option } from '@public-ui/components/src';
7
- import { createErrorList } from './formUtils';
7
+ import { createErrorList, focusErrorList } from './formUtils';
8
8
 
9
9
  export function AvailableAppointmentsForm() {
10
10
  const form = useFormikContext<FormValues>();
11
11
 
12
12
  const [sectionSubmitted, setSectionSubmitted] = useState(false);
13
13
  const [availableTimes, setAvailableTimes] = useState<Option<string>[] | null>(null);
14
+ const [schouldFocusErrorList, setSchouldFocusErrorList] = useState(true);
14
15
  const errorList = createErrorList(form.errors);
16
+ const formikRef = useRef(null);
15
17
 
16
18
  useEffect(() => {
17
19
  let ignoreResponse = false;
18
20
  setAvailableTimes(null);
19
-
21
+ if (schouldFocusErrorList && sectionSubmitted) {
22
+ focusErrorList(errorList, formikRef);
23
+ setSchouldFocusErrorList(false);
24
+ }
20
25
  if (form.values.date) {
21
26
  fetchAvailableTimes().then(
22
27
  (times) => {
@@ -32,17 +37,19 @@ export function AvailableAppointmentsForm() {
32
37
  return () => {
33
38
  ignoreResponse = true;
34
39
  };
35
- }, [form.values.date]);
40
+ }, [form.values.date, sectionSubmitted]);
36
41
 
37
42
  return (
38
43
  <div className="p-2">
39
44
  <KolHeading _level={2} _label="Wählen Sie einen Termin aus"></KolHeading>
40
45
  <KolForm
46
+ ref={formikRef}
41
47
  _errorList={sectionSubmitted ? errorList : []}
42
48
  _on={{
43
49
  onSubmit: () => {
44
50
  void form.submitForm();
45
51
  setSectionSubmitted(true);
52
+ focusErrorList(errorList, formikRef);
46
53
  },
47
54
  }}
48
55
  >
@@ -1,8 +1,8 @@
1
- import React, { useState } from 'react';
1
+ import React, { useState, useRef, useEffect } from 'react';
2
2
  import { KolButton, KolForm, KolHeading, KolSelect } from '@public-ui/react';
3
3
  import { Field, FieldProps, useFormikContext } from 'formik';
4
4
  import { FormValues } from './AppointmentForm';
5
- import { createErrorList } from './formUtils';
5
+ import { createErrorList, focusErrorList } from './formUtils';
6
6
 
7
7
  const LOCATION_OPTIONS = [
8
8
  {
@@ -31,16 +31,23 @@ export function DistrictForm() {
31
31
  const form = useFormikContext<FormValues>();
32
32
  const [sectionSubmitted, setSectionSubmitted] = useState(false);
33
33
  const errorList = createErrorList(form.errors);
34
+ const formikRef = useRef<HTMLKolFormElement>(null);
35
+
36
+ useEffect(() => {
37
+ focusErrorList(errorList, formikRef);
38
+ }, [sectionSubmitted]);
34
39
 
35
40
  return (
36
41
  <div className="p-2">
37
42
  <KolHeading _level={2} _label="Wählen Sie einen Stadtteil aus"></KolHeading>
38
43
  <KolForm
44
+ ref={formikRef}
39
45
  _errorList={sectionSubmitted ? errorList : []}
40
46
  _on={{
41
47
  onSubmit: () => {
42
48
  void form.submitForm();
43
49
  setSectionSubmitted(true);
50
+ focusErrorList(errorList, formikRef);
44
51
  },
45
52
  }}
46
53
  >
@@ -1,8 +1,8 @@
1
- import React, { useState } from 'react';
1
+ import React, { useState, useEffect, useRef } from 'react';
2
2
  import { KolButton, KolForm, KolHeading, KolInputEmail, KolInputText, KolSelect } from '@public-ui/react';
3
3
  import { Field, FieldProps, useFormikContext } from 'formik';
4
4
  import { FormValues } from './AppointmentForm';
5
- import { createErrorList } from './formUtils';
5
+ import { createErrorList, focusErrorList } from './formUtils';
6
6
 
7
7
  const SALUTATION_OPTIONS = [
8
8
  {
@@ -27,16 +27,23 @@ export function PersonalInformationForm() {
27
27
  const form = useFormikContext<FormValues>();
28
28
  const [sectionSubmitted, setSectionSubmitted] = useState(false);
29
29
  const errorList = createErrorList(form.errors);
30
+ const formikRef = useRef(null);
31
+
32
+ useEffect(() => {
33
+ focusErrorList(errorList, formikRef);
34
+ }, [sectionSubmitted]);
30
35
 
31
36
  return (
32
37
  <div className="p-2">
33
38
  <KolHeading _level={2} _label="Geben Sie Ihre Kontaktdaten ein"></KolHeading>
34
39
  <KolForm
40
+ ref={formikRef}
35
41
  _errorList={sectionSubmitted ? errorList : []}
36
42
  _on={{
37
43
  onSubmit: () => {
38
44
  void form.submitForm();
39
45
  setSectionSubmitted(true);
46
+ focusErrorList(errorList, formikRef);
40
47
  },
41
48
  }}
42
49
  >
@@ -6,3 +6,9 @@ export function createErrorList(formikErrors: Record<string, string>): ErrorList
6
6
  selector: `#field-${fieldName}`,
7
7
  }));
8
8
  }
9
+
10
+ export function focusErrorList(errorList: ErrorListPropType[], formikRef: React.RefObject<HTMLKolFormElement>) {
11
+ if (errorList.length > 0 && formikRef && formikRef.current) {
12
+ formikRef.current.focusErrorList().catch(console.warn);
13
+ }
14
+ }
@@ -18,6 +18,8 @@ import React from 'react';
18
18
  import { SampleDescription } from '../components/SampleDescription';
19
19
 
20
20
  export const StaticForm: FC = () => {
21
+ const { searchParams } = new URL(location.href);
22
+
21
23
  return (
22
24
  <>
23
25
  <SampleDescription>
@@ -41,6 +43,16 @@ export const StaticForm: FC = () => {
41
43
  </li>
42
44
  </ol>
43
45
  </SampleDescription>
46
+
47
+ {searchParams.size > 0 && (
48
+ <>
49
+ <h2>Submitted data</h2>
50
+ <pre>
51
+ <code>{JSON.stringify(Object.fromEntries(searchParams.entries()), null, 2)}</code>
52
+ </pre>
53
+ </>
54
+ )}
55
+
44
56
  <form className="grid gap-4" method="get" noValidate>
45
57
  <KolInputCheckbox _name="checkbox" _label="Checkbox" />
46
58
  <KolInputColor _name="color" _label="Color" />
@@ -83,6 +95,9 @@ export const StaticForm: FC = () => {
83
95
  <KolButton _label="Submit" _type="submit" _variant="primary" />
84
96
  <KolButton _label="Reset" _type="reset" />
85
97
  </div>
98
+
99
+ {/* Add a random string to allow the form to be always submitted. Without it, if theres no change to the data, the form simply won't submit when requested. */}
100
+ <input type="hidden" value={crypto.randomUUID()} name="random" />
86
101
  </form>
87
102
  </>
88
103
  );
package/dist/12.js DELETED
@@ -1,2 +0,0 @@
1
- /*! For license information please see 12.js.LICENSE.txt */
2
- "use strict";(self.webpackChunk_public_ui_sample_react=self.webpackChunk_public_ui_sample_react||[]).push([[12],{6040:(t,e,i)=>{i.r(e),i.d(e,{initialize:()=>a});var l=i(3304),r=i(5496);function n(t,e){try{Object.defineProperty((0,l.g)(),t,{get:function(){return e}})}catch(e){l.L.debug(`KoliBri property ${t} is already bind.`)}}const o=(t,e)=>l.L.debug(`${t} ${e?"":"not "}activated`),a=()=>{if((0,l.i)(),(0,l.e)()){(0,l.r)(),n("a11yColorContrast",r.q),n("querySelector",r.k),n("querySelectorAll",r.t),n("querySelectorColors",r.u),n("utils",(function(){return r.n})),n("parseJson",r.p),n("stringifyJson",r.v);const t=(0,l.a)().body,e=(0,l.a)().createElement("svg");if(e.setAttribute("aria-label","KoliBri-DevTools"),e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttribute("role","toolbar"),e.setAttribute("style","position: fixed;color: black;font-size: 200%;bottom: 0.25rem;right: 0.25rem;"),e.innerHTML='<svg\n xmlns="http://www.w3.org/2000/svg"\n width="50"\n height="50"\n viewBox="0 0 600 600"\n>\n <path d="M353 322L213 304V434L353 322Z" fill="#047" />\n <path d="M209 564V304L149 434L209 564Z" fill="#047" />\n <path d="M357 316L417 250L361 210L275 244L357 316Z" fill="#047" />\n <path d="M353 318L35 36L213 300L353 318Z" fill="#047" />\n <path d="M329 218L237 92L250 222L272 241L329 218Z" fill="#047" />\n <path d="M391 286L565 272L421 252L391 286Z" fill="#047" />\n</svg>',(0,l.a)().body.appendChild(e),o("Development mode",(0,l.e)()),o("Experimental mode",(0,l.d)()),o("Color contrast analysis",(0,l.f)()),(0,l.f)()){const e=setTimeout((()=>{clearTimeout(e),setInterval((()=>{r.n.queryHtmlElementColors((0,l.a)().createElement("div"),(0,r.q)(t),!1,!1)}),1e4)}),2500)}}}}}]);
@@ -1,3 +0,0 @@
1
- /*!
2
- * KoliBri - The accessible HTML-Standard
3
- */
File without changes