Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 4 migrate to jalaali js and drop usage of moment #13

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
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
81 changes: 42 additions & 39 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "root",
"private": true,
"workspaces": [
"packages/*"
Expand All @@ -13,57 +14,59 @@
"delete-node-modules": "node ./scripts/delete-node-modules.js"
},
"devDependencies": {
"@babel/core": "^7.17.8",
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/plugin-transform-runtime": "^7.17.0",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.16.7",
"@babel/preset-typescript": "^7.16.7",
"@parcel/transformer-sass": "2.3.2",
"@rollup/plugin-typescript": "^8.3.1",
"@types/jest": "^27.4.1",
"@babel/core": "^7.19.0",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-transform-runtime": "^7.18.10",
"@babel/preset-env": "^7.19.0",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@parcel/transformer-sass": "2.7.0",
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-typescript": "^8.5.0",
"@types/jest": "^29.0.0",
"@types/moment-jalaali": "^0.7.5",
"@types/node": "^17.0.21",
"@types/react": "^17.0.41",
"@types/react-dom": "^17.0.14",
"@types/node": "^18.7.16",
"@types/react": "^18.0.18",
"@types/react-dom": "^18.0.6",
"@types/rimraf": "^3.0.2",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"cross-env": "^7.0.3",
"eslint": "^8.11.0",
"eslint": "^8.23.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.29.4",
"husky": "^7.0.4",
"jest": "^27.5.1",
"jest-config": "^27.5.1",
"lerna": "^4.0.0",
"lint-staged": "^12.3.7",
"npm-check-updates": "^12.5.4",
"parcel": "^2.3.2",
"postcss": "^8.4.12",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.31.8",
"husky": "^8.0.1",
"jest": "^29.0.2",
"jest-config": "^29.0.2",
"jest-environment-jsdom": "^29.0.3",
"lerna": "^5.5.1",
"lint-staged": "^13.0.3",
"npm-check-updates": "^16.1.0",
"parcel": "^2.7.0",
"postcss": "^8.4.16",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-preset-env": "^7.4.3",
"prettier": "^2.6.0",
"postcss-preset-env": "^7.8.1",
"prettier": "^2.7.1",
"process": "^0.11.10",
"rimraf": "^3.0.2",
"rollup": "^2.70.1",
"rollup": "^2.79.0",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.31.2",
"sass": "^1.49.9",
"stylelint": "^14.6.0",
"stylelint-config-recommended-scss": "^6.0.0",
"stylelint-scss": "^4.2.0",
"ts-jest": "^27.1.3",
"ts-node": "^10.7.0",
"tslib": "^2.3.1",
"typescript": "^4.6.2"
"rollup-plugin-typescript2": "^0.33.0",
"sass": "^1.54.9",
"stylelint": "^14.11.0",
"stylelint-config-recommended-scss": "^7.0.0",
"stylelint-scss": "^4.3.0",
"ts-jest": "^29.0.0",
"ts-node": "^10.9.1",
"tslib": "^2.4.0",
"typescript": "^4.8.3"
},
"lint-staged": {
"./packages/**/*.{js,jsx,ts,tsx}": [
Expand Down
33 changes: 33 additions & 0 deletions packages/converter-jalali-universal-datepicker/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"root": true,
"env": {
"browser": true,
"es6": true,
"jest": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/recommended"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"tsconfigRootDir": "./",
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"@typescript-eslint/interface-name-prefix": "off",
"max-classes-per-file": "off",
"@typescript-eslint/no-explicit-any": "off"
}
}
15 changes: 15 additions & 0 deletions packages/converter-jalali-universal-datepicker/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
node_modules
coverage
.nyc_output
.DS_Store
*.log
.vscode
.idea
dist
compiled
.awcache
.rpt2_cache
docs
yarn.lock
package-lock.json
.cache
1 change: 1 addition & 0 deletions packages/converter-jalali-universal-datepicker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Jalali converter
70 changes: 70 additions & 0 deletions packages/converter-jalali-universal-datepicker/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"name": "converter-jalali-universal-datepicker",
"version": "0.2.1",
"description": "A converter for Jalali calendar. Convert jalali to georgian or vice versa",
"keywords": [
"datepicker",
"calendar",
"persian",
"jalali",
"farsi",
"persian datepicker",
"jalali datepicker",
"persian calendar"
],
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
"dist"
],
"author": "Mohammad Toosi m_dd@rogers.com",
"repository": {
"type": "git",
"url": "https://github.com/mammad2c/mmd-persian-datepicker",
"directory": "packages/converter-jalali-universal-datepicker"
},
"license": "MIT",
"engines": {
"node": ">=8.0.0"
},
"scripts": {
"prebuild": "rimraf dist && rimraf .cache",
"build": "yarn prebuild && cross-env NODE_ENV=production rollup -c rollup.config.ts",
"start": "yarn prebuild && rollup -c rollup.config.ts -w",
"example": "parcel example/index.html",
"test": "jest --coverage",
"prepublish": "yarn build",
"test:watch": "jest --coverage --watch",
"test:prod": "npm run lint && npm run test -- --no-cache",
"lint:js": "eslint --fix src/**/*.tsx",
"lint:styles": "stylelint --fix src/**/*.{css,scss,less,sass}"
},
"jest": {
"transform": {
".(ts|tsx)": "ts-jest"
},
"testEnvironment": "jsdom",
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"coveragePathIgnorePatterns": [
"/node_modules/",
"/test/"
],
"coverageThreshold": {
"global": {
"branches": 90,
"functions": 95,
"lines": 95,
"statements": 95
}
},
"collectCoverageFrom": [
"src/*.{js,ts,tsx}"
]
},
"dependencies": {}
}
53 changes: 53 additions & 0 deletions packages/converter-jalali-universal-datepicker/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import commonjs from "rollup-plugin-commonjs";
import sourceMaps from "rollup-plugin-sourcemaps";
import babel from "rollup-plugin-babel";
import typescript from "rollup-plugin-typescript2";
import json from "@rollup/plugin-json";
import { terser } from "rollup-plugin-terser";
import pkg from "./package.json";

