fictoan-react 1.2.3 → 1.2.4
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 +1 @@
|
|
|
1
|
-
"use strict";Object.create,Object.defineProperty,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.prototype.hasOwnProperty;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("../Element/Element.cjs"),r=require("../Button/Button.cjs"),n=require("../Badge/Badge.cjs");var o=["children","source","language","showCopyButton"];function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},a.apply(this,arguments)}function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var i=e.lazy((function(){return import("prism-react-renderer").then((function(t){return t.Highlight?{default:t.Highlight}:(console.log("FICTOAN : [35mLooking[33m for[32m syntax[34m highlighting[36m?[31m\n╭──────────────────────────────────────────────────────────────────────────────────────────────────╮\n│ Please install the prism-react-renderer (https://www.npmjs.com/package/prism-react-renderer) │\n│ package to have syntax highlighting in the CodeBlock component. │\n│ For example: [46m[30myarn add prism-react-renderer[0m[31m │\n╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"),{default:function(t){var r=t.code;return e.createElement("pre",{"data-code-block":!0,className:"module-fallback"},r)}})}))})),u=e.forwardRef((function(u,s){var p,f
|
|
1
|
+
"use strict";Object.create,Object.defineProperty,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.prototype.hasOwnProperty;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("../Element/Element.cjs"),r=require("../Button/Button.cjs"),n=require("../Badge/Badge.cjs");var o=["children","source","language","showCopyButton","showLineNumbers"];function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},a.apply(this,arguments)}function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var i=e.lazy((function(){return import("prism-react-renderer").then((function(t){return t.Highlight?{default:t.Highlight}:(console.log("FICTOAN : [35mLooking[33m for[32m syntax[34m highlighting[36m?[31m\n╭──────────────────────────────────────────────────────────────────────────────────────────────────╮\n│ Please install the prism-react-renderer (https://www.npmjs.com/package/prism-react-renderer) │\n│ package to have syntax highlighting in the CodeBlock component. │\n│ For example: [46m[30myarn add prism-react-renderer[0m[31m │\n╰──────────────────────────────────────────────────────────────────────────────────────────────────╯"),{default:function(t){var r=t.code;return e.createElement("pre",{"data-code-block":!0,className:"module-fallback"},r)}})}))})),u=e.forwardRef((function(u,s){var p,m,f=u.children,y=u.source,d=u.language,b=void 0===d?"json":d,g=u.showCopyButton,h=u.showLineNumbers,O=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(u,o),v=(p=e.useState(!1),m=2,function(e){if(Array.isArray(e))return e}(p)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,l,c=[],i=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;i=!1}else for(;!(i=(n=a.call(r)).done)&&(c.push(n.value),c.length!==t);i=!0);}catch(s){u=!0,o=s}finally{try{if(!i&&null!=r.return&&(l=r.return(),Object(l)!==l))return}finally{if(u)throw o}}return c}}(p,m)||function(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}(p,m)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),j=v[0],k=v[1],w="string"==typeof f?f:e.Children.toArray(f).join("");f||(w="object"===l(y)?JSON.stringify(y,null,2):null!=y?y:"");var E=[];return h&&E.push("show-line-numbers"),e.createElement(t.Element,a({"data-code-block":!0,as:"div",classNames:E},O),g?j?e.createElement(n.Badge,{className:"code-block-copied-badge",size:"tiny",shape:"rounded","aria-live":"polite"},"Copied!"):e.createElement(r.Button,{type:"button",className:"code-block-copy-button",size:"tiny",shape:"rounded",onClick:function(){navigator.clipboard.writeText(w).then((function(){k(!0),setTimeout((function(){return k(!1)}),3e3)})).catch((function(e){console.error("Could not copy text: ",e)}))},role:"button","aria-label":"Copy code to clipboard"},"Copy"):null,e.createElement(e.Suspense,{fallback:e.createElement("pre",{"data-code-block":!0,className:"suspense-fallback"},w)},e.createElement(i,{code:w,language:b,theme:void 0},(function(t){var r=t.className,n=t.tokens,o=t.getLineProps,a=t.getTokenProps;return e.createElement("pre",{ref:s,className:r},n.map((function(t,r){return e.createElement("div",o({line:t,key:r}),h&&e.createElement("span",{className:"line-numbers"},r+1),e.createElement("span",{className:"l-o-c"},t.map((function(t,r){return e.createElement("span",a({token:t,key:r}))}))))})))}))))}));exports.CodeBlock=u;
|
|
@@ -2,8 +2,9 @@ import React from "react";
|
|
|
2
2
|
import { CommonAndHTMLProps } from "../Element/constants";
|
|
3
3
|
export interface CodeBlockCustomProps {
|
|
4
4
|
source?: object | string;
|
|
5
|
-
language?: string;
|
|
5
|
+
language?: string | undefined;
|
|
6
6
|
showCopyButton?: boolean;
|
|
7
|
+
showLineNumbers?: boolean;
|
|
7
8
|
}
|
|
8
9
|
export type CodeBlockElementType = HTMLPreElement;
|
|
9
10
|
export type CodeBlockProps = Omit<CommonAndHTMLProps<CodeBlockElementType>, keyof CodeBlockCustomProps> & CodeBlockCustomProps;
|
|
@@ -2,19 +2,19 @@ import e, { useState as t, Suspense as r } from "react";
|
|
|
2
2
|
import { Element as n } from "../Element/Element.js";
|
|
3
3
|
import { Button as o } from "../Button/Button.js";
|
|
4
4
|
import { Badge as a } from "../Badge/Badge.js";
|
|
5
|
-
var l = ["children", "source", "language", "showCopyButton"];
|
|
6
|
-
function
|
|
7
|
-
return
|
|
5
|
+
var l = ["children", "source", "language", "showCopyButton", "showLineNumbers"];
|
|
6
|
+
function i() {
|
|
7
|
+
return i = Object.assign ? Object.assign.bind() : function(e2) {
|
|
8
8
|
for (var t2 = 1; t2 < arguments.length; t2++) {
|
|
9
9
|
var r2 = arguments[t2];
|
|
10
10
|
for (var n2 in r2)
|
|
11
11
|
Object.prototype.hasOwnProperty.call(r2, n2) && (e2[n2] = r2[n2]);
|
|
12
12
|
}
|
|
13
13
|
return e2;
|
|
14
|
-
},
|
|
14
|
+
}, i.apply(this, arguments);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
return (
|
|
16
|
+
function c(e2) {
|
|
17
|
+
return (c = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e3) {
|
|
18
18
|
return typeof e3;
|
|
19
19
|
} : function(e3) {
|
|
20
20
|
return e3 && "function" == typeof Symbol && e3.constructor === Symbol && e3 !== Symbol.prototype ? "symbol" : typeof e3;
|
|
@@ -27,50 +27,50 @@ function u(e2, t2) {
|
|
|
27
27
|
}(e2) || function(e3, t3) {
|
|
28
28
|
var r2 = null == e3 ? null : "undefined" != typeof Symbol && e3[Symbol.iterator] || e3["@@iterator"];
|
|
29
29
|
if (null != r2) {
|
|
30
|
-
var n2, o2, a2, l2,
|
|
30
|
+
var n2, o2, a2, l2, i2 = [], c2 = true, u2 = false;
|
|
31
31
|
try {
|
|
32
32
|
if (a2 = (r2 = r2.call(e3)).next, 0 === t3) {
|
|
33
33
|
if (Object(r2) !== r2)
|
|
34
34
|
return;
|
|
35
|
-
|
|
35
|
+
c2 = false;
|
|
36
36
|
} else
|
|
37
|
-
for (; !(
|
|
37
|
+
for (; !(c2 = (n2 = a2.call(r2)).done) && (i2.push(n2.value), i2.length !== t3); c2 = true)
|
|
38
38
|
;
|
|
39
39
|
} catch (e4) {
|
|
40
40
|
u2 = true, o2 = e4;
|
|
41
41
|
} finally {
|
|
42
42
|
try {
|
|
43
|
-
if (!
|
|
43
|
+
if (!c2 && null != r2.return && (l2 = r2.return(), Object(l2) !== l2))
|
|
44
44
|
return;
|
|
45
45
|
} finally {
|
|
46
46
|
if (u2)
|
|
47
47
|
throw o2;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
return
|
|
50
|
+
return i2;
|
|
51
51
|
}
|
|
52
52
|
}(e2, t2) || function(e3, t3) {
|
|
53
53
|
if (!e3)
|
|
54
54
|
return;
|
|
55
55
|
if ("string" == typeof e3)
|
|
56
|
-
return
|
|
56
|
+
return s(e3, t3);
|
|
57
57
|
var r2 = Object.prototype.toString.call(e3).slice(8, -1);
|
|
58
58
|
"Object" === r2 && e3.constructor && (r2 = e3.constructor.name);
|
|
59
59
|
if ("Map" === r2 || "Set" === r2)
|
|
60
60
|
return Array.from(e3);
|
|
61
61
|
if ("Arguments" === r2 || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r2))
|
|
62
|
-
return
|
|
62
|
+
return s(e3, t3);
|
|
63
63
|
}(e2, t2) || function() {
|
|
64
64
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
65
65
|
}();
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function s(e2, t2) {
|
|
68
68
|
(null == t2 || t2 > e2.length) && (t2 = e2.length);
|
|
69
69
|
for (var r2 = 0, n2 = new Array(t2); r2 < t2; r2++)
|
|
70
70
|
n2[r2] = e2[r2];
|
|
71
71
|
return n2;
|
|
72
72
|
}
|
|
73
|
-
function
|
|
73
|
+
function m(e2, t2) {
|
|
74
74
|
if (null == e2)
|
|
75
75
|
return {};
|
|
76
76
|
var r2, n2, o2 = function(e3, t3) {
|
|
@@ -88,7 +88,7 @@ function s(e2, t2) {
|
|
|
88
88
|
}
|
|
89
89
|
return o2;
|
|
90
90
|
}
|
|
91
|
-
var
|
|
91
|
+
var f = /* @__PURE__ */ e.lazy(function() {
|
|
92
92
|
return import("prism-react-renderer").then(function(t2) {
|
|
93
93
|
if (t2.Highlight)
|
|
94
94
|
return { default: t2.Highlight };
|
|
@@ -98,22 +98,24 @@ var m = /* @__PURE__ */ e.lazy(function() {
|
|
|
98
98
|
return e.createElement("pre", { "data-code-block": true, className: "module-fallback" }, r2);
|
|
99
99
|
} };
|
|
100
100
|
});
|
|
101
|
-
}), p = /* @__PURE__ */ e.forwardRef(function(
|
|
102
|
-
var y =
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
}), p = /* @__PURE__ */ e.forwardRef(function(s2, p2) {
|
|
102
|
+
var y = s2.children, d = s2.source, b = s2.language, h = void 0 === b ? "json" : b, g = s2.showCopyButton, v = s2.showLineNumbers, j = m(s2, l), k = u(t(false), 2), O = k[0], w = k[1], E = "string" == typeof y ? y : e.Children.toArray(y).join("");
|
|
103
|
+
y || (E = "object" === c(d) ? JSON.stringify(d, null, 2) : null != d ? d : "");
|
|
104
|
+
var N = [];
|
|
105
|
+
return v && N.push("show-line-numbers"), /* @__PURE__ */ e.createElement(n, i({ "data-code-block": true, as: "div", classNames: N }, j), g ? O ? /* @__PURE__ */ e.createElement(a, { className: "code-block-copied-badge", size: "tiny", shape: "rounded", "aria-live": "polite" }, "Copied!") : /* @__PURE__ */ e.createElement(o, { type: "button", className: "code-block-copy-button", size: "tiny", shape: "rounded", onClick: function() {
|
|
106
|
+
navigator.clipboard.writeText(E).then(function() {
|
|
107
|
+
w(true), setTimeout(function() {
|
|
108
|
+
return w(false);
|
|
107
109
|
}, 3e3);
|
|
108
110
|
}).catch(function(e2) {
|
|
109
111
|
console.error("Could not copy text: ", e2);
|
|
110
112
|
});
|
|
111
|
-
} }, "Copy") : null, /* @__PURE__ */ e.createElement(r, { fallback: /* @__PURE__ */ e.createElement("pre", { "data-code-block": true, className: "suspense-fallback" },
|
|
113
|
+
}, role: "button", "aria-label": "Copy code to clipboard" }, "Copy") : null, /* @__PURE__ */ e.createElement(r, { fallback: /* @__PURE__ */ e.createElement("pre", { "data-code-block": true, className: "suspense-fallback" }, E) }, /* @__PURE__ */ e.createElement(f, { code: E, language: h, theme: void 0 }, function(t2) {
|
|
112
114
|
var r2 = t2.className, n2 = t2.tokens, o2 = t2.getLineProps, a2 = t2.getTokenProps;
|
|
113
115
|
return e.createElement("pre", { ref: p2, className: r2 }, n2.map(function(t3, r3) {
|
|
114
|
-
return e.createElement("div", o2({ line: t3, key: r3 }), t3.map(function(t4, r4) {
|
|
116
|
+
return e.createElement("div", o2({ line: t3, key: r3 }), v && /* @__PURE__ */ e.createElement("span", { className: "line-numbers" }, r3 + 1), /* @__PURE__ */ e.createElement("span", { className: "l-o-c" }, t3.map(function(t4, r4) {
|
|
115
117
|
return e.createElement("span", a2({ token: t4, key: r4 }));
|
|
116
|
-
}));
|
|
118
|
+
})));
|
|
117
119
|
}));
|
|
118
120
|
})));
|
|
119
121
|
});
|
|
@@ -8,3 +8,9 @@ export declare const CSS: Story;
|
|
|
8
8
|
export declare const Python: Story;
|
|
9
9
|
export declare const Go: Story;
|
|
10
10
|
export declare const CSharp: Story;
|
|
11
|
+
export declare const TypeScript: Story;
|
|
12
|
+
export declare const JSON: Story;
|
|
13
|
+
export declare const Swift: Story;
|
|
14
|
+
export declare const Kotlin: Story;
|
|
15
|
+
export declare const GraphQL: Story;
|
|
16
|
+
export declare const YAML: Story;
|