plura-assistent 1.0.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/index.cjs +126 -0
- package/dist/index.d.cts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +87 -0
- package/package.json +25 -0
- package/src/ContrastBorder.tsx +11 -0
- package/src/ToggleContrast.tsx +62 -0
- package/src/index.ts +3 -0
- package/src/registerContrastBorder.ts +27 -0
- package/tsconfig.json +24 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
ContrastBorder: () => ContrastBorder,
|
|
34
|
+
ToggleContrast: () => ToggleContrast,
|
|
35
|
+
registerContrastBorder: () => registerContrastBorder
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(index_exports);
|
|
38
|
+
|
|
39
|
+
// src/ToggleContrast.tsx
|
|
40
|
+
var React = __toESM(require("react"), 1);
|
|
41
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
42
|
+
function ToggleContrast({
|
|
43
|
+
className,
|
|
44
|
+
icon,
|
|
45
|
+
label,
|
|
46
|
+
ariaLabel = "Ativar/Desativar alto contraste",
|
|
47
|
+
title = "Alto contraste",
|
|
48
|
+
onToggle
|
|
49
|
+
}) {
|
|
50
|
+
const [isActive, setIsActive] = React.useState(false);
|
|
51
|
+
const apply = React.useCallback(
|
|
52
|
+
(active) => {
|
|
53
|
+
const body = document.body;
|
|
54
|
+
if (active) {
|
|
55
|
+
body.classList.add("contrast");
|
|
56
|
+
localStorage.setItem("contrast", "contrast");
|
|
57
|
+
} else {
|
|
58
|
+
body.classList.remove("contrast");
|
|
59
|
+
localStorage.removeItem("contrast");
|
|
60
|
+
}
|
|
61
|
+
setIsActive(active);
|
|
62
|
+
onToggle?.(active);
|
|
63
|
+
},
|
|
64
|
+
[onToggle]
|
|
65
|
+
);
|
|
66
|
+
const toggle = React.useCallback(() => {
|
|
67
|
+
apply(!isActive);
|
|
68
|
+
}, [apply, isActive]);
|
|
69
|
+
React.useEffect(() => {
|
|
70
|
+
const saved = typeof window !== "undefined" ? localStorage.getItem("contrast") : null;
|
|
71
|
+
if (saved === "contrast") {
|
|
72
|
+
apply(true);
|
|
73
|
+
}
|
|
74
|
+
}, [apply]);
|
|
75
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
76
|
+
"button",
|
|
77
|
+
{
|
|
78
|
+
type: "button",
|
|
79
|
+
onClick: toggle,
|
|
80
|
+
className: className ?? "",
|
|
81
|
+
"aria-label": label ? void 0 : ariaLabel,
|
|
82
|
+
"aria-pressed": isActive,
|
|
83
|
+
title: label ? void 0 : title,
|
|
84
|
+
children: [
|
|
85
|
+
icon,
|
|
86
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: label }) : null
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// src/ContrastBorder.tsx
|
|
93
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
94
|
+
function ContrastBorder({ children, className = "", ...rest }) {
|
|
95
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: `card ${className}`, ...rest, children });
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// src/registerContrastBorder.ts
|
|
99
|
+
function registerContrastBorder() {
|
|
100
|
+
if (typeof window === "undefined") return;
|
|
101
|
+
if (customElements.get("contrast-border")) return;
|
|
102
|
+
class ContrastBorderElement extends HTMLElement {
|
|
103
|
+
constructor() {
|
|
104
|
+
super();
|
|
105
|
+
const shadow = this.attachShadow({ mode: "open" });
|
|
106
|
+
const wrapper = document.createElement("div");
|
|
107
|
+
wrapper.setAttribute("class", "card");
|
|
108
|
+
wrapper.innerHTML = `<slot></slot>`;
|
|
109
|
+
const style = document.createElement("style");
|
|
110
|
+
style.textContent = `
|
|
111
|
+
:host {
|
|
112
|
+
display: block;
|
|
113
|
+
}
|
|
114
|
+
`;
|
|
115
|
+
shadow.appendChild(style);
|
|
116
|
+
shadow.appendChild(wrapper);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
customElements.define("contrast-border", ContrastBorderElement);
|
|
120
|
+
}
|
|
121
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
+
0 && (module.exports = {
|
|
123
|
+
ContrastBorder,
|
|
124
|
+
ToggleContrast,
|
|
125
|
+
registerContrastBorder
|
|
126
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
type ToggleContrastProps = {
|
|
5
|
+
className?: string;
|
|
6
|
+
icon?: React.ReactNode;
|
|
7
|
+
label?: string;
|
|
8
|
+
ariaLabel?: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
onToggle?: (active: boolean) => void;
|
|
11
|
+
};
|
|
12
|
+
declare function ToggleContrast({ className, icon, label, ariaLabel, title, onToggle, }: ToggleContrastProps): react_jsx_runtime.JSX.Element;
|
|
13
|
+
|
|
14
|
+
type Props = React.HTMLAttributes<HTMLDivElement>;
|
|
15
|
+
declare function ContrastBorder({ children, className, ...rest }: Props): react_jsx_runtime.JSX.Element;
|
|
16
|
+
|
|
17
|
+
declare function registerContrastBorder(): void;
|
|
18
|
+
|
|
19
|
+
export { ContrastBorder, ToggleContrast, registerContrastBorder };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
type ToggleContrastProps = {
|
|
5
|
+
className?: string;
|
|
6
|
+
icon?: React.ReactNode;
|
|
7
|
+
label?: string;
|
|
8
|
+
ariaLabel?: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
onToggle?: (active: boolean) => void;
|
|
11
|
+
};
|
|
12
|
+
declare function ToggleContrast({ className, icon, label, ariaLabel, title, onToggle, }: ToggleContrastProps): react_jsx_runtime.JSX.Element;
|
|
13
|
+
|
|
14
|
+
type Props = React.HTMLAttributes<HTMLDivElement>;
|
|
15
|
+
declare function ContrastBorder({ children, className, ...rest }: Props): react_jsx_runtime.JSX.Element;
|
|
16
|
+
|
|
17
|
+
declare function registerContrastBorder(): void;
|
|
18
|
+
|
|
19
|
+
export { ContrastBorder, ToggleContrast, registerContrastBorder };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// src/ToggleContrast.tsx
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
function ToggleContrast({
|
|
5
|
+
className,
|
|
6
|
+
icon,
|
|
7
|
+
label,
|
|
8
|
+
ariaLabel = "Ativar/Desativar alto contraste",
|
|
9
|
+
title = "Alto contraste",
|
|
10
|
+
onToggle
|
|
11
|
+
}) {
|
|
12
|
+
const [isActive, setIsActive] = React.useState(false);
|
|
13
|
+
const apply = React.useCallback(
|
|
14
|
+
(active) => {
|
|
15
|
+
const body = document.body;
|
|
16
|
+
if (active) {
|
|
17
|
+
body.classList.add("contrast");
|
|
18
|
+
localStorage.setItem("contrast", "contrast");
|
|
19
|
+
} else {
|
|
20
|
+
body.classList.remove("contrast");
|
|
21
|
+
localStorage.removeItem("contrast");
|
|
22
|
+
}
|
|
23
|
+
setIsActive(active);
|
|
24
|
+
onToggle?.(active);
|
|
25
|
+
},
|
|
26
|
+
[onToggle]
|
|
27
|
+
);
|
|
28
|
+
const toggle = React.useCallback(() => {
|
|
29
|
+
apply(!isActive);
|
|
30
|
+
}, [apply, isActive]);
|
|
31
|
+
React.useEffect(() => {
|
|
32
|
+
const saved = typeof window !== "undefined" ? localStorage.getItem("contrast") : null;
|
|
33
|
+
if (saved === "contrast") {
|
|
34
|
+
apply(true);
|
|
35
|
+
}
|
|
36
|
+
}, [apply]);
|
|
37
|
+
return /* @__PURE__ */ jsxs(
|
|
38
|
+
"button",
|
|
39
|
+
{
|
|
40
|
+
type: "button",
|
|
41
|
+
onClick: toggle,
|
|
42
|
+
className: className ?? "",
|
|
43
|
+
"aria-label": label ? void 0 : ariaLabel,
|
|
44
|
+
"aria-pressed": isActive,
|
|
45
|
+
title: label ? void 0 : title,
|
|
46
|
+
children: [
|
|
47
|
+
icon,
|
|
48
|
+
label ? /* @__PURE__ */ jsx("span", { children: label }) : null
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/ContrastBorder.tsx
|
|
55
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
56
|
+
function ContrastBorder({ children, className = "", ...rest }) {
|
|
57
|
+
return /* @__PURE__ */ jsx2("div", { className: `card ${className}`, ...rest, children });
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// src/registerContrastBorder.ts
|
|
61
|
+
function registerContrastBorder() {
|
|
62
|
+
if (typeof window === "undefined") return;
|
|
63
|
+
if (customElements.get("contrast-border")) return;
|
|
64
|
+
class ContrastBorderElement extends HTMLElement {
|
|
65
|
+
constructor() {
|
|
66
|
+
super();
|
|
67
|
+
const shadow = this.attachShadow({ mode: "open" });
|
|
68
|
+
const wrapper = document.createElement("div");
|
|
69
|
+
wrapper.setAttribute("class", "card");
|
|
70
|
+
wrapper.innerHTML = `<slot></slot>`;
|
|
71
|
+
const style = document.createElement("style");
|
|
72
|
+
style.textContent = `
|
|
73
|
+
:host {
|
|
74
|
+
display: block;
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
shadow.appendChild(style);
|
|
78
|
+
shadow.appendChild(wrapper);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
customElements.define("contrast-border", ContrastBorderElement);
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
ContrastBorder,
|
|
85
|
+
ToggleContrast,
|
|
86
|
+
registerContrastBorder
|
|
87
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "plura-assistent",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean --external react --external react-dom --external react/jsx-runtime"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [],
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@types/react": "^19.1.16",
|
|
15
|
+
"@types/react-dom": "^19.1.9",
|
|
16
|
+
"react": "^19.1.1",
|
|
17
|
+
"react-dom": "^19.1.1",
|
|
18
|
+
"tsup": "^8.5.0",
|
|
19
|
+
"typescript": "^5.9.3"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"react": ">=18",
|
|
23
|
+
"react-dom": ">=18"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
type Props = React.HTMLAttributes<HTMLDivElement>;
|
|
4
|
+
|
|
5
|
+
export function ContrastBorder({ children, className = "", ...rest }: Props) {
|
|
6
|
+
return (
|
|
7
|
+
<div className={`card ${className}`} {...rest}>
|
|
8
|
+
{children}
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
export type ToggleContrastProps = {
|
|
4
|
+
className?: string;
|
|
5
|
+
icon?: React.ReactNode;
|
|
6
|
+
label?: string;
|
|
7
|
+
ariaLabel?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
onToggle?: (active: boolean) => void;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function ToggleContrast({
|
|
13
|
+
className,
|
|
14
|
+
icon,
|
|
15
|
+
label,
|
|
16
|
+
ariaLabel = "Ativar/Desativar alto contraste",
|
|
17
|
+
title = "Alto contraste",
|
|
18
|
+
onToggle,
|
|
19
|
+
}: ToggleContrastProps) {
|
|
20
|
+
const [isActive, setIsActive] = React.useState(false);
|
|
21
|
+
|
|
22
|
+
const apply = React.useCallback(
|
|
23
|
+
(active: boolean) => {
|
|
24
|
+
const body = document.body;
|
|
25
|
+
if (active) {
|
|
26
|
+
body.classList.add("contrast");
|
|
27
|
+
localStorage.setItem("contrast", "contrast");
|
|
28
|
+
} else {
|
|
29
|
+
body.classList.remove("contrast");
|
|
30
|
+
localStorage.removeItem("contrast");
|
|
31
|
+
}
|
|
32
|
+
setIsActive(active);
|
|
33
|
+
onToggle?.(active);
|
|
34
|
+
},
|
|
35
|
+
[onToggle]
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const toggle = React.useCallback(() => {
|
|
39
|
+
apply(!isActive);
|
|
40
|
+
}, [apply, isActive]);
|
|
41
|
+
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
const saved = typeof window !== "undefined" ? localStorage.getItem("contrast") : null;
|
|
44
|
+
if (saved === "contrast") {
|
|
45
|
+
apply(true);
|
|
46
|
+
}
|
|
47
|
+
}, [apply]);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<button
|
|
51
|
+
type="button"
|
|
52
|
+
onClick={toggle}
|
|
53
|
+
className={className ?? ""}
|
|
54
|
+
aria-label={label ? undefined : ariaLabel}
|
|
55
|
+
aria-pressed={isActive}
|
|
56
|
+
title={label ? undefined : title}
|
|
57
|
+
>
|
|
58
|
+
{icon}
|
|
59
|
+
{label ? <span>{label}</span> : null}
|
|
60
|
+
</button>
|
|
61
|
+
);
|
|
62
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function registerContrastBorder() {
|
|
2
|
+
if (typeof window === "undefined") return;
|
|
3
|
+
if (customElements.get("contrast-border")) return;
|
|
4
|
+
|
|
5
|
+
class ContrastBorderElement extends HTMLElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
const shadow = this.attachShadow({ mode: "open" });
|
|
9
|
+
|
|
10
|
+
const wrapper = document.createElement("div");
|
|
11
|
+
wrapper.setAttribute("class", "card"); // mantém compatível com seu CSS existente
|
|
12
|
+
wrapper.innerHTML = `<slot></slot>`;
|
|
13
|
+
|
|
14
|
+
const style = document.createElement("style");
|
|
15
|
+
style.textContent = `
|
|
16
|
+
:host {
|
|
17
|
+
display: block;
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
shadow.appendChild(style);
|
|
22
|
+
shadow.appendChild(wrapper);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
customElements.define("contrast-border", ContrastBorderElement);
|
|
27
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"rootDir": "./src",
|
|
4
|
+
"outDir": "./dist",
|
|
5
|
+
|
|
6
|
+
"target": "ES2020",
|
|
7
|
+
"module": "ESNext",
|
|
8
|
+
"moduleResolution": "Bundler",
|
|
9
|
+
"lib": ["DOM", "ES2020"],
|
|
10
|
+
"jsx": "react-jsx",
|
|
11
|
+
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"declarationMap": true,
|
|
14
|
+
"sourceMap": true,
|
|
15
|
+
"types": ["react"],
|
|
16
|
+
|
|
17
|
+
"strict": true,
|
|
18
|
+
"noUncheckedIndexedAccess": true,
|
|
19
|
+
"exactOptionalPropertyTypes": true,
|
|
20
|
+
"skipLibCheck": true
|
|
21
|
+
},
|
|
22
|
+
"include": ["src"],
|
|
23
|
+
"exclude": ["node_modules", "dist"]
|
|
24
|
+
}
|