Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
216 changes: 214 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "@doist/react-interpolate",
"version": "2.0.0",
"version": "2.1.0",
"license": "MIT",
"description": "A string interpolation component that formats and interpolates a template string in a safe way",
"main": "dist/react-interpolate.cjs",
"module": "dist/react-interpolate.mjs",
"types": "dist/react-interpolate.d.ts",
"engines": {
"node": "^20.0.0 || ^21.0.0",
"npm": "^10.0.0"
Expand Down Expand Up @@ -68,6 +69,7 @@
"react-dom": "18.2.0",
"rollup": "2.75.7",
"rollup-plugin-babel": "4.4.0",
"rollup-plugin-copy": "3.5.0",
"uglify-es": "3.3.9"
}
}
8 changes: 7 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import babel from 'rollup-plugin-babel'
import pkg from './package.json'
import copy from 'rollup-plugin-copy'

export default {
input: 'src/index.js',
Expand All @@ -13,5 +14,10 @@ export default {
format: 'es',
},
],
plugins: [babel({ runtimeHelpers: true })],
plugins: [
babel({ runtimeHelpers: true }),
copy({
targets: [{ src: 'src/react-interpolate.d.ts', dest: 'dist' }],
}),
],
}
18 changes: 18 additions & 0 deletions src/react-interpolate.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const TOKEN_PLACEHOLDER: 'TOKEN_PLACEHOLDER'

type Syntax = {
type: typeof TOKEN_PLACEHOLDER
regex: RegExp
}

type InterpolateProps = {
string: string
mapping: {
[key: string]: ((children: React.ReactNode) => React.ReactNode) | React.ReactNode
}
syntax?: Syntax[]
}

declare function Interpolate(props: InterpolateProps): JSX.Element

export = Interpolate