ncore-ui-kit 1.1.0-alpha.0 → 1.1.0-alpha.2
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/lib/module/components/codeViewer/index.js +1 -1
- package/lib/module/components/codeViewer/index.js.map +1 -1
- package/lib/module/components/codeViewer/parser.js +30 -3
- package/lib/module/components/codeViewer/parser.js.map +1 -1
- package/lib/module/components/localeSwitcher/index.js +2 -2
- package/lib/module/components/localeSwitcher/index.js.map +1 -1
- package/lib/module/components/paletteSwitcher/index.js +3 -3
- package/lib/module/components/paletteSwitcher/index.js.map +1 -1
- package/lib/module/components/themeSwitcher/index.js +2 -2
- package/lib/module/components/themeSwitcher/index.js.map +1 -1
- package/lib/module/package.json +1 -1
- package/lib/package.json +1 -1
- package/lib/src/components/codeViewer/index.js +4 -1
- package/lib/src/components/codeViewer/parser.js +31 -3
- package/lib/src/components/localeSwitcher/index.js +2 -2
- package/lib/src/components/paletteSwitcher/index.js +3 -3
- package/lib/src/components/themeSwitcher/index.js +2 -2
- package/lib/tsconfig.build.tsbuildinfo +1 -1
- package/lib/typescript/package.json +1 -1
- package/lib/typescript/src/components/codeViewer/index.d.ts.map +1 -1
- package/lib/typescript/src/components/codeViewer/parser.d.ts.map +1 -1
- package/lib/typescript/src/components/localeSwitcher/index.d.ts.map +1 -1
- package/lib/typescript/src/components/paletteSwitcher/index.d.ts.map +1 -1
- package/lib/typescript/src/components/themeSwitcher/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/codeViewer/index.tsx +5 -2
- package/src/components/codeViewer/parser.ts +33 -3
- package/src/components/localeSwitcher/index.tsx +5 -3
- package/src/components/paletteSwitcher/index.tsx +6 -4
- package/src/components/themeSwitcher/index.tsx +5 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/codeViewer/index.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,gBAAgB,MAAM,QAAQ,CAAC;AAwB3C,QAAA,MAAM,UAAU,GAAI,oBAGjB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/codeViewer/index.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,gBAAgB,MAAM,QAAQ,CAAC;AAwB3C,QAAA,MAAM,UAAU,GAAI,oBAGjB,gBAAgB,4CA0NlB,CAAC;AACF,eAAe,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../../../src/components/codeViewer/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAER,KAAK,EACR,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../../../src/components/codeViewer/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAER,KAAK,EACR,MAAM,QAAQ,CAAC;AAimBhB,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,EAAE,WAAW,MAAM,KAAG,KAAK,EAsChE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/localeSwitcher/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,EAAE,EACV,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,oBAAoB,MAAM,QAAQ,CAAC;AAiB/C,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/localeSwitcher/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,EAAE,EACV,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,oBAAoB,MAAM,QAAQ,CAAC;AAiB/C,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,oBAAoB,CA8I5C,CAAC;AACF,eAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/paletteSwitcher/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,EAAE,EACV,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,qBAAqB,MAAM,QAAQ,CAAC;AAkBhD,QAAA,MAAM,eAAe,EAAE,EAAE,CAAC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/paletteSwitcher/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,EAAE,EACV,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,qBAAqB,MAAM,QAAQ,CAAC;AAkBhD,QAAA,MAAM,eAAe,EAAE,EAAE,CAAC,qBAAqB,CA+J9C,CAAC;AACF,eAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/themeSwitcher/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,EAAE,EACV,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,mBAAmB,MAAM,QAAQ,CAAC;AAiB9C,QAAA,MAAM,aAAa,EAAE,EAAE,CAAC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/themeSwitcher/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,EAAE,EACV,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,mBAAmB,MAAM,QAAQ,CAAC;AAiB9C,QAAA,MAAM,aAAa,EAAE,EAAE,CAAC,mBAAmB,CAyJ1C,CAAC;AACF,eAAe,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -55,7 +55,7 @@ const CodeViewer = ({
|
|
|
55
55
|
|
|
56
56
|
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
57
57
|
|
|
58
|
-
const containerRef = useRef<import("react").
|
|
58
|
+
const containerRef = useRef<import("react").ComponentRef<typeof View>>(null);
|
|
59
59
|
|
|
60
60
|
const [
|
|
61
61
|
stickyTop,
|
|
@@ -133,7 +133,10 @@ const CodeViewer = ({
|
|
|
133
133
|
const handleCopyCode = async () => {
|
|
134
134
|
if (isCopied) return;
|
|
135
135
|
|
|
136
|
-
const replacedCode =
|
|
136
|
+
const replacedCode = tokens
|
|
137
|
+
.filter(token => token.type !== "comment")
|
|
138
|
+
.map(token => token.value)
|
|
139
|
+
.join("");
|
|
137
140
|
|
|
138
141
|
let isSuccess = false;
|
|
139
142
|
|
|
@@ -555,12 +555,42 @@ const getTokenRegex = (language?: string): RegExp => {
|
|
|
555
555
|
}
|
|
556
556
|
}
|
|
557
557
|
|
|
558
|
-
const keywordsRegexStr = "\\b(?:" + keywordList.join("|") + ")\\b";
|
|
558
|
+
const keywordsRegexStr = "(?<!\\.)\\b(?:" + keywordList.join("|") + ")\\b";
|
|
559
559
|
|
|
560
|
-
const keywordControlRegexStr = "\\b(?:return|if|else|for|while|try|catch|finally|switch|case|break|continue|throw|yield)\\b";
|
|
560
|
+
const keywordControlRegexStr = "(?<!\\.)\\b(?:return|if|else|for|while|try|catch|finally|switch|case|break|continue|throw|yield)\\b";
|
|
561
561
|
|
|
562
|
-
|
|
562
|
+
let commentRegexStr = "//.*|/\\*[\\s\\S]*?\\*/|#.*|<!--[\\s\\S]*?-->";
|
|
563
|
+
if (language) {
|
|
564
|
+
switch (language.toLowerCase()) {
|
|
565
|
+
case "bash":
|
|
566
|
+
case "python":
|
|
567
|
+
commentRegexStr = "#.*";
|
|
568
|
+
break;
|
|
569
|
+
case "sql":
|
|
570
|
+
commentRegexStr = "--.*|/\\*[\\s\\S]*?\\*/";
|
|
571
|
+
break;
|
|
572
|
+
case "html":
|
|
573
|
+
case "xml":
|
|
574
|
+
commentRegexStr = "<!--[\\s\\S]*?-->";
|
|
575
|
+
break;
|
|
576
|
+
case "javascript":
|
|
577
|
+
case "typescript":
|
|
578
|
+
case "jsx":
|
|
579
|
+
case "tsx":
|
|
580
|
+
case "csharp":
|
|
581
|
+
commentRegexStr = "//.*|/\\*[\\s\\S]*?\\*/";
|
|
582
|
+
break;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
let bashTextRegexStr = "";
|
|
587
|
+
if (language && language.toLowerCase() === "bash") {
|
|
588
|
+
bashTextRegexStr = "(?<text>(?:[a-zA-Z0-9_@]+[.:/-]+)+[a-zA-Z0-9_@]+)|";
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
const regexStr = "(?<comment>" + commentRegexStr + ")|" +
|
|
563
592
|
'(?<string>(["\\\'`])(?:(?=(\\\\?))\\4.)*?\\3)|' +
|
|
593
|
+
bashTextRegexStr +
|
|
564
594
|
"(?<keywordControl>" + keywordControlRegexStr + ")|" +
|
|
565
595
|
"(?<keyword>" + keywordsRegexStr + ")|" +
|
|
566
596
|
"(?<htmlTag>(?<=<\\/?)[a-z][a-zA-Z0-9-]*\\b)|" +
|
|
@@ -51,15 +51,17 @@ const LocaleSwitcher: FC<ILocaleSwitcherProps> = ({
|
|
|
51
51
|
activeLocale
|
|
52
52
|
]);
|
|
53
53
|
|
|
54
|
-
const variantsPre: LocaleSwitchVariants
|
|
54
|
+
const variantsPre: Array<Omit<LocaleSwitchVariants[0], "backgroundColor"> & {
|
|
55
|
+
backgroundColor?: LocaleSwitchVariants[0]["backgroundColor"]
|
|
56
|
+
}> = variantsProps;
|
|
55
57
|
|
|
56
58
|
const isHaveNCTRTR = variantsProps.findIndex(iV => iV.localeKey === "tr-TR") !== -1;
|
|
57
59
|
const isHaveNCENUS = variantsProps.findIndex(iV => iV.localeKey === "en-US") !== -1;
|
|
58
60
|
|
|
59
61
|
if(!isHaveNCTRTR) {
|
|
60
62
|
variantsPre.unshift({
|
|
63
|
+
backgroundColor: isWorkWithHighlightButton ? undefined : "subtle",
|
|
61
64
|
borderColor: "transparent",
|
|
62
|
-
backgroundColor: "subtle",
|
|
63
65
|
iconColor: "turkish",
|
|
64
66
|
localeKey: "tr-TR",
|
|
65
67
|
icon: ({
|
|
@@ -74,8 +76,8 @@ const LocaleSwitcher: FC<ILocaleSwitcherProps> = ({
|
|
|
74
76
|
|
|
75
77
|
if(!isHaveNCENUS) {
|
|
76
78
|
variantsPre.unshift({
|
|
79
|
+
backgroundColor: isWorkWithHighlightButton ? undefined : "subtle",
|
|
77
80
|
borderColor: "transparent",
|
|
78
|
-
backgroundColor: "subtle",
|
|
79
81
|
iconColor: "english",
|
|
80
82
|
localeKey: "en-US",
|
|
81
83
|
icon: ({
|
|
@@ -52,7 +52,9 @@ const PaletteSwitcher: FC<IPaletteSwitcherProps> = ({
|
|
|
52
52
|
activePalette
|
|
53
53
|
]);
|
|
54
54
|
|
|
55
|
-
const variantsPre: ThemeSwitchVariants
|
|
55
|
+
const variantsPre: Array<Omit<ThemeSwitchVariants[0], "backgroundColor"> & {
|
|
56
|
+
backgroundColor?: ThemeSwitchVariants[0]["backgroundColor"]
|
|
57
|
+
}> = variantsProps;
|
|
56
58
|
|
|
57
59
|
const isHaveNC = variantsProps.findIndex(iV => iV.paletteKey === "nibgat-community") !== -1;
|
|
58
60
|
const isHaveCC = variantsProps.findIndex(iV => iV.paletteKey === "caycore") !== -1;
|
|
@@ -60,8 +62,8 @@ const PaletteSwitcher: FC<IPaletteSwitcherProps> = ({
|
|
|
60
62
|
|
|
61
63
|
if(!isHaveN) {
|
|
62
64
|
variantsPre.unshift({
|
|
65
|
+
backgroundColor: isWorkWithHighlightButton ? undefined : "subtle",
|
|
63
66
|
borderColor: "transparent",
|
|
64
|
-
backgroundColor: "subtle",
|
|
65
67
|
paletteKey: "nibgat",
|
|
66
68
|
iconColor: "moon",
|
|
67
69
|
icon: ({
|
|
@@ -76,9 +78,9 @@ const PaletteSwitcher: FC<IPaletteSwitcherProps> = ({
|
|
|
76
78
|
|
|
77
79
|
if(!isHaveNC) {
|
|
78
80
|
variantsPre.unshift({
|
|
81
|
+
backgroundColor: isWorkWithHighlightButton ? undefined : "subtle",
|
|
79
82
|
paletteKey: "nibgat-community",
|
|
80
83
|
borderColor: "transparent",
|
|
81
|
-
backgroundColor: "subtle",
|
|
82
84
|
iconColor: "moon",
|
|
83
85
|
icon: ({
|
|
84
86
|
size
|
|
@@ -92,8 +94,8 @@ const PaletteSwitcher: FC<IPaletteSwitcherProps> = ({
|
|
|
92
94
|
|
|
93
95
|
if(!isHaveCC) {
|
|
94
96
|
variantsPre.unshift({
|
|
97
|
+
backgroundColor: isWorkWithHighlightButton ? undefined : "subtle",
|
|
95
98
|
borderColor: "transparent",
|
|
96
|
-
backgroundColor: "subtle",
|
|
97
99
|
paletteKey: "caycore",
|
|
98
100
|
iconColor: "moon",
|
|
99
101
|
icon: ({
|
|
@@ -52,15 +52,17 @@ const ThemeSwitcher: FC<IThemeSwitcherProps> = ({
|
|
|
52
52
|
activeTheme
|
|
53
53
|
]);
|
|
54
54
|
|
|
55
|
-
const variantsPre: ThemeSwitchVariants
|
|
55
|
+
const variantsPre: Array<Omit<ThemeSwitchVariants[0], "backgroundColor"> & {
|
|
56
|
+
backgroundColor?: ThemeSwitchVariants[0]["backgroundColor"]
|
|
57
|
+
}> = variantsProps;
|
|
56
58
|
|
|
57
59
|
const isHaveLight = variantsProps.findIndex(iV => iV.themeKey === "light") !== -1;
|
|
58
60
|
const isHaveDark = variantsProps.findIndex(iV => iV.themeKey === "dark") !== -1;
|
|
59
61
|
|
|
60
62
|
if(!isHaveDark) {
|
|
61
63
|
variantsPre.unshift({
|
|
64
|
+
backgroundColor: isWorkWithHighlightButton ? undefined : "subtle",
|
|
62
65
|
borderColor: "transparent",
|
|
63
|
-
backgroundColor: "subtle",
|
|
64
66
|
iconColor: "moon",
|
|
65
67
|
themeKey: "dark",
|
|
66
68
|
icon: ({
|
|
@@ -80,8 +82,8 @@ const ThemeSwitcher: FC<IThemeSwitcherProps> = ({
|
|
|
80
82
|
|
|
81
83
|
if(!isHaveLight) {
|
|
82
84
|
variantsPre.unshift({
|
|
85
|
+
backgroundColor: isWorkWithHighlightButton ? undefined : "subtle",
|
|
83
86
|
borderColor: "transparent",
|
|
84
|
-
backgroundColor: "subtle",
|
|
85
87
|
themeKey: "light",
|
|
86
88
|
iconColor: "sun",
|
|
87
89
|
icon: ({
|