@postenbring/hedwig-react 0.0.50 → 0.0.51
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/chunk-4RD7KCEO.mjs +64 -0
- package/dist/{chunk-JOKO7Y7O.mjs → chunk-BIPWW7NV.mjs} +8 -202
- package/dist/chunk-CFMCOWLY.mjs +91 -0
- package/dist/chunk-GP3JFLYZ.mjs +204 -0
- package/dist/chunk-VIFCPFRJ.mjs +29 -0
- package/dist/form/index.mjs +8 -8
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +29236 -11
- package/dist/index.mjs +37 -12
- package/dist/navbar/index.mjs +2 -1
- package/dist/navbar/navbar-expandable-menu.mjs +2 -1
- package/dist/show-more/auto-animate-height.d.mts +30 -0
- package/dist/show-more/auto-animate-height.d.ts +30 -0
- package/dist/show-more/auto-animate-height.js +29198 -0
- package/dist/show-more/auto-animate-height.mjs +8 -0
- package/dist/show-more/show-more.d.mts +38 -0
- package/dist/show-more/show-more.d.ts +38 -0
- package/dist/show-more/show-more.js +76 -0
- package/dist/show-more/show-more.mjs +7 -0
- package/dist/step-indicator/step-indicator.d.mts +42 -0
- package/dist/step-indicator/step-indicator.d.ts +42 -0
- package/dist/step-indicator/step-indicator.js +111 -0
- package/dist/step-indicator/step-indicator.mjs +7 -0
- package/package.json +2 -2
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface ShowMoreProps extends React.HTMLAttributes<HTMLButtonElement> {
|
|
4
|
+
text: React.ReactNode;
|
|
5
|
+
expanded?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Simple button for triggering more content.
|
|
9
|
+
*
|
|
10
|
+
* You have to add the logic for what happens when the button is clicked yourself.
|
|
11
|
+
*
|
|
12
|
+
* **Example**
|
|
13
|
+
*
|
|
14
|
+
* ```tsx
|
|
15
|
+
* function Content() {
|
|
16
|
+
* const [items, fetchMoreItems, moreItemsAvailable] = useYourData();
|
|
17
|
+
* function onShowMoreItems() {
|
|
18
|
+
* fetchMoreItems();
|
|
19
|
+
* }
|
|
20
|
+
* return (
|
|
21
|
+
* <>
|
|
22
|
+
* <ul>
|
|
23
|
+
* {items.map((item) => (
|
|
24
|
+
* <li key={item.id}>{item.text}</li>
|
|
25
|
+
* ))}
|
|
26
|
+
* </ul>
|
|
27
|
+
* {moreItemsAvailable ?
|
|
28
|
+
* <ShowMoreButton className="mt-small-2" onClick={onShowMoreItems} lang="en" /> :
|
|
29
|
+
* null
|
|
30
|
+
* }
|
|
31
|
+
* </>
|
|
32
|
+
* )
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare function ShowMoreButton({ text, expanded, className, ...rest }: ShowMoreProps): react_jsx_runtime.JSX.Element;
|
|
37
|
+
|
|
38
|
+
export { ShowMoreButton };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
interface ShowMoreProps extends React.HTMLAttributes<HTMLButtonElement> {
|
|
4
|
+
text: React.ReactNode;
|
|
5
|
+
expanded?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Simple button for triggering more content.
|
|
9
|
+
*
|
|
10
|
+
* You have to add the logic for what happens when the button is clicked yourself.
|
|
11
|
+
*
|
|
12
|
+
* **Example**
|
|
13
|
+
*
|
|
14
|
+
* ```tsx
|
|
15
|
+
* function Content() {
|
|
16
|
+
* const [items, fetchMoreItems, moreItemsAvailable] = useYourData();
|
|
17
|
+
* function onShowMoreItems() {
|
|
18
|
+
* fetchMoreItems();
|
|
19
|
+
* }
|
|
20
|
+
* return (
|
|
21
|
+
* <>
|
|
22
|
+
* <ul>
|
|
23
|
+
* {items.map((item) => (
|
|
24
|
+
* <li key={item.id}>{item.text}</li>
|
|
25
|
+
* ))}
|
|
26
|
+
* </ul>
|
|
27
|
+
* {moreItemsAvailable ?
|
|
28
|
+
* <ShowMoreButton className="mt-small-2" onClick={onShowMoreItems} lang="en" /> :
|
|
29
|
+
* null
|
|
30
|
+
* }
|
|
31
|
+
* </>
|
|
32
|
+
* )
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare function ShowMoreButton({ text, expanded, className, ...rest }: ShowMoreProps): react_jsx_runtime.JSX.Element;
|
|
37
|
+
|
|
38
|
+
export { ShowMoreButton };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __objRest = (source, exclude) => {
|
|
24
|
+
var target = {};
|
|
25
|
+
for (var prop in source)
|
|
26
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
27
|
+
target[prop] = source[prop];
|
|
28
|
+
if (source != null && __getOwnPropSymbols)
|
|
29
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
30
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
31
|
+
target[prop] = source[prop];
|
|
32
|
+
}
|
|
33
|
+
return target;
|
|
34
|
+
};
|
|
35
|
+
var __export = (target, all) => {
|
|
36
|
+
for (var name in all)
|
|
37
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
38
|
+
};
|
|
39
|
+
var __copyProps = (to, from, except, desc) => {
|
|
40
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
41
|
+
for (let key of __getOwnPropNames(from))
|
|
42
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
43
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
44
|
+
}
|
|
45
|
+
return to;
|
|
46
|
+
};
|
|
47
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
48
|
+
|
|
49
|
+
// src/show-more/show-more.tsx
|
|
50
|
+
var show_more_exports = {};
|
|
51
|
+
__export(show_more_exports, {
|
|
52
|
+
ShowMoreButton: () => ShowMoreButton
|
|
53
|
+
});
|
|
54
|
+
module.exports = __toCommonJS(show_more_exports);
|
|
55
|
+
var import_typed_classname = require("@postenbring/hedwig-css/typed-classname/index.mjs");
|
|
56
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
57
|
+
function ShowMoreButton(_a) {
|
|
58
|
+
var _b = _a, { text, expanded = false, className } = _b, rest = __objRest(_b, ["text", "expanded", "className"]);
|
|
59
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
60
|
+
"button",
|
|
61
|
+
__spreadProps(__spreadValues({
|
|
62
|
+
className: (0, import_typed_classname.clsx)("hds-show-more", className),
|
|
63
|
+
"data-state": expanded ? "expanded" : void 0,
|
|
64
|
+
type: "button"
|
|
65
|
+
}, rest), {
|
|
66
|
+
children: [
|
|
67
|
+
text,
|
|
68
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: (0, import_typed_classname.clsx)("hds-show-more__icon") })
|
|
69
|
+
]
|
|
70
|
+
})
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
+
0 && (module.exports = {
|
|
75
|
+
ShowMoreButton
|
|
76
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
type TitleProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Optional title of the active step to be shown underneath the step indicator
|
|
6
|
+
*
|
|
7
|
+
* Use `titleAs` to set the correct heading level
|
|
8
|
+
*/
|
|
9
|
+
title: React.ReactNode;
|
|
10
|
+
titleAs: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
|
11
|
+
} | {
|
|
12
|
+
title?: undefined;
|
|
13
|
+
titleAs?: undefined;
|
|
14
|
+
};
|
|
15
|
+
interface StepIndicatorProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
16
|
+
activeStep: number;
|
|
17
|
+
/**
|
|
18
|
+
* 1-indexed number of steps
|
|
19
|
+
*/
|
|
20
|
+
totalSteps: number;
|
|
21
|
+
/**
|
|
22
|
+
* Label on the left side above the steps
|
|
23
|
+
*/
|
|
24
|
+
leftLabel: React.ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Override the label on the right side above the steps
|
|
27
|
+
* Default is "step x of y". use {@link rightLabelLang} to change language
|
|
28
|
+
*/
|
|
29
|
+
rightLabel?: React.ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Language for the "step x of y" label, default is "en"
|
|
32
|
+
*/
|
|
33
|
+
rightLabelLang?: "no" | "en" | "da" | "sv";
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Indicate a step in a process.
|
|
37
|
+
*
|
|
38
|
+
* It does not handle step content or navigation, only the visual indication of the active step.
|
|
39
|
+
*/
|
|
40
|
+
declare function StepIndicator({ activeStep, totalSteps, className, leftLabel, rightLabel, rightLabelLang, title, titleAs: TitleComponent, ...rest }: StepIndicatorProps & TitleProps): react_jsx_runtime.JSX.Element;
|
|
41
|
+
|
|
42
|
+
export { StepIndicator };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
type TitleProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Optional title of the active step to be shown underneath the step indicator
|
|
6
|
+
*
|
|
7
|
+
* Use `titleAs` to set the correct heading level
|
|
8
|
+
*/
|
|
9
|
+
title: React.ReactNode;
|
|
10
|
+
titleAs: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
|
11
|
+
} | {
|
|
12
|
+
title?: undefined;
|
|
13
|
+
titleAs?: undefined;
|
|
14
|
+
};
|
|
15
|
+
interface StepIndicatorProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
16
|
+
activeStep: number;
|
|
17
|
+
/**
|
|
18
|
+
* 1-indexed number of steps
|
|
19
|
+
*/
|
|
20
|
+
totalSteps: number;
|
|
21
|
+
/**
|
|
22
|
+
* Label on the left side above the steps
|
|
23
|
+
*/
|
|
24
|
+
leftLabel: React.ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Override the label on the right side above the steps
|
|
27
|
+
* Default is "step x of y". use {@link rightLabelLang} to change language
|
|
28
|
+
*/
|
|
29
|
+
rightLabel?: React.ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Language for the "step x of y" label, default is "en"
|
|
32
|
+
*/
|
|
33
|
+
rightLabelLang?: "no" | "en" | "da" | "sv";
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Indicate a step in a process.
|
|
37
|
+
*
|
|
38
|
+
* It does not handle step content or navigation, only the visual indication of the active step.
|
|
39
|
+
*/
|
|
40
|
+
declare function StepIndicator({ activeStep, totalSteps, className, leftLabel, rightLabel, rightLabelLang, title, titleAs: TitleComponent, ...rest }: StepIndicatorProps & TitleProps): react_jsx_runtime.JSX.Element;
|
|
41
|
+
|
|
42
|
+
export { StepIndicator };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __objRest = (source, exclude) => {
|
|
24
|
+
var target = {};
|
|
25
|
+
for (var prop in source)
|
|
26
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
27
|
+
target[prop] = source[prop];
|
|
28
|
+
if (source != null && __getOwnPropSymbols)
|
|
29
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
30
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
31
|
+
target[prop] = source[prop];
|
|
32
|
+
}
|
|
33
|
+
return target;
|
|
34
|
+
};
|
|
35
|
+
var __export = (target, all) => {
|
|
36
|
+
for (var name in all)
|
|
37
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
38
|
+
};
|
|
39
|
+
var __copyProps = (to, from, except, desc) => {
|
|
40
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
41
|
+
for (let key of __getOwnPropNames(from))
|
|
42
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
43
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
44
|
+
}
|
|
45
|
+
return to;
|
|
46
|
+
};
|
|
47
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
48
|
+
|
|
49
|
+
// src/step-indicator/step-indicator.tsx
|
|
50
|
+
var step_indicator_exports = {};
|
|
51
|
+
__export(step_indicator_exports, {
|
|
52
|
+
StepIndicator: () => StepIndicator
|
|
53
|
+
});
|
|
54
|
+
module.exports = __toCommonJS(step_indicator_exports);
|
|
55
|
+
var import_typed_classname = require("@postenbring/hedwig-css/typed-classname/index.mjs");
|
|
56
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
57
|
+
function StepIndicator(_a) {
|
|
58
|
+
var _b = _a, {
|
|
59
|
+
activeStep,
|
|
60
|
+
totalSteps,
|
|
61
|
+
className,
|
|
62
|
+
leftLabel,
|
|
63
|
+
rightLabel,
|
|
64
|
+
rightLabelLang = "en",
|
|
65
|
+
title,
|
|
66
|
+
titleAs: TitleComponent
|
|
67
|
+
} = _b, rest = __objRest(_b, [
|
|
68
|
+
"activeStep",
|
|
69
|
+
"totalSteps",
|
|
70
|
+
"className",
|
|
71
|
+
"leftLabel",
|
|
72
|
+
"rightLabel",
|
|
73
|
+
"rightLabelLang",
|
|
74
|
+
"title",
|
|
75
|
+
"titleAs"
|
|
76
|
+
]);
|
|
77
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", __spreadProps(__spreadValues({ className: (0, import_typed_classname.clsx)("hds-step-indicator", className) }, rest), { children: [
|
|
78
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_typed_classname.clsx)("hds-step-indicator__header"), children: [
|
|
79
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: (0, import_typed_classname.clsx)("hds-step-indicator__left-label"), children: leftLabel }),
|
|
80
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { lang: rightLabel ? void 0 : rightLabelLang, children: rightLabel != null ? rightLabel : stepLabelTranslations[rightLabelLang](activeStep, totalSteps) })
|
|
81
|
+
] }),
|
|
82
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_typed_classname.clsx)("hds-step-indicator__steps"), children: Array.from({ length: totalSteps }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
83
|
+
"div",
|
|
84
|
+
{
|
|
85
|
+
className: (0, import_typed_classname.clsx)("hds-step-indicator__step"),
|
|
86
|
+
"data-state": getStepState(i + 1, activeStep)
|
|
87
|
+
},
|
|
88
|
+
i
|
|
89
|
+
)) }),
|
|
90
|
+
title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TitleComponent, { className: (0, import_typed_classname.clsx)("hds-step-indicator__title"), children: title }) : null
|
|
91
|
+
] }));
|
|
92
|
+
}
|
|
93
|
+
var stepLabelTranslations = {
|
|
94
|
+
no: (activeStep, totalSteps) => `steg ${activeStep} av ${totalSteps}`,
|
|
95
|
+
en: (activeStep, totalSteps) => `step ${activeStep} of ${totalSteps}`,
|
|
96
|
+
da: (activeStep, totalSteps) => `trin ${activeStep} af ${totalSteps}`,
|
|
97
|
+
sv: (activeStep, totalSteps) => `steg ${activeStep} av ${totalSteps}`
|
|
98
|
+
};
|
|
99
|
+
function getStepState(renderedStep, activeStep) {
|
|
100
|
+
if (renderedStep < activeStep) {
|
|
101
|
+
return "previous";
|
|
102
|
+
}
|
|
103
|
+
if (renderedStep === activeStep) {
|
|
104
|
+
return "active";
|
|
105
|
+
}
|
|
106
|
+
return "next";
|
|
107
|
+
}
|
|
108
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
109
|
+
0 && (module.exports = {
|
|
110
|
+
StepIndicator
|
|
111
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@postenbring/hedwig-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.51",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"hedwig-tsconfig": "0.0.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@postenbring/hedwig-css": "0.0.
|
|
23
|
+
"@postenbring/hedwig-css": "0.0.46"
|
|
24
24
|
},
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "public"
|