Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
dd1fd35238
|
|||
be0daf2097
|
|||
83f29b8e63
|
|||
5926c08da5
|
|||
e37ac9aa4a
|
2613
package-lock.json
generated
2613
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
37
package.json
37
package.json
@@ -1,28 +1,32 @@
|
||||
{
|
||||
"name": "kintone-plugin-docx",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.2",
|
||||
"scripts": {
|
||||
"prepare": "node scripts/prepare-private-key.js",
|
||||
"gen": "run-s gen:*",
|
||||
"gen:key": "node scripts/generate-private-key.js",
|
||||
"start": "node scripts/npm-start.js",
|
||||
"develop": "npm run build -- --watch",
|
||||
"build": "npm run prepare && cross-env NODE_ENV=development rspack build",
|
||||
"build:prod": "npm run prepare && cross-env NODE_ENV=production rspack build",
|
||||
"dts-gen": "kintone-dts-gen",
|
||||
"prebuild": "npm run gen",
|
||||
"prebuild:prod": "npm run gen",
|
||||
"build": "cross-env NODE_ENV=development rspack build",
|
||||
"build:prod": "cross-env NODE_ENV=production rspack build",
|
||||
"lint": "eslint src --ext .js,.jsx,.ts,.tsx",
|
||||
"upload": "env-cmd --silent kintone-plugin-uploader dist/plugin.zip --watch --waiting-dialog-ms 3000"
|
||||
},
|
||||
"dependencies": {
|
||||
"@kintone/rest-api-client": "^5.7.4",
|
||||
"angular-expressions": "^1.4.3",
|
||||
"angular-expressions": "^1.5.0",
|
||||
"clsx": "^2.1.1",
|
||||
"dayjs": "^1.11.13",
|
||||
"docxtemplater": "^3.63.2",
|
||||
"docxtemplater": "^3.65.1",
|
||||
"file-saver": "^2.0.5",
|
||||
"i18next": "^25.3.0",
|
||||
"moize": "^6.1.6",
|
||||
"pizzip": "^3.2.0",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"react-error-boundary": "^6.0.0",
|
||||
"react-i18next": "^15.6.0",
|
||||
"tiny-invariant": "^1.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -30,22 +34,21 @@
|
||||
"@kintone/dts-gen": "^8.1.2",
|
||||
"@kintone/plugin-uploader": "^9.1.5",
|
||||
"@kintone/webpack-plugin-kintone-plugin": "^8.0.11",
|
||||
"@rspack/cli": "^1.3.13",
|
||||
"@rspack/core": "^1.3.13",
|
||||
"@rspack/cli": "^1.4.3",
|
||||
"@rspack/core": "^1.4.3",
|
||||
"@shin-chan/kypes": "^0.0.7",
|
||||
"@swc/helpers": "^0.5.17",
|
||||
"@types/file-saver": "^2.0.7",
|
||||
"@types/react": "^19.1.6",
|
||||
"@types/react-dom": "^19.1.5",
|
||||
"@types/node": "^24.0.10",
|
||||
"@types/react": "^19.1.8",
|
||||
"@types/react-dom": "^19.1.6",
|
||||
"cross-env": "^7.0.3",
|
||||
"css-loader": "^7.1.2",
|
||||
"env-cmd": "^10.1.0",
|
||||
"eslint": "^9.28.0",
|
||||
"eslint": "^9.30.1",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"globals": "^16.2.0",
|
||||
"globals": "^16.3.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^3.5.3",
|
||||
"style-loader": "^4.0.0",
|
||||
"prettier": "^3.6.2",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.8.3"
|
||||
}
|
||||
}
|
||||
|
@@ -1,18 +1,21 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/kintone/js-sdk/%40kintone/plugin-manifest-validator%4010.2.0/packages/plugin-manifest-validator/manifest-schema.json",
|
||||
"manifest_version": 1,
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.2",
|
||||
"type": "APP",
|
||||
"desktop": {
|
||||
"js": ["js/desktop.js"]
|
||||
"js": ["js/desktop.js"],
|
||||
"css": ["js/desktop.css"]
|
||||
},
|
||||
"mobile": {
|
||||
"js": ["js/desktop.js"]
|
||||
"js": ["js/desktop.js"],
|
||||
"css": ["js/desktop.css"]
|
||||
},
|
||||
"icon": "image/icon.png",
|
||||
"config": {
|
||||
"html": "html/config.html",
|
||||
"js": ["js/config.js"],
|
||||
"css": ["js/config.css"],
|
||||
"required_params": ["template"]
|
||||
},
|
||||
"name": {
|
||||
|
@@ -1,99 +0,0 @@
|
||||
/* eslint-env node */
|
||||
|
||||
const path = require('path');
|
||||
const KintonePlugin = require('@kintone/webpack-plugin-kintone-plugin');
|
||||
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
|
||||
module.exports = {
|
||||
mode: isProduction ? 'production' : 'development',
|
||||
devtool: isProduction ? false : 'inline-cheap-module-source-map',
|
||||
entry: { config: './src/config/index.tsx', desktop: './src/desktop/index.tsx' },
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'plugin', 'js'),
|
||||
filename: '[name].js',
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.ts', '.tsx', '.js'],
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.(j|t)s$/,
|
||||
exclude: [/[\\/]node_modules[\\/]/],
|
||||
loader: 'builtin:swc-loader',
|
||||
options: {
|
||||
sourceMaps: !isProduction,
|
||||
jsc: {
|
||||
parser: {
|
||||
syntax: 'typescript',
|
||||
},
|
||||
transform: {
|
||||
react: {
|
||||
runtime: 'automatic',
|
||||
development: !isProduction,
|
||||
},
|
||||
},
|
||||
externalHelpers: true,
|
||||
},
|
||||
env: {
|
||||
targets: 'Chrome >= 48',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.(j|t)sx$/,
|
||||
loader: 'builtin:swc-loader',
|
||||
exclude: [/[\\/]node_modules[\\/]/],
|
||||
options: {
|
||||
sourceMaps: !isProduction,
|
||||
jsc: {
|
||||
parser: {
|
||||
syntax: 'typescript',
|
||||
tsx: true,
|
||||
},
|
||||
transform: {
|
||||
react: {
|
||||
runtime: 'automatic',
|
||||
development: !isProduction,
|
||||
},
|
||||
},
|
||||
externalHelpers: true,
|
||||
},
|
||||
env: {
|
||||
targets: 'Chrome >= 48', // browser compatibility
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.css$/i,
|
||||
use: ['style-loader', 'css-loader'],
|
||||
exclude: /\.module\.css$/,
|
||||
},
|
||||
{
|
||||
test: /\.module\.css$/i,
|
||||
use: [
|
||||
'style-loader',
|
||||
{
|
||||
loader: 'css-loader',
|
||||
options: {
|
||||
importLoaders: 1,
|
||||
sourceMap: !isProduction,
|
||||
modules: {
|
||||
localIdentName: isProduction ? '[hash:base64]' : '[name]__[local]--[hash:base64:5]',
|
||||
namedExport: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
new KintonePlugin({
|
||||
manifestJSONPath: './plugin/manifest.json',
|
||||
privateKeyPath: './private.ppk',
|
||||
pluginZipPath: './dist/plugin.zip',
|
||||
}),
|
||||
],
|
||||
};
|
70
rspack.config.ts
Normal file
70
rspack.config.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import { defineConfig } from '@rspack/cli';
|
||||
import { rspack } from '@rspack/core';
|
||||
|
||||
import KintonePlugin from '@kintone/webpack-plugin-kintone-plugin';
|
||||
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
|
||||
// Target browsers, see: https://github.com/browserslist/browserslist
|
||||
const targets = ['last 2 versions', '> 0.2%', 'not dead', 'Firefox ESR'];
|
||||
|
||||
export default defineConfig({
|
||||
mode: isDev ? 'development' : 'production',
|
||||
devtool: isDev ? 'inline-cheap-module-source-map' : false,
|
||||
entry: { config: './src/config/index.tsx', desktop: './src/desktop/index.tsx' },
|
||||
output: {
|
||||
path: './plugin/js',
|
||||
filename: '[name].js',
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['...', '.ts', '.tsx', '.jsx'],
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.(jsx?|tsx?)$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'builtin:swc-loader',
|
||||
options: {
|
||||
jsc: {
|
||||
parser: {
|
||||
syntax: 'typescript',
|
||||
tsx: true,
|
||||
},
|
||||
},
|
||||
env: { targets },
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
parser: {
|
||||
'css/auto': {
|
||||
namedExports: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
new KintonePlugin({
|
||||
manifestJSONPath: './plugin/manifest.json',
|
||||
privateKeyPath: './private.ppk',
|
||||
pluginZipPath: './dist/plugin.zip',
|
||||
}),
|
||||
],
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new rspack.SwcJsMinimizerRspackPlugin(),
|
||||
new rspack.LightningCssMinimizerRspackPlugin({
|
||||
minimizerOptions: { targets },
|
||||
}),
|
||||
],
|
||||
},
|
||||
experiments: {
|
||||
css: true,
|
||||
},
|
||||
performance: {
|
||||
maxEntrypointSize: 1024000,
|
||||
maxAssetSize: 1024000,
|
||||
},
|
||||
});
|
@@ -7,14 +7,16 @@
|
||||
background-color: rgba(0, 0, 0, 0.7);
|
||||
z-index: 9999;
|
||||
}
|
||||
.spinner-container {
|
||||
|
||||
.spinnerContainer {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: 10000;
|
||||
}
|
||||
.spinner-container .spinner {
|
||||
|
||||
.spinnerContainer .spinner {
|
||||
font-size: 10px;
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
@@ -24,6 +26,7 @@
|
||||
animation: mulShdSpin 1.1s infinite ease;
|
||||
transform: translateZ(0);
|
||||
}
|
||||
|
||||
@keyframes mulShdSpin {
|
||||
0%,
|
||||
100% {
|
||||
|
1
src/common/constants.ts
Normal file
1
src/common/constants.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const DOCX_CONTENT_TYPE = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
|
@@ -1,14 +0,0 @@
|
||||
import invariant from 'tiny-invariant';
|
||||
|
||||
export const PLUGIN_ID = kintone.$PLUGIN_ID;
|
||||
invariant(PLUGIN_ID, 'The PLUGIN_ID is not available. Please ensure you are on a Kintone plugin page.');
|
||||
|
||||
const KintoneUserLanguages = ['en', 'ja', 'zh', 'zh-TW', 'es', 'pt-BR', 'th'] as const;
|
||||
export type KintoneUserLanguages = (typeof KintoneUserLanguages)[number];
|
||||
export const LANGUAGE = kintone.getLoginUser().language as KintoneUserLanguages;
|
||||
invariant(
|
||||
KintoneUserLanguages.includes(LANGUAGE),
|
||||
`Unsupported language: ${LANGUAGE}. Supported languages are: ${KintoneUserLanguages.join(', ')}`,
|
||||
);
|
||||
|
||||
export const DOCX_CONTENT_TYPE = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
|
10
src/common/kintoneLanguageDetector.ts
Normal file
10
src/common/kintoneLanguageDetector.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { LanguageDetectorModule } from 'i18next';
|
||||
|
||||
const KintoneLanguageDetector: LanguageDetectorModule = {
|
||||
type: 'languageDetector',
|
||||
// init: () => {},
|
||||
detect: () => kintone.getLoginUser().language,
|
||||
// cacheUserLanguage: () => {},
|
||||
};
|
||||
|
||||
export default KintoneLanguageDetector;
|
7
src/common/stringUtils.ts
Normal file
7
src/common/stringUtils.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export const naturalCompare = (a: string, b: string): number => {
|
||||
const locales = new Set<string>([...navigator.languages, 'en-US', 'ja-JP']);
|
||||
return new Intl.Collator(Array.from(locales), {
|
||||
sensitivity: 'variant',
|
||||
numeric: true,
|
||||
}).compare(a, b);
|
||||
};
|
5
src/common/types.ts
Normal file
5
src/common/types.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { KintoneFormFieldProperty } from '@kintone/rest-api-client';
|
||||
|
||||
export type KintoneFormFieldProperties = {
|
||||
[fieldCode: string]: KintoneFormFieldProperty.OneOf;
|
||||
};
|
@@ -40,7 +40,7 @@
|
||||
color: #f6f6f6;
|
||||
}
|
||||
|
||||
/* Row for the settings */
|
||||
/* Row for the settings */
|
||||
/*
|
||||
<div class="kintoneplugin-row">Settings 1</div>
|
||||
<div class="kintoneplugin-row">Settings 2</div>
|
||||
@@ -49,7 +49,7 @@
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
/* Heading for each settings*/
|
||||
/* Heading for each settings */
|
||||
/* Heading */
|
||||
/*
|
||||
<div class="kintoneplugin-label">Heading for the setting</div>
|
||||
@@ -79,7 +79,7 @@
|
||||
color: #888;
|
||||
}
|
||||
|
||||
/* Required settings*/
|
||||
/* Required settings */
|
||||
/*
|
||||
<div class="kintoneplugin-label">Title<span class="kintoneplugin-require">*</span></div>
|
||||
*/
|
||||
|
@@ -2,10 +2,9 @@ import React from 'react';
|
||||
|
||||
import clsx from 'clsx';
|
||||
|
||||
interface KintonePluginAlertProps {
|
||||
export type KintonePluginAlertProps = React.PropsWithChildren<{
|
||||
className?: string;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
}>;
|
||||
|
||||
const KintonePluginAlert: React.FC<KintonePluginAlertProps> = (props) => {
|
||||
const { className, children } = props;
|
||||
|
@@ -2,16 +2,15 @@ import React from 'react';
|
||||
|
||||
import clsx from 'clsx';
|
||||
|
||||
interface KintonePluginButtonProps {
|
||||
export type KintonePluginButtonProps = React.PropsWithChildren<{
|
||||
className?: string;
|
||||
variant: 'normal' | 'disabled' | 'dialog-ok' | 'dialog-cancel';
|
||||
variant: 'normal' | 'disabled' | 'dialog-ok' | 'dialog-cancel' | 'add-row-image' | 'remove-row-image';
|
||||
type?: 'button' | 'submit' | 'reset';
|
||||
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
}>;
|
||||
|
||||
const KintonePluginButton: React.FC<KintonePluginButtonProps> = (props) => {
|
||||
const { className, variant, type, onClick, children } = props;
|
||||
const { className, variant, type = 'button', onClick, children } = props;
|
||||
return (
|
||||
<button
|
||||
className={clsx(`kintoneplugin-button-${variant}`, className)}
|
||||
|
@@ -2,10 +2,9 @@ import React from 'react';
|
||||
|
||||
import clsx from 'clsx';
|
||||
|
||||
interface KintonePluginDescProps {
|
||||
export type KintonePluginDescProps = React.PropsWithChildren<{
|
||||
className?: string;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
}>;
|
||||
|
||||
const KintonePluginDesc: React.FC<KintonePluginDescProps> = (props) => {
|
||||
const { className, children } = props;
|
||||
|
@@ -2,10 +2,9 @@ import React from 'react';
|
||||
|
||||
import clsx from 'clsx';
|
||||
|
||||
interface KintonePluginLabelProps {
|
||||
export type KintonePluginLabelProps = React.PropsWithChildren<{
|
||||
className?: string;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
}>;
|
||||
|
||||
const KintonePluginLabel: React.FC<KintonePluginLabelProps> = (props) => {
|
||||
const { className, children } = props;
|
||||
|
@@ -2,10 +2,9 @@ import React from 'react';
|
||||
|
||||
import clsx from 'clsx';
|
||||
|
||||
interface KintonePluginRequire {
|
||||
export type KintonePluginRequire = React.PropsWithChildren<{
|
||||
className?: string;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
}>;
|
||||
|
||||
const KintonePluginRequire: React.FC<KintonePluginRequire> = (props) => {
|
||||
const { className, children } = props;
|
||||
|
@@ -2,10 +2,9 @@ import React from 'react';
|
||||
|
||||
import clsx from 'clsx';
|
||||
|
||||
interface KintonePluginRowProps {
|
||||
export type KintonePluginRowProps = React.PropsWithChildren<{
|
||||
className?: string;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
}>;
|
||||
|
||||
const KintonePluginRow: React.FC<KintonePluginRowProps> = (props) => {
|
||||
const { className, children } = props;
|
||||
|
@@ -2,32 +2,42 @@ import React from 'react';
|
||||
|
||||
import clsx from 'clsx';
|
||||
|
||||
export interface KintonePluginSelectOptionData {
|
||||
key: string;
|
||||
export type KintonePluginSelectOptionData = {
|
||||
value: string;
|
||||
label: string;
|
||||
disabled?: boolean;
|
||||
}
|
||||
};
|
||||
|
||||
interface KintonePluginSelectProps {
|
||||
export type KintonePluginSelectProps = {
|
||||
className?: string;
|
||||
defaultValue?: string;
|
||||
onChange?: (e: React.ChangeEvent<HTMLSelectElement>) => void;
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
options: KintonePluginSelectOptionData[];
|
||||
}
|
||||
};
|
||||
|
||||
const KintonePluginSelect: React.FC<KintonePluginSelectProps> = (props) => {
|
||||
const { className, defaultValue, onChange, options } = props;
|
||||
if (!options || options.length === 0) {
|
||||
return null; // Return null if no options are provided
|
||||
const { className, value, onChange, options } = props;
|
||||
const optionWithKeys = React.useMemo(
|
||||
() =>
|
||||
options.map((option) => ({
|
||||
...option,
|
||||
key: crypto.randomUUID(),
|
||||
})),
|
||||
[options],
|
||||
);
|
||||
if (options.length === 0) {
|
||||
return null;
|
||||
}
|
||||
const handleOnChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
||||
onChange(e.target.value);
|
||||
};
|
||||
return (
|
||||
<div className={clsx('kintoneplugin-select-outer', className)}>
|
||||
<div className="kintoneplugin-select">
|
||||
<select defaultValue={defaultValue} onChange={onChange}>
|
||||
{options.map((option) => (
|
||||
<option key={option.key} value={option.value} disabled={option.disabled}>
|
||||
{option.label}
|
||||
<select value={value} onChange={handleOnChange}>
|
||||
{optionWithKeys.map(({ key, value: itemValue, label, disabled }) => (
|
||||
<option key={key} value={itemValue} disabled={disabled}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
|
@@ -2,10 +2,9 @@ import React from 'react';
|
||||
|
||||
import clsx from 'clsx';
|
||||
|
||||
interface KintonePluginTitleProps {
|
||||
export type KintonePluginTitleProps = React.PropsWithChildren<{
|
||||
className?: string;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
}>;
|
||||
|
||||
const KintonePluginTitle: React.FC<KintonePluginTitleProps> = (props) => {
|
||||
const { className, children } = props;
|
||||
|
@@ -5,11 +5,16 @@ import ErrorFallback from '../common/ErrorFallback';
|
||||
import Loading from '../common/Loading';
|
||||
import Settings from './Settings';
|
||||
|
||||
const ConfigApp: React.FC = () => {
|
||||
interface ConfigAppProps {
|
||||
pluginId: string;
|
||||
}
|
||||
|
||||
const ConfigApp: React.FC<ConfigAppProps> = (props) => {
|
||||
const { pluginId } = props;
|
||||
return (
|
||||
<ErrorBoundary FallbackComponent={ErrorFallback}>
|
||||
<React.Suspense fallback={<Loading />}>
|
||||
<Settings />
|
||||
<Settings pluginId={pluginId} />
|
||||
</React.Suspense>
|
||||
</ErrorBoundary>
|
||||
);
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import React from 'react';
|
||||
|
||||
import { KintoneRestAPIClient } from '@kintone/rest-api-client';
|
||||
import { Properties as KintoneFormFieldProperties } from '@kintone/rest-api-client/lib/src/client/types';
|
||||
import moize from 'moize';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import invariant from 'tiny-invariant';
|
||||
import { PLUGIN_ID } from '../common/global';
|
||||
import { naturalCompare } from '../common/stringUtils';
|
||||
import { KintoneFormFieldProperties } from '../common/types';
|
||||
import KintonePluginAlert from '../common/ui/KintonePluginAlert';
|
||||
import KintonePluginButton from '../common/ui/KintonePluginButton';
|
||||
import KintonePluginDesc from '../common/ui/KintonePluginDesc';
|
||||
@@ -18,22 +19,29 @@ import styles from './Settings.module.css';
|
||||
|
||||
const cachedFormFieldsProperties = moize.promise(async (appId: number): Promise<KintoneFormFieldProperties> => {
|
||||
const client = new KintoneRestAPIClient();
|
||||
const { properties } = await client.app.getFormFields({ app: appId, lang: 'en', preview: false });
|
||||
const { properties } = await client.app.getFormFields({ app: appId, preview: true });
|
||||
return properties;
|
||||
});
|
||||
|
||||
const Settings: React.FC = () => {
|
||||
const config = kintone.plugin.app.getConfig(PLUGIN_ID);
|
||||
interface SettingsProps {
|
||||
pluginId: string;
|
||||
}
|
||||
|
||||
const Settings: React.FC<SettingsProps> = (props) => {
|
||||
const { pluginId } = props;
|
||||
const { t } = useTranslation();
|
||||
const config = kintone.plugin.app.getConfig(pluginId);
|
||||
const appId = kintone.app.getId();
|
||||
invariant(appId, 'The app ID is not available. Please ensure you are on a Kintone app page.');
|
||||
const properties = React.use(cachedFormFieldsProperties(appId));
|
||||
const fileFields = Object.values(properties).filter((property) => property.type === 'FILE');
|
||||
const fileFields = Object.values(properties)
|
||||
.filter((property) => property.type === 'FILE')
|
||||
.sort((a, b) => naturalCompare(`${a.label} (${a.code})`, `${b.label} (${b.code})`));
|
||||
const options: KintonePluginSelectOptionData[] = [
|
||||
{ key: '-', value: '', label: 'Select a File field', disabled: true }, // Default option
|
||||
{ value: '', label: t('settings.template.messages.select-an-attachment-fields'), disabled: true }, // Default option
|
||||
...fileFields.map((property) => ({
|
||||
key: property.code,
|
||||
value: property.code,
|
||||
label: property.label,
|
||||
label: `${property.label} (${property.code})`,
|
||||
})),
|
||||
];
|
||||
|
||||
@@ -44,13 +52,13 @@ const Settings: React.FC = () => {
|
||||
const handleOnSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
kintone.plugin.app.setConfig({ template }, () => {
|
||||
alert('The plug-in settings have been saved. Please update the app!');
|
||||
alert(t('on-saved'));
|
||||
window.location.href = `../../flow?app=${appId}`;
|
||||
});
|
||||
};
|
||||
|
||||
const handleOnChangeTemplate = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
||||
setTemplate(e.target.value);
|
||||
const handleOnChangeTemplate = (value: string) => {
|
||||
setTemplate(value);
|
||||
};
|
||||
|
||||
const handleOnClickCancel = () => {
|
||||
@@ -59,27 +67,26 @@ const Settings: React.FC = () => {
|
||||
|
||||
return (
|
||||
<section className="settings">
|
||||
<KintonePluginLabel>Settings for the Kintone Word output plugin</KintonePluginLabel>
|
||||
<KintonePluginLabel>{t('title')}</KintonePluginLabel>
|
||||
<form onSubmit={handleOnSubmit}>
|
||||
<KintonePluginRow>
|
||||
<KintonePluginTitle>
|
||||
Template<KintonePluginRequire>*</KintonePluginRequire>
|
||||
{t('settings.template.title')}
|
||||
<KintonePluginRequire>*</KintonePluginRequire>
|
||||
</KintonePluginTitle>
|
||||
<KintonePluginDesc>Select a file field that contains the Word template file.</KintonePluginDesc>
|
||||
<KintonePluginDesc> {t('settings.template.description')}</KintonePluginDesc>
|
||||
{fileFields.length === 0 ? (
|
||||
<KintonePluginAlert>
|
||||
No file fields found in the app. Please add a file field to use this plugin.
|
||||
</KintonePluginAlert>
|
||||
<KintonePluginAlert>{t('settings.template.errors.no-attachment-field-found')}</KintonePluginAlert>
|
||||
) : (
|
||||
<KintonePluginSelect defaultValue={template} onChange={handleOnChangeTemplate} options={options} />
|
||||
<KintonePluginSelect value={template} onChange={handleOnChangeTemplate} options={options} />
|
||||
)}
|
||||
</KintonePluginRow>
|
||||
<KintonePluginRow className={styles.buttons}>
|
||||
<KintonePluginButton variant="dialog-cancel" type="button" onClick={handleOnClickCancel}>
|
||||
Cancel
|
||||
{t('buttons.cancel')}
|
||||
</KintonePluginButton>
|
||||
<KintonePluginButton variant="dialog-ok" type="submit">
|
||||
Save
|
||||
{t('buttons.save')}
|
||||
</KintonePluginButton>
|
||||
</KintonePluginRow>
|
||||
</form>
|
||||
|
27
src/config/i18n.ts
Normal file
27
src/config/i18n.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import i18n from 'i18next';
|
||||
import { initReactI18next } from 'react-i18next';
|
||||
import kintoneLanguageDetector from '../common/kintoneLanguageDetector';
|
||||
|
||||
import enTranslation from './locales/en.json';
|
||||
import jaTranslation from './locales/ja.json';
|
||||
|
||||
i18n
|
||||
.use(kintoneLanguageDetector)
|
||||
.use(initReactI18next)
|
||||
.init({
|
||||
fallbackLng: 'en',
|
||||
// debug: true,
|
||||
interpolation: {
|
||||
escapeValue: false, // not needed for react as it escapes by default
|
||||
},
|
||||
resources: {
|
||||
en: {
|
||||
translation: enTranslation,
|
||||
},
|
||||
ja: {
|
||||
translation: jaTranslation,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default i18n;
|
@@ -6,11 +6,15 @@ import ConfigApp from './ConfigApp';
|
||||
|
||||
import '../common/ui/51-modern-default.css';
|
||||
|
||||
const root = document.getElementById('plugin-config-root');
|
||||
invariant(root, 'The plugin configuration root element "plugin-config-root" is not found.');
|
||||
import './i18n';
|
||||
|
||||
ReactDOM.createRoot(root).render(
|
||||
<React.StrictMode>
|
||||
<ConfigApp />
|
||||
</React.StrictMode>,
|
||||
);
|
||||
((PLUGIN_ID) => {
|
||||
const root = document.getElementById('plugin-config-root');
|
||||
invariant(root, 'The plugin configuration root element "plugin-config-root" is not found.');
|
||||
|
||||
ReactDOM.createRoot(root).render(
|
||||
<React.StrictMode>
|
||||
<ConfigApp pluginId={PLUGIN_ID} />
|
||||
</React.StrictMode>,
|
||||
);
|
||||
})(kintone.$PLUGIN_ID);
|
||||
|
20
src/config/locales/en.json
Normal file
20
src/config/locales/en.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"title": "Settings for the Kintone Word output plugin",
|
||||
"settings": {
|
||||
"template": {
|
||||
"title": "Template",
|
||||
"description": "Select a attachment field that contains the Word template file.",
|
||||
"messages": {
|
||||
"select-an-attachment-fields": "(Select an attachment field)"
|
||||
},
|
||||
"errors": {
|
||||
"no-attachment-field-found": "No attachment fields found in the app. Please add an attachment field to use this plugin."
|
||||
}
|
||||
}
|
||||
},
|
||||
"buttons": {
|
||||
"save": "Save",
|
||||
"cancel": "Cancel"
|
||||
},
|
||||
"on-saved": "The plug-in settings have been saved. Please update the app!"
|
||||
}
|
20
src/config/locales/ja.json
Normal file
20
src/config/locales/ja.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"title": "Word出力プラグイン設定",
|
||||
"settings": {
|
||||
"template": {
|
||||
"title": "雛形ファイル",
|
||||
"description": "Word雛形ファイルを保存する添付ファイルフィールドを選択してください。",
|
||||
"messages": {
|
||||
"select-an-attachment-fields": "(選択してください)"
|
||||
},
|
||||
"errors": {
|
||||
"no-attachment-field-found": "このアプリに添付ファイルフィールドが見つかりません。フォームに添付ファイルフィールドを追加してください。"
|
||||
}
|
||||
}
|
||||
},
|
||||
"buttons": {
|
||||
"save": "保存",
|
||||
"cancel": "キャンセル"
|
||||
},
|
||||
"on-saved": "設定を保存しました。アプリを更新してください。"
|
||||
}
|
@@ -6,15 +6,16 @@ import Loading from '../common/Loading';
|
||||
import MenuPanel from './MenuPanel';
|
||||
|
||||
interface DesktopAppProps {
|
||||
pluginId: string;
|
||||
event: kintone.events.AppRecordDetailShowEvent | kintone.events.MobileAppRecordDetailShowEvent;
|
||||
}
|
||||
|
||||
const DesktopApp: React.FC<DesktopAppProps> = (props) => {
|
||||
const { event } = props;
|
||||
const { pluginId, event } = props;
|
||||
return (
|
||||
<ErrorBoundary FallbackComponent={ErrorFallback}>
|
||||
<React.Suspense fallback={<Loading />}>
|
||||
<MenuPanel event={event} />
|
||||
<MenuPanel pluginId={pluginId} event={event} />
|
||||
</React.Suspense>
|
||||
</ErrorBoundary>
|
||||
);
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import React from 'react';
|
||||
|
||||
import { KintoneFormFieldProperty, KintoneRestAPIClient } from '@kintone/rest-api-client';
|
||||
import { Properties as KintoneFormFieldProperties } from '@kintone/rest-api-client/lib/src/client/types';
|
||||
import { KintoneRecord } from '@shin-chan/kypes/types/page';
|
||||
import dayjs from 'dayjs';
|
||||
import Docxtemplater from 'docxtemplater';
|
||||
@@ -9,8 +8,10 @@ import expressionParser from 'docxtemplater/expressions';
|
||||
import { saveAs } from 'file-saver';
|
||||
import moize from 'moize';
|
||||
import PizZip from 'pizzip';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import invariant from 'tiny-invariant';
|
||||
import { DOCX_CONTENT_TYPE, LANGUAGE, PLUGIN_ID } from '../common/global';
|
||||
import { DOCX_CONTENT_TYPE } from '../common/constants';
|
||||
import { KintoneFormFieldProperties } from '../common/types';
|
||||
import KintonePluginAlert from '../common/ui/KintonePluginAlert';
|
||||
import KintonePluginButton from '../common/ui/KintonePluginButton';
|
||||
|
||||
@@ -19,12 +20,13 @@ interface TemplateData {
|
||||
}
|
||||
|
||||
interface MenuPanelProps {
|
||||
pluginId: string;
|
||||
event: kintone.events.AppRecordDetailShowEvent | kintone.events.MobileAppRecordDetailShowEvent;
|
||||
}
|
||||
|
||||
const cachedFormFieldsProperties = moize.promise(async (appId: number): Promise<KintoneFormFieldProperties> => {
|
||||
const client = new KintoneRestAPIClient();
|
||||
const { properties } = await client.app.getFormFields({ app: appId, lang: 'en', preview: false });
|
||||
const { properties } = await client.app.getFormFields({ app: appId, preview: false });
|
||||
return properties;
|
||||
});
|
||||
|
||||
@@ -70,7 +72,11 @@ const formatNumberRecordValue = (
|
||||
return formatValueWithUnit(formattedValue, property);
|
||||
};
|
||||
|
||||
const formatCalculatedRecordValue = (value: string, property: KintoneFormFieldProperty.Calc): string => {
|
||||
const formatCalculatedRecordValue = (
|
||||
value: string,
|
||||
property: KintoneFormFieldProperty.Calc,
|
||||
language: string,
|
||||
): string => {
|
||||
const { format } = property;
|
||||
if (value === '') {
|
||||
return '';
|
||||
@@ -106,7 +112,7 @@ const formatCalculatedRecordValue = (value: string, property: KintoneFormFieldPr
|
||||
!isNaN(hours) && !isNaN(minutes),
|
||||
`Expected hours and minutes to be numbers, but got hours: ${hours}, minutes: ${minutes}`,
|
||||
);
|
||||
formattedValue = LANGUAGE === 'ja' ? `${hours}時間${minutes}分` : `${hours} hours ${minutes} minutes`;
|
||||
formattedValue = language === 'ja' ? `${hours}時間${minutes}分` : `${hours} hours ${minutes} minutes`;
|
||||
} else if (format === 'DAY_HOUR_MINUTE') {
|
||||
// "49:30" -> en: "2 days 1 hour 30 minutes", ja: "2日1時間30分
|
||||
const [hours, minutes] = value.split(':').map((v) => Number(v));
|
||||
@@ -117,7 +123,7 @@ const formatCalculatedRecordValue = (value: string, property: KintoneFormFieldPr
|
||||
const days = Math.floor(Number(hours) / 24);
|
||||
const remainingHours = Number(hours) % 24;
|
||||
formattedValue =
|
||||
LANGUAGE === 'ja'
|
||||
language === 'ja'
|
||||
? `${days}日${remainingHours}時間${minutes}分`
|
||||
: `${days} days ${remainingHours} hours ${minutes} minutes`;
|
||||
} else {
|
||||
@@ -127,7 +133,11 @@ const formatCalculatedRecordValue = (value: string, property: KintoneFormFieldPr
|
||||
return formatValueWithUnit(formattedValue, property);
|
||||
};
|
||||
|
||||
const record2data = (properties: KintoneFormFieldProperties, record: Partial<KintoneRecord>): TemplateData => {
|
||||
const record2data = (
|
||||
properties: KintoneFormFieldProperties,
|
||||
record: Partial<KintoneRecord>,
|
||||
language: string,
|
||||
): TemplateData => {
|
||||
const data: TemplateData = {};
|
||||
for (const key in record) {
|
||||
if (Object.prototype.hasOwnProperty.call(record, key) && Object.prototype.hasOwnProperty.call(properties, key)) {
|
||||
@@ -147,7 +157,7 @@ const record2data = (properties: KintoneFormFieldProperties, record: Partial<Kin
|
||||
data[key] = formatNumberRecordValue(value, property);
|
||||
} else if (type === 'CALC') {
|
||||
invariant(property.type === 'CALC', `Expected property type to be CALC, but got ${property.type}`);
|
||||
data[key] = formatCalculatedRecordValue(value, property);
|
||||
data[key] = formatCalculatedRecordValue(value, property, language);
|
||||
} else if (type === 'CHECK_BOX' || type === 'MULTI_SELECT' || type === 'CATEGORY') {
|
||||
data[key] = value.map((v) => v);
|
||||
} else if (
|
||||
@@ -161,7 +171,7 @@ const record2data = (properties: KintoneFormFieldProperties, record: Partial<Kin
|
||||
});
|
||||
} else if (type === 'SUBTABLE') {
|
||||
invariant(property.type === 'SUBTABLE', `Expected property type to be SUBTABLE, but got ${property.type}`);
|
||||
data[key] = value.map((subRecord) => record2data(property.fields, subRecord.value));
|
||||
data[key] = value.map((subRecord) => record2data(property.fields, subRecord.value, language));
|
||||
} else if (type === 'FILE') {
|
||||
invariant(property.type === 'FILE', `Expected property type to be FILE, but got ${property.type}`);
|
||||
data[key] = value.map((file) => ({
|
||||
@@ -181,32 +191,47 @@ const record2data = (properties: KintoneFormFieldProperties, record: Partial<Kin
|
||||
};
|
||||
|
||||
const MenuPanel: React.FC<MenuPanelProps> = (props) => {
|
||||
const { event } = props;
|
||||
const { pluginId, event } = props;
|
||||
const { t } = useTranslation();
|
||||
const appId = event.appId;
|
||||
const properties = React.use(cachedFormFieldsProperties(appId));
|
||||
const config = kintone.plugin.app.getConfig(PLUGIN_ID);
|
||||
const language = kintone.getLoginUser().language;
|
||||
const config = kintone.plugin.app.getConfig(pluginId);
|
||||
const template: string = config.template ?? '';
|
||||
|
||||
if (template === '') {
|
||||
return (
|
||||
<KintonePluginAlert>
|
||||
Word output plugin: Template field is not set. Please configure the plugin.
|
||||
{t('name')}: {t('errors.template-field-is-not-set')}
|
||||
</KintonePluginAlert>
|
||||
);
|
||||
}
|
||||
const record = event.record[template];
|
||||
if (record == null) {
|
||||
return <KintonePluginAlert>Word output plugin: Template field is not available in this app.</KintonePluginAlert>;
|
||||
return (
|
||||
<KintonePluginAlert>
|
||||
{t('name')}: {t('errors.template-field-is-not-available')}
|
||||
</KintonePluginAlert>
|
||||
);
|
||||
}
|
||||
if (record.type !== 'FILE') {
|
||||
return <KintonePluginAlert>Word output plugin: Template field must be a file field.</KintonePluginAlert>;
|
||||
return (
|
||||
<KintonePluginAlert>
|
||||
{t('name')}: {t('errors.template-field-must-be-an-attachment-field')}
|
||||
</KintonePluginAlert>
|
||||
);
|
||||
}
|
||||
if (record.value.length === 0) {
|
||||
return <KintonePluginAlert>Word output plugin: Template field does not contain any files.</KintonePluginAlert>;
|
||||
return (
|
||||
<KintonePluginAlert>
|
||||
{t('name')}: {t('errors.template-field-does-not-contain-any-files')}
|
||||
</KintonePluginAlert>
|
||||
);
|
||||
}
|
||||
if (record.value.length > 1) {
|
||||
return (
|
||||
<KintonePluginAlert>
|
||||
Word output plugin: Template field contains multiple files. Please ensure it contains only one file.
|
||||
{t('name')}: {t('errors.template-field-contains-multiple-files')}
|
||||
</KintonePluginAlert>
|
||||
);
|
||||
}
|
||||
@@ -214,10 +239,11 @@ const MenuPanel: React.FC<MenuPanelProps> = (props) => {
|
||||
if (contentType !== DOCX_CONTENT_TYPE) {
|
||||
return (
|
||||
<KintonePluginAlert>
|
||||
Word output plugin: The template file must be a DOCX file. The current file type is {contentType}.
|
||||
{t('name')}: {t('errors.template-file-must-be-a-docx', { contentType })}
|
||||
</KintonePluginAlert>
|
||||
);
|
||||
}
|
||||
|
||||
const handleOnClickOutputButton = (e: React.MouseEvent<HTMLButtonElement>) => {
|
||||
e.preventDefault();
|
||||
const client = new KintoneRestAPIClient();
|
||||
@@ -229,8 +255,9 @@ const MenuPanel: React.FC<MenuPanelProps> = (props) => {
|
||||
paragraphLoop: true,
|
||||
linebreaks: true,
|
||||
parser: expressionParser,
|
||||
nullGetter: () => '',
|
||||
});
|
||||
doc.render(record2data(properties, event.record));
|
||||
doc.render(record2data(properties, event.record, language));
|
||||
const out = doc.getZip().generate({ type: 'blob', mimeType: DOCX_CONTENT_TYPE });
|
||||
saveAs(out, 'output.docx');
|
||||
})
|
||||
@@ -242,7 +269,7 @@ const MenuPanel: React.FC<MenuPanelProps> = (props) => {
|
||||
|
||||
return (
|
||||
<KintonePluginButton variant="normal" onClick={handleOnClickOutputButton}>
|
||||
Word出力
|
||||
{t('buttons.output')}
|
||||
</KintonePluginButton>
|
||||
);
|
||||
};
|
||||
|
27
src/desktop/i18n.ts
Normal file
27
src/desktop/i18n.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import i18n from 'i18next';
|
||||
import { initReactI18next } from 'react-i18next';
|
||||
import kintoneLanguageDetector from '../common/kintoneLanguageDetector';
|
||||
|
||||
import enTranslation from './locales/en.json';
|
||||
import jaTranslation from './locales/ja.json';
|
||||
|
||||
i18n
|
||||
.use(kintoneLanguageDetector)
|
||||
.use(initReactI18next)
|
||||
.init({
|
||||
fallbackLng: 'en',
|
||||
// debug: true,
|
||||
interpolation: {
|
||||
escapeValue: false, // not needed for react as it escapes by default
|
||||
},
|
||||
resources: {
|
||||
en: {
|
||||
translation: enTranslation,
|
||||
},
|
||||
ja: {
|
||||
translation: jaTranslation,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default i18n;
|
@@ -6,27 +6,31 @@ import DesktopApp from './DesktopApp';
|
||||
|
||||
import '../common/ui/51-modern-default.css';
|
||||
|
||||
kintone.events.on(
|
||||
['app.record.detail.show', 'mobile.app.record.detail.show'],
|
||||
async (event: kintone.events.AppRecordDetailShowEvent | kintone.events.MobileAppRecordDetailShowEvent) => {
|
||||
const spaceElement =
|
||||
event.type === 'app.record.detail.show'
|
||||
? kintone.app.record.getHeaderMenuSpaceElement()
|
||||
: kintone.mobile.app.getHeaderSpaceElement();
|
||||
invariant(
|
||||
spaceElement,
|
||||
'The header menu space element is not available. Please ensure you are on a Kintone app record detail page.',
|
||||
);
|
||||
import './i18n';
|
||||
|
||||
const root = document.createElement('div');
|
||||
spaceElement.appendChild(root);
|
||||
((PLUGIN_ID) => {
|
||||
kintone.events.on(
|
||||
['app.record.detail.show', 'mobile.app.record.detail.show'],
|
||||
async (event: kintone.events.AppRecordDetailShowEvent | kintone.events.MobileAppRecordDetailShowEvent) => {
|
||||
const spaceElement =
|
||||
event.type === 'app.record.detail.show'
|
||||
? kintone.app.record.getHeaderMenuSpaceElement()
|
||||
: kintone.mobile.app.getHeaderSpaceElement();
|
||||
invariant(
|
||||
spaceElement,
|
||||
'The header menu space element is not available. Please ensure you are on a Kintone app record detail page.',
|
||||
);
|
||||
|
||||
ReactDOM.createRoot(root).render(
|
||||
<React.StrictMode>
|
||||
<DesktopApp event={event} />
|
||||
</React.StrictMode>,
|
||||
);
|
||||
const root = document.createElement('div');
|
||||
spaceElement.appendChild(root);
|
||||
|
||||
return event;
|
||||
},
|
||||
);
|
||||
ReactDOM.createRoot(root).render(
|
||||
<React.StrictMode>
|
||||
<DesktopApp pluginId={PLUGIN_ID} event={event} />
|
||||
</React.StrictMode>,
|
||||
);
|
||||
|
||||
return event;
|
||||
},
|
||||
);
|
||||
})(kintone.$PLUGIN_ID);
|
||||
|
14
src/desktop/locales/en.json
Normal file
14
src/desktop/locales/en.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "Word output plugin",
|
||||
"errors": {
|
||||
"template-field-is-not-set": "Template field is not set. Please configure the plugin.",
|
||||
"template-field-is-not-available": "Template field is not available in this app.",
|
||||
"template-field-must-be-an-attachment-field": "Template field must be an attachment field.",
|
||||
"template-field-does-not-contain-any-files": "Template field does not contain any files.",
|
||||
"template-field-contains-multiple-files": "Template field contains multiple files. Please ensure it contains only one file.",
|
||||
"template-file-must-be-a-docx": "The template file must be a Word (.docx) file. 'Mime-Type: {{contentType}}'."
|
||||
},
|
||||
"buttons": {
|
||||
"output": "Output Word"
|
||||
}
|
||||
}
|
14
src/desktop/locales/ja.json
Normal file
14
src/desktop/locales/ja.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "Word出力プラグイン",
|
||||
"errors": {
|
||||
"template-field-is-not-set": "雛形ファイルが設定されていません。プラグインの設定を見直してください。",
|
||||
"template-field-is-not-available": "雛形ファイルに設定された添付ファイルフィールドが見つかりませんでした。プラグインの設定を見直してください。",
|
||||
"template-field-must-be-an-attachment-field": "雛形ファイルに設定されたフィールド型が添付ファイルフィールドではありません。プラグインの設定を見直してください。",
|
||||
"template-field-does-not-contain-any-files": "雛形ファイルが添付されていません。",
|
||||
"template-field-contains-multiple-files": "雛形ファイルとして複数登録されています。1つのみを指定してください。",
|
||||
"template-file-must-be-a-docx": "雛形ファイルがWord形式(.docx)ではありません。'Mime-Type: {{contentType}}'"
|
||||
},
|
||||
"buttons": {
|
||||
"output": "Word出力"
|
||||
}
|
||||
}
|
5
src/kintone-env.d.ts
vendored
5
src/kintone-env.d.ts
vendored
@@ -7,11 +7,6 @@ declare module '*.module.css' {
|
||||
const classes: CSSModuleClasses;
|
||||
export default classes;
|
||||
}
|
||||
declare module '*.module.scss' {
|
||||
const classes: CSSModuleClasses;
|
||||
export default classes;
|
||||
}
|
||||
|
||||
// CSS
|
||||
declare module '*.css' {}
|
||||
declare module '*.scss' {}
|
||||
|
@@ -1,73 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
||||
"lib": ["DOM", "ES2020"],
|
||||
"jsx": "react-jsx",
|
||||
"target": "ES2020",
|
||||
"noEmit": true,
|
||||
"skipLibCheck": true,
|
||||
"useDefineForClassFields": true,
|
||||
|
||||
/* Basic Options */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
||||
"module": "es2015", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
||||
"lib": ["dom", "es2020"], /* Specify library files to be included in the compilation. */
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||
"outDir": "./plugin", /* Redirect output structure to the directory. */
|
||||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||
// "composite": true, /* Enable project compilation */
|
||||
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
||||
// "removeComments": true, /* Do not emit comments to output. */
|
||||
// "noEmit": true, /* Do not emit outputs. */
|
||||
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||
/* modules */
|
||||
"module": "ESNext",
|
||||
"resolveJsonModule": true,
|
||||
"moduleResolution": "bundler",
|
||||
"esModuleInterop": true,
|
||||
"allowImportingTsExtensions": true,
|
||||
|
||||
/* Strict Type-Checking Options */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
// "strictNullChecks": true, /* Enable strict null checks. */
|
||||
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||
|
||||
/* Additional Checks */
|
||||
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
||||
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
|
||||
/* Module Resolution Options */
|
||||
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||
// "types": [], /* Type declaration files to be included in compilation. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||
|
||||
/* Source Map Options */
|
||||
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
||||
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
||||
|
||||
/* Experimental Options */
|
||||
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
||||
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||
|
||||
/* Advanced Options */
|
||||
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
||||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
||||
/* type checking */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*",
|
||||
"./node_modules/@kintone/dts-gen/kintone.d.ts"
|
||||
]
|
||||
"include": ["src/**/*", "./node_modules/@kintone/dts-gen/kintone.d.ts"],
|
||||
"ts-node": {
|
||||
"compilerOptions": {
|
||||
"module": "CommonJS"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user