Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit 200dba1

Browse files
committed
fix typescript error
1 parent b6aa009 commit 200dba1

File tree

9 files changed

+52
-46
lines changed

9 files changed

+52
-46
lines changed

docs/package-lock.json

+14-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
"@types/react-dom": "18.0.11",
1515
"eslint": "8.35.0",
1616
"eslint-config-next": "13.2.3",
17-
"jb-date-input": "^3.7.3",
18-
"jb-date-input-react": "^2.0.12",
17+
"jb-calendar": "^4.0.3",
18+
"jb-date-input": "^3.7.12",
19+
"jb-date-input-react": "^2.0.17",
1920
"next": "13.2.3",
2021
"react": "18.2.0",
2122
"react-dom": "18.2.0",

docs/src/components/intro-section/IntroSection.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ComponentName, ComponentSubtitle, IntroWrapper } from './styled';
33
import dynamic from 'next/dynamic';
44

55
function IntroSection() {
6-
const JBDateInput = dynamic(() => import('jb-date-input-react').then(module => module.default), {
6+
const JBDateInput = dynamic(() => import('jb-date-input-react').then(module => module.JBDateInput), {
77
ssr: false,
88
});
99
return (

docs/src/components/samples/Samples.tsx

+17-13
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
import 'jb-date-input';
2-
import React from 'react';
1+
import React, { useEffect } from 'react';
32
import { FormalTheme, SamplesSectionWrapper, SamplesTitle } from './styled';
43
import dynamic from 'next/dynamic';
54
// eslint-disable-next-line no-duplicate-imports
6-
import { InputTypes,JBDateInputValueObject } from 'jb-date-input';
7-
const JBDateInput = dynamic(() => import('jb-date-input-react').then(module => module.default), {
5+
// import {JBDateInputValueObject } from 'jb-date-input-react';
6+
// import {InputTypes as JBDateInputInputTypes} from 'jb-date-input/dist/web-component/jb-date-input/lib/Types';
7+
enum InputTypes {
8+
jalali = 'JALALI',
9+
gregorian = 'GREGORIAN'
10+
}
11+
const JBDateInput = dynamic(() => import('jb-date-input-react').then(module => module.JBDateInput), {
812
ssr: false,
913
});
1014
const validationList = [
@@ -13,7 +17,7 @@ const validationList = [
1317
message: 'تاریخ باید تنها در قرن 13 شمسی باشد'
1418
},
1519
{
16-
validator: (inputedText: string, valueObject: JBDateInputValueObject, valueText: string) => {
20+
validator: (inputedText: string, valueObject: any, valueText: string) => {
1721
//you can use raw inputed text or formatted text in expected value in argumants
1822
//you have access to both jalali and gregorian date object here in valueObject
1923
// remember valueObject and valueText are both empty and null when date is incomplete
@@ -29,13 +33,13 @@ function Samples() {
2933
<SamplesTitle>
3034
Samples
3135
</SamplesTitle>
32-
<JBDateInput label="simple date:">{}</JBDateInput>
33-
<JBDateInput label="with persian number" usePersianNumber={true}>{}</JBDateInput>
34-
<JBDateInput label="with default value:" value="2020-08-10T08:51:23.176Z">{}</JBDateInput>
35-
<JBDateInput label="with min and max value:" value="2020-08-10T08:51:23.176Z" min="2020-08-05T08:51:23.176Z" max="2020-08-15T08:51:23.176Z">{}</JBDateInput>
36-
<JBDateInput label="with validation" validationList={validationList}>{}</JBDateInput>
37-
<JBDateInput label="gregorian date:" inputType="GREGORIAN">{}</JBDateInput>
38-
<JBDateInput label="with default opened calendar date" inputType="JALALI" calendarDefaultDateView={{ year: 1350, month: 3, dateType:InputTypes.jalali }}>{}</JBDateInput>
36+
<JBDateInput label="simple date:">{ }</JBDateInput>
37+
<JBDateInput label="with persian number" usePersianNumber={true}>{ }</JBDateInput>
38+
<JBDateInput label="with default value:" value="2020-08-10T08:51:23.176Z">{ }</JBDateInput>
39+
<JBDateInput label="with min and max value:" value="2020-08-10T08:51:23.176Z" min="2020-08-05T08:51:23.176Z" max="2020-08-15T08:51:23.176Z">{ }</JBDateInput>
40+
<JBDateInput label="with validation" validationList={validationList}>{ }</JBDateInput>
41+
<JBDateInput label="gregorian date:" inputType="GREGORIAN">{ }</JBDateInput>
42+
<JBDateInput label="with default opened calendar date" inputType="JALALI" calendarDefaultDateView={{ year: 1350, month: 3, dateType: InputTypes.jalali }}>{ }</JBDateInput>
3943
<JBDateInput label="with custom icon">
4044
<div slot="calendar-trigger-icon">
4145
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" x="0px" y="0px" viewBox="0 0 610.398 610.398">
@@ -65,7 +69,7 @@ function Samples() {
6569
<div>before</div>
6670
</jb-date-input-inbox-element>
6771
</JBDateInput>
68-
<FormalTheme label="more formal look">{}</FormalTheme>
72+
<FormalTheme label="more formal look">{ }</FormalTheme>
6973

7074
</SamplesSectionWrapper>
7175
);

docs/src/components/samples/styled.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import styled from "styled-components";
22
import dynamic from 'next/dynamic';
3-
const JBDateInput = dynamic(() => import('jb-date-input-react').then(module => module.default), {
3+
const JBDateInput = dynamic(() => import('jb-date-input-react').then(module => module.JBDateInput), {
44
ssr: false,
55
});
66
export const SamplesSectionWrapper = styled.section`
+8-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
export function fixMobileHeightVH() {
2-
// First we get the viewport height and we multiple it by 1% to get a value for a vh unit
3-
let vh = window.innerHeight * 0.01;
4-
// Then we set the value in the --vh custom property to the root of the document
2+
// First we get the viewport height and we multiple it by 1% to get a value for a vh unit
3+
const vh = window.innerHeight * 0.01;
4+
// Then we set the value in the --vh custom property to the root of the document
5+
document.documentElement.style.setProperty('--vh', `${vh}px`);
6+
window.addEventListener('resize', () => {
7+
// We execute the same script as before
8+
const vh = window.innerHeight * 0.01;
59
document.documentElement.style.setProperty('--vh', `${vh}px`);
6-
window.addEventListener('resize', () => {
7-
// We execute the same script as before
8-
let vh = window.innerHeight * 0.01;
9-
document.documentElement.style.setProperty('--vh', `${vh}px`);
10-
});
10+
});
1111
}

index.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
import JBDateInput from './dist/JBDateInput.js';
2-
export default JBDateInput;
1+
export {JBDateInput,JBDateInputInputTypes} from './dist/JBDateInput.js';

lib/JBDateInput.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import PropTypes from 'prop-types';
33
// import {type} from 'jb-date-input';
44
import 'jb-date-input';
55
// eslint-disable-next-line no-duplicate-imports
6-
import { JBDateInputWebComponent, InputTypes, JBDateInputValidationItem, JBDDateInputInboxElementWebComponent } from 'jb-date-input';
6+
import { JBDateInputWebComponent, JBDateInputInputTypes, JBDateInputValidationItem, JBDDateInputInboxElementWebComponent,JBDateInputValueObject } from 'jb-date-input';
77
import { useEvent } from '../../custom-hooks/UseEvent';
88

9+
export {JBDateInputInputTypes,JBDateInputValueObject};
910
type CustomEvents<K extends string> = { [key in K] : (event: CustomEvent) => void };
1011

1112
type CustomElement<T, K extends string> = Partial<T & DOMAttributes<T> & { children: any } & CustomEvents<`on${K}`>>;
@@ -40,7 +41,7 @@ export type JBDateInputProps = {
4041
value?: string,
4142
validationList?: JBDateInputValidationItem[],
4243
required?: boolean,
43-
calendarDefaultDateView?:{ year:number, month: number, dateType:InputTypes},
44+
calendarDefaultDateView?:{ year:number, month: number, dateType:JBDateInputInputTypes},
4445
usePersianNumber?: boolean,
4546
children:any,
4647
}
@@ -168,10 +169,10 @@ JBDateInput.propTypes = {
168169
value: PropTypes.string,
169170
validationList: PropTypes.array,
170171
required: PropTypes.bool,
171-
calendarDefaultDateView: PropTypes.shape({ year: PropTypes.number.isRequired, month: PropTypes.number.isRequired, dateType: PropTypes.oneOf<InputTypes>([InputTypes.gregorian, InputTypes.jalali]).isRequired }),
172+
calendarDefaultDateView: PropTypes.shape({ year: PropTypes.number.isRequired, month: PropTypes.number.isRequired, dateType: PropTypes.oneOf<JBDateInputInputTypes>([JBDateInputInputTypes.gregorian, JBDateInputInputTypes.jalali]).isRequired }),
172173
// calendarDefaultDateView: PropTypes.object,
173174
usePersianNumber: PropTypes.bool,
174175
// children:PropTypes.element
175176
};
176177

177-
export default JBDateInput;
178+
export {JBDateInput};

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"react component",
1919
"react"
2020
],
21-
"version": "2.0.12",
21+
"version": "2.0.17",
2222
"bugs": "https://github.com/javadbat/jb-date-input-react/issues",
2323
"license": "MIT",
2424
"files": [
@@ -36,6 +36,6 @@
3636
"url": "https://github.com/javadbat/jb-date-input-react"
3737
},
3838
"dependencies": {
39-
"jb-date-input": ">=3.7.5"
39+
"jb-date-input": ">=3.7.11"
4040
}
4141
}

0 commit comments

Comments
 (0)