react-keywords 0.0.2 → 0.0.3

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/cjs/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+ export interface KeywordsProps {
3
+ value?: string;
4
+ color?: string;
5
+ backgroundColor?: string;
6
+ render?: (keyword: string, color: string, backgroundColor: string) => JSX.Element;
7
+ }
8
+ declare const KeywordsInner: FC<PropsWithChildren<KeywordsProps>>;
9
+ export default KeywordsInner;
package/cjs/index.js ADDED
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ var _jsxRuntime = require("react/jsx-runtime");
11
+
12
+ var Highlight = function Highlight(props) {
13
+ var children = props.children,
14
+ value = props.value,
15
+ color = props.color,
16
+ backgroundColor = props.backgroundColor,
17
+ render = props.render;
18
+ var child = (0, _react.useMemo)(function () {
19
+ return render ? render(value, color, backgroundColor) : /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
20
+ style: {
21
+ color: color,
22
+ backgroundColor: backgroundColor
23
+ },
24
+ children: value
25
+ });
26
+ }, [color, backgroundColor, value]);
27
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
28
+ children: [children, value && child]
29
+ });
30
+ };
31
+
32
+ var KeywordsInner = function KeywordsInner(props) {
33
+ var children = props.children,
34
+ _props$color = props.color,
35
+ color = _props$color === void 0 ? 'inherit' : _props$color,
36
+ _props$backgroundColo = props.backgroundColor,
37
+ backgroundColor = _props$backgroundColo === void 0 ? '#ffff00' : _props$backgroundColo,
38
+ value = props.value,
39
+ render = props.render;
40
+ if (typeof children !== 'string') return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {
41
+ children: children
42
+ });
43
+ var splitMatch = new RegExp("".concat(value), 'ig');
44
+ var matched = children.split(splitMatch);
45
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {
46
+ children: matched.map(function (item, idx) {
47
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Highlight, {
48
+ color: color,
49
+ value: matched.length > idx + 1 ? value : undefined,
50
+ render: render,
51
+ backgroundColor: backgroundColor,
52
+ children: item
53
+ }, idx);
54
+ })
55
+ });
56
+ };
57
+
58
+ var _default = KeywordsInner;
59
+ exports["default"] = _default;
60
+ module.exports = exports.default;
61
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,31 @@
1
+ {
2
+ "version": 3,
3
+ "names": [
4
+ "Highlight",
5
+ "props",
6
+ "children",
7
+ "value",
8
+ "color",
9
+ "backgroundColor",
10
+ "render",
11
+ "child",
12
+ "useMemo",
13
+ "KeywordsInner",
14
+ "splitMatch",
15
+ "RegExp",
16
+ "matched",
17
+ "split",
18
+ "map",
19
+ "item",
20
+ "idx",
21
+ "length",
22
+ "undefined"
23
+ ],
24
+ "sources": [
25
+ "../src/index.tsx"
26
+ ],
27
+ "sourcesContent": [
28
+ "import { FC, Fragment, PropsWithChildren, useMemo } from 'react';\n\nexport interface KeywordsProps {\n value?: string;\n color?: string;\n backgroundColor?: string;\n render?: (keyword: string, color: string, backgroundColor: string) => JSX.Element;\n}\n\ninterface HighlightProps extends KeywordsProps {}\nconst Highlight: FC<PropsWithChildren<HighlightProps>> = (props) => {\n const { children, value, color, backgroundColor, render } = props;\n const child = useMemo(\n () => (render ? render(value!, color!, backgroundColor!) : <span style={{ color, backgroundColor }}>{value}</span>),\n [color, backgroundColor, value],\n );\n return (\n <Fragment>\n {children}\n {value && child}\n </Fragment>\n );\n};\n\nconst KeywordsInner: FC<PropsWithChildren<KeywordsProps>> = (props) => {\n const { children, color = 'inherit', backgroundColor = '#ffff00', value, render } = props;\n if (typeof children !== 'string') return <Fragment>{children}</Fragment>;\n const splitMatch = new RegExp(`${value}`, 'ig');\n const matched = children.split(splitMatch);\n return (\n <Fragment>\n {matched.map((item, idx) => {\n return (\n <Highlight\n key={idx}\n color={color}\n value={matched.length > idx + 1 ? value : undefined}\n render={render}\n backgroundColor={backgroundColor}\n >\n {item}\n </Highlight>\n );\n })}\n </Fragment>\n );\n};\n\nexport default KeywordsInner;\n"
29
+ ],
30
+ "mappings": ";;;;;;;AAAA;;;;AAUA,IAAMA,SAAgD,GAAG,SAAnDA,SAAmD,CAACC,KAAD,EAAW;EAClE,IAAQC,QAAR,GAA4DD,KAA5D,CAAQC,QAAR;EAAA,IAAkBC,KAAlB,GAA4DF,KAA5D,CAAkBE,KAAlB;EAAA,IAAyBC,KAAzB,GAA4DH,KAA5D,CAAyBG,KAAzB;EAAA,IAAgCC,eAAhC,GAA4DJ,KAA5D,CAAgCI,eAAhC;EAAA,IAAiDC,MAAjD,GAA4DL,KAA5D,CAAiDK,MAAjD;EACA,IAAMC,KAAK,GAAG,IAAAC,cAAA,EACZ;IAAA,OAAOF,MAAM,GAAGA,MAAM,CAACH,KAAD,EAASC,KAAT,EAAiBC,eAAjB,CAAT,gBAA8C;MAAM,KAAK,EAAE;QAAED,KAAK,EAALA,KAAF;QAASC,eAAe,EAAfA;MAAT,CAAb;MAAA,UAA0CF;IAA1C,EAA3D;EAAA,CADY,EAEZ,CAACC,KAAD,EAAQC,eAAR,EAAyBF,KAAzB,CAFY,CAAd;EAIA,oBACE,sBAAC,eAAD;IAAA,WACGD,QADH,EAEGC,KAAK,IAAII,KAFZ;EAAA,EADF;AAMD,CAZD;;AAcA,IAAME,aAAmD,GAAG,SAAtDA,aAAsD,CAACR,KAAD,EAAW;EACrE,IAAQC,QAAR,GAAoFD,KAApF,CAAQC,QAAR;EAAA,mBAAoFD,KAApF,CAAkBG,KAAlB;EAAA,IAAkBA,KAAlB,6BAA0B,SAA1B;EAAA,4BAAoFH,KAApF,CAAqCI,eAArC;EAAA,IAAqCA,eAArC,sCAAuD,SAAvD;EAAA,IAAkEF,KAAlE,GAAoFF,KAApF,CAAkEE,KAAlE;EAAA,IAAyEG,MAAzE,GAAoFL,KAApF,CAAyEK,MAAzE;EACA,IAAI,OAAOJ,QAAP,KAAoB,QAAxB,EAAkC,oBAAO,qBAAC,eAAD;IAAA,UAAWA;EAAX,EAAP;EAClC,IAAMQ,UAAU,GAAG,IAAIC,MAAJ,WAAcR,KAAd,GAAuB,IAAvB,CAAnB;EACA,IAAMS,OAAO,GAAGV,QAAQ,CAACW,KAAT,CAAeH,UAAf,CAAhB;EACA,oBACE,qBAAC,eAAD;IAAA,UACGE,OAAO,CAACE,GAAR,CAAY,UAACC,IAAD,EAAOC,GAAP,EAAe;MAC1B,oBACE,qBAAC,SAAD;QAEE,KAAK,EAAEZ,KAFT;QAGE,KAAK,EAAEQ,OAAO,CAACK,MAAR,GAAiBD,GAAG,GAAG,CAAvB,GAA2Bb,KAA3B,GAAmCe,SAH5C;QAIE,MAAM,EAAEZ,MAJV;QAKE,eAAe,EAAED,eALnB;QAAA,UAOGU;MAPH,GACOC,GADP,CADF;IAWD,CAZA;EADH,EADF;AAiBD,CAtBD;;eAwBeP,a"
31
+ }
@@ -0,0 +1,137 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory(require("react"));
4
+ else if(typeof define === 'function' && define.amd)
5
+ define(["react"], factory);
6
+ else if(typeof exports === 'object')
7
+ exports["react-keywords"] = factory(require("react"));
8
+ else
9
+ root["react-keywords"] = factory(root["React"]);
10
+ })(self, (__WEBPACK_EXTERNAL_MODULE__787__) => {
11
+ return /******/ (() => { // webpackBootstrap
12
+ /******/ "use strict";
13
+ /******/ var __webpack_modules__ = ({
14
+
15
+ /***/ 298:
16
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
17
+
18
+ var __webpack_unused_export__;
19
+ /**
20
+ * @license React
21
+ * react-jsx-runtime.production.min.js
22
+ *
23
+ * Copyright (c) Facebook, Inc. and its affiliates.
24
+ *
25
+ * This source code is licensed under the MIT license found in the
26
+ * LICENSE file in the root directory of this source tree.
27
+ */
28
+ var f=__webpack_require__(787),k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};
29
+ function q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=""+g);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}__webpack_unused_export__=l;exports.jsx=q;exports.jsxs=q;
30
+
31
+
32
+ /***/ }),
33
+
34
+ /***/ 605:
35
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
36
+
37
+
38
+
39
+ if (true) {
40
+ module.exports = __webpack_require__(298);
41
+ } else {}
42
+
43
+
44
+ /***/ }),
45
+
46
+ /***/ 787:
47
+ /***/ ((module) => {
48
+
49
+ module.exports = __WEBPACK_EXTERNAL_MODULE__787__;
50
+
51
+ /***/ })
52
+
53
+ /******/ });
54
+ /************************************************************************/
55
+ /******/ // The module cache
56
+ /******/ var __webpack_module_cache__ = {};
57
+ /******/
58
+ /******/ // The require function
59
+ /******/ function __webpack_require__(moduleId) {
60
+ /******/ // Check if module is in cache
61
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
62
+ /******/ if (cachedModule !== undefined) {
63
+ /******/ return cachedModule.exports;
64
+ /******/ }
65
+ /******/ // Create a new module (and put it into the cache)
66
+ /******/ var module = __webpack_module_cache__[moduleId] = {
67
+ /******/ // no module.id needed
68
+ /******/ // no module.loaded needed
69
+ /******/ exports: {}
70
+ /******/ };
71
+ /******/
72
+ /******/ // Execute the module function
73
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
74
+ /******/
75
+ /******/ // Return the exports of the module
76
+ /******/ return module.exports;
77
+ /******/ }
78
+ /******/
79
+ /************************************************************************/
80
+ /******/ /* webpack/runtime/compat get default export */
81
+ /******/ (() => {
82
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
83
+ /******/ __webpack_require__.n = (module) => {
84
+ /******/ var getter = module && module.__esModule ?
85
+ /******/ () => (module['default']) :
86
+ /******/ () => (module);
87
+ /******/ __webpack_require__.d(getter, { a: getter });
88
+ /******/ return getter;
89
+ /******/ };
90
+ /******/ })();
91
+ /******/
92
+ /******/ /* webpack/runtime/define property getters */
93
+ /******/ (() => {
94
+ /******/ // define getter functions for harmony exports
95
+ /******/ __webpack_require__.d = (exports, definition) => {
96
+ /******/ for(var key in definition) {
97
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
98
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
99
+ /******/ }
100
+ /******/ }
101
+ /******/ };
102
+ /******/ })();
103
+ /******/
104
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
105
+ /******/ (() => {
106
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
107
+ /******/ })();
108
+ /******/
109
+ /******/ /* webpack/runtime/make namespace object */
110
+ /******/ (() => {
111
+ /******/ // define __esModule on exports
112
+ /******/ __webpack_require__.r = (exports) => {
113
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
114
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
115
+ /******/ }
116
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
117
+ /******/ };
118
+ /******/ })();
119
+ /******/
120
+ /************************************************************************/
121
+ var __webpack_exports__ = {};
122
+ // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
123
+ (() => {
124
+ __webpack_require__.r(__webpack_exports__);
125
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
126
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
127
+ /* harmony export */ });
128
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(787);
129
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
130
+ /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(605);
131
+ var Highlight=function Highlight(props){var children=props.children,value=props.value,color=props.color,backgroundColor=props.backgroundColor,render=props.render;var child=(0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function(){return render?render(value,color,backgroundColor):/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("span",{style:{color:color,backgroundColor:backgroundColor},children:value});},[color,backgroundColor,value]);return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment,{children:[children,value&&child]});};var KeywordsInner=function KeywordsInner(props){var children=props.children,_props$color=props.color,color=_props$color===void 0?'inherit':_props$color,_props$backgroundColo=props.backgroundColor,backgroundColor=_props$backgroundColo===void 0?'#ffff00':_props$backgroundColo,value=props.value,render=props.render;if(typeof children!=='string')return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment,{children:children});var splitMatch=new RegExp("".concat(value),'ig');var matched=children.split(splitMatch);return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment,{children:matched.map(function(item,idx){return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(Highlight,{color:color,value:matched.length>idx+1?value:undefined,render:render,backgroundColor:backgroundColor,children:item},idx);})});};/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (KeywordsInner);
132
+ })();
133
+
134
+ /******/ return __webpack_exports__;
135
+ /******/ })()
136
+ ;
137
+ });
@@ -0,0 +1,2 @@
1
+ /*! For license information please see keywords.min.js.LICENSE.txt */
2
+ !function(e,r){"object"===typeof exports&&"object"===typeof module?module.exports=r(require("react")):"function"===typeof define&&define.amd?define(["react"],r):"object"===typeof exports?exports["react-keywords"]=r(require("react")):e["react-keywords"]=r(e.React)}(self,(e=>(()=>{"use strict";var r={298:(e,r,o)=>{var t=o(787),n=Symbol.for("react.element"),a=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,c=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function i(e,r,o){var t,a={},i=null,d=null;for(t in void 0!==o&&(i=""+o),void 0!==r.key&&(i=""+r.key),void 0!==r.ref&&(d=r.ref),r)l.call(r,t)&&!u.hasOwnProperty(t)&&(a[t]=r[t]);if(e&&e.defaultProps)for(t in r=e.defaultProps)void 0===a[t]&&(a[t]=r[t]);return{$$typeof:n,type:e,key:i,ref:d,props:a,_owner:c.current}}r.jsx=i,r.jsxs=i},605:(e,r,o)=>{e.exports=o(298)},787:r=>{r.exports=e}},o={};function t(e){var n=o[e];if(void 0!==n)return n.exports;var a=o[e]={exports:{}};return r[e](a,a.exports,t),a.exports}t.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},t.d=(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},t.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),t.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{t.r(n),t.d(n,{default:()=>a});var e=t(787),r=t(605),o=function(o){var t=o.children,n=o.value,a=o.color,l=o.backgroundColor,c=o.render,u=(0,e.useMemo)((function(){return c?c(n,a,l):(0,r.jsx)("span",{style:{color:a,backgroundColor:l},children:n})}),[a,l,n]);return(0,r.jsxs)(e.Fragment,{children:[t,n&&u]})};const a=function(t){var n=t.children,a=t.color,l=void 0===a?"inherit":a,c=t.backgroundColor,u=void 0===c?"#ffff00":c,i=t.value,d=t.render;if("string"!==typeof n)return(0,r.jsx)(e.Fragment,{children:n});var f=new RegExp("".concat(i),"ig"),s=n.split(f);return(0,r.jsx)(e.Fragment,{children:s.map((function(e,t){return(0,r.jsx)(o,{color:l,value:s.length>t+1?i:void 0,render:d,backgroundColor:u,children:e},t)}))})}})(),n})()));
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
package/esm/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+ export interface KeywordsProps {
3
+ value?: string;
4
+ color?: string;
5
+ backgroundColor?: string;
6
+ render?: (keyword: string, color: string, backgroundColor: string) => JSX.Element;
7
+ }
8
+ declare const KeywordsInner: FC<PropsWithChildren<KeywordsProps>>;
9
+ export default KeywordsInner;
package/esm/index.js ADDED
@@ -0,0 +1,52 @@
1
+ import { Fragment, useMemo } from 'react';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { jsxs as _jsxs } from "react/jsx-runtime";
4
+
5
+ var Highlight = props => {
6
+ var {
7
+ children,
8
+ value,
9
+ color,
10
+ backgroundColor,
11
+ render
12
+ } = props;
13
+ var child = useMemo(() => render ? render(value, color, backgroundColor) : /*#__PURE__*/_jsx("span", {
14
+ style: {
15
+ color,
16
+ backgroundColor
17
+ },
18
+ children: value
19
+ }), [color, backgroundColor, value]);
20
+ return /*#__PURE__*/_jsxs(Fragment, {
21
+ children: [children, value && child]
22
+ });
23
+ };
24
+
25
+ var KeywordsInner = props => {
26
+ var {
27
+ children,
28
+ color = 'inherit',
29
+ backgroundColor = '#ffff00',
30
+ value,
31
+ render
32
+ } = props;
33
+ if (typeof children !== 'string') return /*#__PURE__*/_jsx(Fragment, {
34
+ children: children
35
+ });
36
+ var splitMatch = new RegExp("" + value, 'ig');
37
+ var matched = children.split(splitMatch);
38
+ return /*#__PURE__*/_jsx(Fragment, {
39
+ children: matched.map((item, idx) => {
40
+ return /*#__PURE__*/_jsx(Highlight, {
41
+ color: color,
42
+ value: matched.length > idx + 1 ? value : undefined,
43
+ render: render,
44
+ backgroundColor: backgroundColor,
45
+ children: item
46
+ }, idx);
47
+ })
48
+ });
49
+ };
50
+
51
+ export default KeywordsInner;
52
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,32 @@
1
+ {
2
+ "version": 3,
3
+ "names": [
4
+ "Fragment",
5
+ "useMemo",
6
+ "Highlight",
7
+ "props",
8
+ "children",
9
+ "value",
10
+ "color",
11
+ "backgroundColor",
12
+ "render",
13
+ "child",
14
+ "KeywordsInner",
15
+ "splitMatch",
16
+ "RegExp",
17
+ "matched",
18
+ "split",
19
+ "map",
20
+ "item",
21
+ "idx",
22
+ "length",
23
+ "undefined"
24
+ ],
25
+ "sources": [
26
+ "../src/index.tsx"
27
+ ],
28
+ "sourcesContent": [
29
+ "import { FC, Fragment, PropsWithChildren, useMemo } from 'react';\n\nexport interface KeywordsProps {\n value?: string;\n color?: string;\n backgroundColor?: string;\n render?: (keyword: string, color: string, backgroundColor: string) => JSX.Element;\n}\n\ninterface HighlightProps extends KeywordsProps {}\nconst Highlight: FC<PropsWithChildren<HighlightProps>> = (props) => {\n const { children, value, color, backgroundColor, render } = props;\n const child = useMemo(\n () => (render ? render(value!, color!, backgroundColor!) : <span style={{ color, backgroundColor }}>{value}</span>),\n [color, backgroundColor, value],\n );\n return (\n <Fragment>\n {children}\n {value && child}\n </Fragment>\n );\n};\n\nconst KeywordsInner: FC<PropsWithChildren<KeywordsProps>> = (props) => {\n const { children, color = 'inherit', backgroundColor = '#ffff00', value, render } = props;\n if (typeof children !== 'string') return <Fragment>{children}</Fragment>;\n const splitMatch = new RegExp(`${value}`, 'ig');\n const matched = children.split(splitMatch);\n return (\n <Fragment>\n {matched.map((item, idx) => {\n return (\n <Highlight\n key={idx}\n color={color}\n value={matched.length > idx + 1 ? value : undefined}\n render={render}\n backgroundColor={backgroundColor}\n >\n {item}\n </Highlight>\n );\n })}\n </Fragment>\n );\n};\n\nexport default KeywordsInner;\n"
30
+ ],
31
+ "mappings": "AAAA,SAAaA,QAAb,EAA0CC,OAA1C,QAAyD,OAAzD;;;;AAUA,IAAMC,SAAgD,GAAIC,KAAD,IAAW;EAClE,IAAM;IAAEC,QAAF;IAAYC,KAAZ;IAAmBC,KAAnB;IAA0BC,eAA1B;IAA2CC;EAA3C,IAAsDL,KAA5D;EACA,IAAMM,KAAK,GAAGR,OAAO,CACnB,MAAOO,MAAM,GAAGA,MAAM,CAACH,KAAD,EAASC,KAAT,EAAiBC,eAAjB,CAAT,gBAA8C;IAAM,KAAK,EAAE;MAAED,KAAF;MAASC;IAAT,CAAb;IAAA,UAA0CF;EAA1C,EADxC,EAEnB,CAACC,KAAD,EAAQC,eAAR,EAAyBF,KAAzB,CAFmB,CAArB;EAIA,oBACE,MAAC,QAAD;IAAA,WACGD,QADH,EAEGC,KAAK,IAAII,KAFZ;EAAA,EADF;AAMD,CAZD;;AAcA,IAAMC,aAAmD,GAAIP,KAAD,IAAW;EACrE,IAAM;IAAEC,QAAF;IAAYE,KAAK,GAAG,SAApB;IAA+BC,eAAe,GAAG,SAAjD;IAA4DF,KAA5D;IAAmEG;EAAnE,IAA8EL,KAApF;EACA,IAAI,OAAOC,QAAP,KAAoB,QAAxB,EAAkC,oBAAO,KAAC,QAAD;IAAA,UAAWA;EAAX,EAAP;EAClC,IAAMO,UAAU,GAAG,IAAIC,MAAJ,MAAcP,KAAd,EAAuB,IAAvB,CAAnB;EACA,IAAMQ,OAAO,GAAGT,QAAQ,CAACU,KAAT,CAAeH,UAAf,CAAhB;EACA,oBACE,KAAC,QAAD;IAAA,UACGE,OAAO,CAACE,GAAR,CAAY,CAACC,IAAD,EAAOC,GAAP,KAAe;MAC1B,oBACE,KAAC,SAAD;QAEE,KAAK,EAAEX,KAFT;QAGE,KAAK,EAAEO,OAAO,CAACK,MAAR,GAAiBD,GAAG,GAAG,CAAvB,GAA2BZ,KAA3B,GAAmCc,SAH5C;QAIE,MAAM,EAAEX,MAJV;QAKE,eAAe,EAAED,eALnB;QAAA,UAOGS;MAPH,GACOC,GADP,CADF;IAWD,CAZA;EADH,EADF;AAiBD,CAtBD;;AAwBA,eAAeP,aAAf"
32
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-keywords",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Highlight a keyword in a piece of text and return a React element.",
5
5
  "homepage": "https://uiwjs.github.io/react-keywords/",
6
6
  "author": "kenny wang <wowohoo@qq.com>",
@@ -20,6 +20,12 @@
20
20
  "test": "tsbb test --env=jsdom",
21
21
  "coverage": "tsbb test --env=jsdom --coverage --bail"
22
22
  },
23
+ "files": [
24
+ "src",
25
+ "dist",
26
+ "esm",
27
+ "cjs"
28
+ ],
23
29
  "keywords": [
24
30
  "react",
25
31
  "react-keywords",
package/.kktrc.ts DELETED
@@ -1,17 +0,0 @@
1
- import { Configuration } from 'webpack';
2
- import { LoaderConfOptions } from 'kkt';
3
-
4
- export default (conf: Configuration, env: 'production' | 'development', options: LoaderConfOptions) => {
5
- if (options.bundle) {
6
- conf.output!.library = 'react-keywords';
7
- conf.externals = {
8
- react: {
9
- root: 'React',
10
- commonjs2: 'react',
11
- commonjs: 'react',
12
- amd: 'react',
13
- },
14
- };
15
- }
16
- return conf;
17
- };
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../tsconfig",
3
- "include": ["src", ".kktrc.ts"],
4
- "compilerOptions": {
5
- "outDir": "./cjs",
6
- "baseUrl": ".",
7
- "noEmit": false
8
- }
9
- }