@haklex/rich-renderer-banner 0.0.39 → 0.0.41
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/BannerRenderer-L8GV-X-_.js +156 -0
- package/dist/index.mjs +1 -143
- package/dist/static.mjs +5 -0
- package/package.json +4 -4
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { OctagonAlert, TriangleAlert, MessageSquareWarning, Lightbulb, Info } from "lucide-react";
|
|
3
|
+
function toPrimitive(t, r) {
|
|
4
|
+
if ("object" != typeof t || !t) return t;
|
|
5
|
+
var e = t[Symbol.toPrimitive];
|
|
6
|
+
if (void 0 !== e) {
|
|
7
|
+
var i = e.call(t, r);
|
|
8
|
+
if ("object" != typeof i) return i;
|
|
9
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
10
|
+
}
|
|
11
|
+
return ("string" === r ? String : Number)(t);
|
|
12
|
+
}
|
|
13
|
+
function toPropertyKey(t) {
|
|
14
|
+
var i = toPrimitive(t, "string");
|
|
15
|
+
return "symbol" == typeof i ? i : String(i);
|
|
16
|
+
}
|
|
17
|
+
function _defineProperty(obj, key, value) {
|
|
18
|
+
key = toPropertyKey(key);
|
|
19
|
+
if (key in obj) {
|
|
20
|
+
Object.defineProperty(obj, key, {
|
|
21
|
+
value,
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true
|
|
25
|
+
});
|
|
26
|
+
} else {
|
|
27
|
+
obj[key] = value;
|
|
28
|
+
}
|
|
29
|
+
return obj;
|
|
30
|
+
}
|
|
31
|
+
function ownKeys(e, r) {
|
|
32
|
+
var t = Object.keys(e);
|
|
33
|
+
if (Object.getOwnPropertySymbols) {
|
|
34
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
35
|
+
r && (o = o.filter(function(r2) {
|
|
36
|
+
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
37
|
+
})), t.push.apply(t, o);
|
|
38
|
+
}
|
|
39
|
+
return t;
|
|
40
|
+
}
|
|
41
|
+
function _objectSpread2(e) {
|
|
42
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
43
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
44
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
45
|
+
_defineProperty(e, r2, t[r2]);
|
|
46
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
47
|
+
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return e;
|
|
51
|
+
}
|
|
52
|
+
function mapValues(input, fn) {
|
|
53
|
+
var result = {};
|
|
54
|
+
for (var _key in input) {
|
|
55
|
+
result[_key] = fn(input[_key], _key);
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
var shouldApplyCompound = (compoundCheck, selections, defaultVariants) => {
|
|
60
|
+
for (var key of Object.keys(compoundCheck)) {
|
|
61
|
+
var _selections$key;
|
|
62
|
+
if (compoundCheck[key] !== ((_selections$key = selections[key]) !== null && _selections$key !== void 0 ? _selections$key : defaultVariants[key])) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
};
|
|
68
|
+
var createRuntimeFn = (config) => {
|
|
69
|
+
var runtimeFn = (options) => {
|
|
70
|
+
var className = config.defaultClassName;
|
|
71
|
+
var selections = _objectSpread2(_objectSpread2({}, config.defaultVariants), options);
|
|
72
|
+
for (var variantName in selections) {
|
|
73
|
+
var _selections$variantNa;
|
|
74
|
+
var variantSelection = (_selections$variantNa = selections[variantName]) !== null && _selections$variantNa !== void 0 ? _selections$variantNa : config.defaultVariants[variantName];
|
|
75
|
+
if (variantSelection != null) {
|
|
76
|
+
var selection = variantSelection;
|
|
77
|
+
if (typeof selection === "boolean") {
|
|
78
|
+
selection = selection === true ? "true" : "false";
|
|
79
|
+
}
|
|
80
|
+
var selectionClassName = (
|
|
81
|
+
// @ts-expect-error
|
|
82
|
+
config.variantClassNames[variantName][selection]
|
|
83
|
+
);
|
|
84
|
+
if (selectionClassName) {
|
|
85
|
+
className += " " + selectionClassName;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
for (var [compoundCheck, compoundClassName] of config.compoundVariants) {
|
|
90
|
+
if (shouldApplyCompound(compoundCheck, selections, config.defaultVariants)) {
|
|
91
|
+
className += " " + compoundClassName;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return className;
|
|
95
|
+
};
|
|
96
|
+
runtimeFn.variants = () => Object.keys(config.variantClassNames);
|
|
97
|
+
runtimeFn.classNames = {
|
|
98
|
+
get base() {
|
|
99
|
+
return config.defaultClassName.split(" ")[0];
|
|
100
|
+
},
|
|
101
|
+
get variants() {
|
|
102
|
+
return mapValues(config.variantClassNames, (classNames) => mapValues(classNames, (className) => className.split(" ")[0]));
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
return runtimeFn;
|
|
106
|
+
};
|
|
107
|
+
var semanticClassNames = { icon: "rich-banner-icon" };
|
|
108
|
+
var semanticTypeClassNames = { icon: { note: "rich-banner-icon-note", tip: "rich-banner-icon-tip", important: "rich-banner-icon-important", warning: "rich-banner-icon-warning", caution: "rich-banner-icon-caution" } };
|
|
109
|
+
var bannerIcon = "_1gu0svs2";
|
|
110
|
+
createRuntimeFn({ defaultClassName: "_1gu0svs5", variantClassNames: { type: { note: "_1gu0svs6", tip: "_1gu0svs7", important: "_1gu0svs8", warning: "_1gu0svs9", caution: "_1gu0svsa" } }, defaultVariants: {}, compoundVariants: [] });
|
|
111
|
+
var bannerIconType = createRuntimeFn({ defaultClassName: "_1gu0svsb", variantClassNames: { type: { note: "_1gu0svsc", tip: "_1gu0svsd", important: "_1gu0svse", warning: "_1gu0svsf", caution: "_1gu0svsg" } }, defaultVariants: {}, compoundVariants: [] });
|
|
112
|
+
var bannerTrigger = "_1gu0svsh";
|
|
113
|
+
var bannerMenuIcon = "_1gu0svsi";
|
|
114
|
+
const BANNER_ICONS = {
|
|
115
|
+
note: Info,
|
|
116
|
+
tip: Lightbulb,
|
|
117
|
+
important: MessageSquareWarning,
|
|
118
|
+
warning: TriangleAlert,
|
|
119
|
+
caution: OctagonAlert
|
|
120
|
+
};
|
|
121
|
+
const BANNER_LABELS = {
|
|
122
|
+
note: "Note",
|
|
123
|
+
tip: "Tip",
|
|
124
|
+
important: "Important",
|
|
125
|
+
warning: "Warning",
|
|
126
|
+
caution: "Caution"
|
|
127
|
+
};
|
|
128
|
+
const ALL_TYPES = [
|
|
129
|
+
"note",
|
|
130
|
+
"tip",
|
|
131
|
+
"important",
|
|
132
|
+
"warning",
|
|
133
|
+
"caution"
|
|
134
|
+
];
|
|
135
|
+
const BannerRenderer = ({ type }) => {
|
|
136
|
+
const Icon = BANNER_ICONS[type];
|
|
137
|
+
return /* @__PURE__ */ jsx(
|
|
138
|
+
"span",
|
|
139
|
+
{
|
|
140
|
+
className: `${bannerIcon} ${bannerIconType({ type })} ${semanticClassNames.icon} ${semanticTypeClassNames.icon[type]}`,
|
|
141
|
+
children: /* @__PURE__ */ jsx(Icon, { width: "1em", height: "1em" })
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
};
|
|
145
|
+
export {
|
|
146
|
+
ALL_TYPES as A,
|
|
147
|
+
BannerRenderer as B,
|
|
148
|
+
bannerIcon as a,
|
|
149
|
+
bannerTrigger as b,
|
|
150
|
+
semanticTypeClassNames as c,
|
|
151
|
+
BANNER_ICONS as d,
|
|
152
|
+
bannerIconType as e,
|
|
153
|
+
bannerMenuIcon as f,
|
|
154
|
+
BANNER_LABELS as g,
|
|
155
|
+
semanticClassNames as s
|
|
156
|
+
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,148 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from "@haklex/rich-editor-ui";
|
|
3
|
-
import {
|
|
4
|
-
function toPrimitive(t, r) {
|
|
5
|
-
if ("object" != typeof t || !t) return t;
|
|
6
|
-
var e = t[Symbol.toPrimitive];
|
|
7
|
-
if (void 0 !== e) {
|
|
8
|
-
var i = e.call(t, r);
|
|
9
|
-
if ("object" != typeof i) return i;
|
|
10
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
11
|
-
}
|
|
12
|
-
return ("string" === r ? String : Number)(t);
|
|
13
|
-
}
|
|
14
|
-
function toPropertyKey(t) {
|
|
15
|
-
var i = toPrimitive(t, "string");
|
|
16
|
-
return "symbol" == typeof i ? i : String(i);
|
|
17
|
-
}
|
|
18
|
-
function _defineProperty(obj, key, value) {
|
|
19
|
-
key = toPropertyKey(key);
|
|
20
|
-
if (key in obj) {
|
|
21
|
-
Object.defineProperty(obj, key, {
|
|
22
|
-
value,
|
|
23
|
-
enumerable: true,
|
|
24
|
-
configurable: true,
|
|
25
|
-
writable: true
|
|
26
|
-
});
|
|
27
|
-
} else {
|
|
28
|
-
obj[key] = value;
|
|
29
|
-
}
|
|
30
|
-
return obj;
|
|
31
|
-
}
|
|
32
|
-
function ownKeys(e, r) {
|
|
33
|
-
var t = Object.keys(e);
|
|
34
|
-
if (Object.getOwnPropertySymbols) {
|
|
35
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
36
|
-
r && (o = o.filter(function(r2) {
|
|
37
|
-
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
38
|
-
})), t.push.apply(t, o);
|
|
39
|
-
}
|
|
40
|
-
return t;
|
|
41
|
-
}
|
|
42
|
-
function _objectSpread2(e) {
|
|
43
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
44
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
45
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
46
|
-
_defineProperty(e, r2, t[r2]);
|
|
47
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
48
|
-
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return e;
|
|
52
|
-
}
|
|
53
|
-
function mapValues(input, fn) {
|
|
54
|
-
var result = {};
|
|
55
|
-
for (var _key in input) {
|
|
56
|
-
result[_key] = fn(input[_key], _key);
|
|
57
|
-
}
|
|
58
|
-
return result;
|
|
59
|
-
}
|
|
60
|
-
var shouldApplyCompound = (compoundCheck, selections, defaultVariants) => {
|
|
61
|
-
for (var key of Object.keys(compoundCheck)) {
|
|
62
|
-
var _selections$key;
|
|
63
|
-
if (compoundCheck[key] !== ((_selections$key = selections[key]) !== null && _selections$key !== void 0 ? _selections$key : defaultVariants[key])) {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return true;
|
|
68
|
-
};
|
|
69
|
-
var createRuntimeFn = (config) => {
|
|
70
|
-
var runtimeFn = (options) => {
|
|
71
|
-
var className = config.defaultClassName;
|
|
72
|
-
var selections = _objectSpread2(_objectSpread2({}, config.defaultVariants), options);
|
|
73
|
-
for (var variantName in selections) {
|
|
74
|
-
var _selections$variantNa;
|
|
75
|
-
var variantSelection = (_selections$variantNa = selections[variantName]) !== null && _selections$variantNa !== void 0 ? _selections$variantNa : config.defaultVariants[variantName];
|
|
76
|
-
if (variantSelection != null) {
|
|
77
|
-
var selection = variantSelection;
|
|
78
|
-
if (typeof selection === "boolean") {
|
|
79
|
-
selection = selection === true ? "true" : "false";
|
|
80
|
-
}
|
|
81
|
-
var selectionClassName = (
|
|
82
|
-
// @ts-expect-error
|
|
83
|
-
config.variantClassNames[variantName][selection]
|
|
84
|
-
);
|
|
85
|
-
if (selectionClassName) {
|
|
86
|
-
className += " " + selectionClassName;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
for (var [compoundCheck, compoundClassName] of config.compoundVariants) {
|
|
91
|
-
if (shouldApplyCompound(compoundCheck, selections, config.defaultVariants)) {
|
|
92
|
-
className += " " + compoundClassName;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return className;
|
|
96
|
-
};
|
|
97
|
-
runtimeFn.variants = () => Object.keys(config.variantClassNames);
|
|
98
|
-
runtimeFn.classNames = {
|
|
99
|
-
get base() {
|
|
100
|
-
return config.defaultClassName.split(" ")[0];
|
|
101
|
-
},
|
|
102
|
-
get variants() {
|
|
103
|
-
return mapValues(config.variantClassNames, (classNames) => mapValues(classNames, (className) => className.split(" ")[0]));
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
return runtimeFn;
|
|
107
|
-
};
|
|
108
|
-
var semanticClassNames = { icon: "rich-banner-icon" };
|
|
109
|
-
var semanticTypeClassNames = { icon: { note: "rich-banner-icon-note", tip: "rich-banner-icon-tip", important: "rich-banner-icon-important", warning: "rich-banner-icon-warning", caution: "rich-banner-icon-caution" } };
|
|
110
|
-
var bannerIcon = "_1gu0svs2";
|
|
111
|
-
createRuntimeFn({ defaultClassName: "_1gu0svs5", variantClassNames: { type: { note: "_1gu0svs6", tip: "_1gu0svs7", important: "_1gu0svs8", warning: "_1gu0svs9", caution: "_1gu0svsa" } }, defaultVariants: {}, compoundVariants: [] });
|
|
112
|
-
var bannerIconType = createRuntimeFn({ defaultClassName: "_1gu0svsb", variantClassNames: { type: { note: "_1gu0svsc", tip: "_1gu0svsd", important: "_1gu0svse", warning: "_1gu0svsf", caution: "_1gu0svsg" } }, defaultVariants: {}, compoundVariants: [] });
|
|
113
|
-
var bannerTrigger = "_1gu0svsh";
|
|
114
|
-
var bannerMenuIcon = "_1gu0svsi";
|
|
115
|
-
const BANNER_ICONS = {
|
|
116
|
-
note: Info,
|
|
117
|
-
tip: Lightbulb,
|
|
118
|
-
important: MessageSquareWarning,
|
|
119
|
-
warning: TriangleAlert,
|
|
120
|
-
caution: OctagonAlert
|
|
121
|
-
};
|
|
122
|
-
const BANNER_LABELS = {
|
|
123
|
-
note: "Note",
|
|
124
|
-
tip: "Tip",
|
|
125
|
-
important: "Important",
|
|
126
|
-
warning: "Warning",
|
|
127
|
-
caution: "Caution"
|
|
128
|
-
};
|
|
129
|
-
const ALL_TYPES = [
|
|
130
|
-
"note",
|
|
131
|
-
"tip",
|
|
132
|
-
"important",
|
|
133
|
-
"warning",
|
|
134
|
-
"caution"
|
|
135
|
-
];
|
|
136
|
-
const BannerRenderer = ({ type }) => {
|
|
137
|
-
const Icon = BANNER_ICONS[type];
|
|
138
|
-
return /* @__PURE__ */ jsx(
|
|
139
|
-
"span",
|
|
140
|
-
{
|
|
141
|
-
className: `${bannerIcon} ${bannerIconType({ type })} ${semanticClassNames.icon} ${semanticTypeClassNames.icon[type]}`,
|
|
142
|
-
children: /* @__PURE__ */ jsx(Icon, { width: "1em", height: "1em" })
|
|
143
|
-
}
|
|
144
|
-
);
|
|
145
|
-
};
|
|
3
|
+
import { B as BannerRenderer, b as bannerTrigger, a as bannerIcon, s as semanticClassNames, c as semanticTypeClassNames, d as BANNER_ICONS, e as bannerIconType, A as ALL_TYPES, f as bannerMenuIcon, g as BANNER_LABELS } from "./BannerRenderer-L8GV-X-_.js";
|
|
146
4
|
const BannerEditRenderer = ({
|
|
147
5
|
type,
|
|
148
6
|
editable,
|
package/dist/static.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haklex/rich-renderer-banner",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.41",
|
|
4
4
|
"description": "Banner renderer for haklex rich editor",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"lucide-react": "^0.574.0",
|
|
24
|
-
"@haklex/rich-editor": "0.0.
|
|
25
|
-
"@haklex/rich-
|
|
26
|
-
"@haklex/rich-
|
|
24
|
+
"@haklex/rich-editor": "0.0.41",
|
|
25
|
+
"@haklex/rich-style-token": "0.0.41",
|
|
26
|
+
"@haklex/rich-editor-ui": "0.0.41"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/react": "^19.2.14",
|