const isProduction = process.env.NODE_ENV === "production";

const extensions = [".js", ".jsx", ".ts", ".tsx"];

export default {
input: `src/index.ts`,
output: [
{
file: pkg.main,
name: "ConverterJalaliUniversalDatepicker",
format: "umd",
sourcemap: true,
},
],

external: [...Object.keys(pkg.dependencies)],
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
watch: {
include: "src/**",
},
plugins: [
// Allow json resolution
json(),
// Compile TypeScript files
typescript(),
// Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
commonjs(),
// Allow node_modules resolution, so you can use 'external' to control
// which external modules to include in the bundle
// https://github.com/rollup/rollup-plugin-node-resolve#usage
babel({
presets: ["@babel/preset-env", "@babel/preset-typescript"],
extensions,
plugins: [
"@babel/plugin-proposal-class-properties",
"@babel/transform-runtime",
],
exclude: "node_modules/**",
runtimeHelpers: true,
}),
// Resolve source maps to the original source
sourceMaps(),
isProduction && terser(),
],
};
3 changes: 3 additions & 0 deletions packages/converter-jalali-universal-datepicker/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function () {
console.log("salam");
}
10 changes: 10 additions & 0 deletions packages/converter-jalali-universal-datepicker/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"jsx": "react",
"outDir": "dist",
"rootDir": "src"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", ".cache", "example"]
}
12 changes: 6 additions & 6 deletions packages/mmd-persian-datepicker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"scripts": {
"prebuild": "rimraf dist && rimraf .cache",
"build": "tsc --module commonjs && cross-env NODE_ENV=production rollup -c rollup.config.ts",
"build": "yarn prebuild && cross-env NODE_ENV=production rollup -c rollup.config.ts",
"start": "yarn prebuild && rollup -c rollup.config.ts -w",
"example": "parcel example/index.html",
"prepublish": "yarn build",
Expand Down Expand Up @@ -67,12 +67,12 @@
]
},
"peerDependencies": {
"moment": "^2.29.1",
"moment-jalaali": "^0.9.4"
"moment": "^2.29.4",
"moment-jalaali": "^0.9.6"
},
"dependencies": {
"jalaali-js": "^1.2.3",
"moment": "^2.29.1",
"moment-jalaali": "^0.9.4"
"jalaali-js": "^1.2.6",
"moment": "^2.29.4",
"moment-jalaali": "^0.9.6"
}
}
2 changes: 1 addition & 1 deletion packages/mmd-persian-datepicker/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import sourceMaps from "rollup-plugin-sourcemaps";
import typescript from "rollup-plugin-typescript2";
import json from "rollup-plugin-json";
import json from "@rollup/plugin-json";
import postcss from "rollup-plugin-postcss";
import { terser } from "rollup-plugin-terser";
import postcssFlexbugsFixes from "postcss-flexbugs-fixes";
Expand Down

This file was deleted.

10 changes: 7 additions & 3 deletions packages/react-mmd-persian-datepicker/example/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from "react";
import ReactDOM from "react-dom";
import { createRoot } from "react-dom/client";
import MmdPersianDatepicker from "../src";

const CustomInput: React.FC<{
Expand All @@ -9,7 +9,7 @@ const CustomInput: React.FC<{
const App: React.FC = () => {
const [active, setActive] = useState(true);
const [date, setDate] = useState<any>([]);
const [disabledDates, setDisabledDates] = useState([]);
const [disabledDates, setDisabledDates] = useState<string[]>([]);

return (
<div>
Expand Down Expand Up @@ -52,4 +52,8 @@ const App: React.FC = () => {
};

const mountNode = document.getElementById("app");
ReactDOM.render(<App />, mountNode);

if (mountNode) {
const root = createRoot(mountNode);
root.render(<App />);
}
Loading