@jk-core/components 0.0.6 → 0.0.8

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.
Files changed (46) hide show
  1. package/dist/Calendar/components/DayTile/index.d.ts +11 -0
  2. package/dist/Calendar/components/MonthTile/index.d.ts +9 -0
  3. package/dist/Calendar/components/YearTile/index.d.ts +8 -0
  4. package/dist/Calendar/hooks/useCalendarNav.d.ts +14 -0
  5. package/dist/Calendar/hooks/useDateSelect.d.ts +14 -0
  6. package/dist/Calendar/index.d.ts +13 -0
  7. package/{src/Calendar/type.ts → dist/Calendar/type.d.ts} +2 -3
  8. package/dist/Calendar/utils/getWeeksInMonth.d.ts +5 -0
  9. package/dist/Calendar/utils/isInRange.d.ts +3 -0
  10. package/dist/Calendar/utils/isSameDay.d.ts +3 -0
  11. package/dist/index.d.ts +2 -0
  12. package/dist/index.js +937 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/index.umd.cjs +40 -0
  15. package/dist/index.umd.cjs.map +1 -0
  16. package/dist/main.d.ts +1 -0
  17. package/dist/style.css +402 -0
  18. package/dist/style.css.map +1 -0
  19. package/package.json +16 -5
  20. package/src/Calendar/{Calendar.module.scss → scss/_calendar.scss} +9 -0
  21. package/src/Calendar/scss/_tile.scss +214 -0
  22. package/src/Calendar/scss/main.scss +3 -0
  23. package/.eslintrc.json +0 -63
  24. package/.stylelintrc.json +0 -29
  25. package/src/Calendar/components/DayTile/DayTile.module.scss +0 -79
  26. package/src/Calendar/components/DayTile/index.tsx +0 -52
  27. package/src/Calendar/components/MonthTile/MonthTile.module.scss +0 -44
  28. package/src/Calendar/components/MonthTile/index.tsx +0 -38
  29. package/src/Calendar/components/YearTile/YearTile.module.scss +0 -85
  30. package/src/Calendar/components/YearTile/index.tsx +0 -60
  31. package/src/Calendar/components/mixin.module.scss +0 -5
  32. package/src/Calendar/hooks/useCalendarNav.ts +0 -80
  33. package/src/Calendar/hooks/useDateSelect.ts +0 -47
  34. package/src/Calendar/index.tsx +0 -166
  35. package/src/Calendar/utils/getWeeksInMonth.ts +0 -45
  36. package/src/Calendar/utils/isInRange.ts +0 -8
  37. package/src/Calendar/utils/isSameDay.ts +0 -21
  38. package/src/assets/close.svg +0 -16
  39. package/src/assets/drop-arrow.svg +0 -3
  40. package/src/index.tsx +0 -3
  41. package/src/styles/mediaQuery.scss +0 -22
  42. package/src/svg.d.ts +0 -6
  43. package/src/vite-env.d.ts +0 -1
  44. package/tsconfig.json +0 -13
  45. package/vite.config.ts +0 -58
  46. /package/src/{styles/color.scss → Calendar/scss/_variables.scss} +0 -0
@@ -1,166 +0,0 @@
1
- /* eslint-disable react/no-array-index-key */
2
- import { useState } from 'react';
3
- import { cn } from '@jk-core/utils';
4
- import CloseIcon from '../assets/close.svg';
5
- import DropIcon from '../assets/drop-arrow.svg';
6
- import styles from './Calendar.module.scss';
7
- import { CalendarView } from './type';
8
- import getWeeksInMonth from './utils/getWeeksInMonth';
9
- import DayTile from './components/DayTile';
10
- import MonthTile from './components/MonthTile';
11
- import YearTile from './components/YearTile';
12
- import useCalendarNav from './hooks/useCalendarNav';
13
- import useDateSelect from './hooks/useDateSelect';
14
-
15
- import '../styles/color.scss';
16
-
17
- interface CalendarProps {
18
- date?: Date;
19
- view?: CalendarView;
20
- tileContent?: (date: Date | undefined, view: CalendarView) => React.ReactNode;
21
- onChange?:(date:Date)=>void;
22
- min?: Date;
23
- max?: Date;
24
- onClose?:()=>void;
25
- }
26
-
27
- export default function Calendar({
28
- date: selectedDate, view, tileContent, onChange = () => { }, onClose,
29
- min = new Date(2000, 0, 1), max = new Date(2099, 11, 31),
30
- }:CalendarProps) {
31
- const [viewDate, setViewDate] = useState<Date>(selectedDate || new Date());
32
- const [method, setMethod] = useState<CalendarView>(view || 'day');
33
- const [selectMode, setSelectMode] = useState<CalendarView>('day');
34
- const weeksInMonth = getWeeksInMonth(viewDate);
35
- const { onDayClick, onMonthClick, onYearClick } = useDateSelect({
36
- viewDate,
37
- setViewDate: (data) => setViewDate(data),
38
- onChange,
39
- setSelectMode,
40
- method,
41
- });
42
- const { disabled, onArrowClick } = useCalendarNav({
43
- method, selectMode, date: viewDate, setDate: setViewDate, min, max,
44
- });
45
-
46
- return (
47
- <div className={styles.calendar}>
48
- <div className={styles.calendar__close}>
49
- {onClose
50
- && (
51
- <CloseIcon onClick={onClose} />
52
- )}
53
- </div>
54
- {/* 일/월/년 선택 버튼 */}
55
- <div className={styles.view}>
56
- <div className={cn({
57
- [styles.view__block]: true,
58
- [styles['view__block--second']]: method === 'month',
59
- [styles['view__block--last']]: method === 'year',
60
- })}
61
- />
62
- <button
63
- className={cn({
64
- [styles.view__selector]: true,
65
- [styles['view__selector--selected']]: method === 'day',
66
- })}
67
- type="button"
68
- onClick={() => { setMethod('day'); setSelectMode('day'); }}
69
- >일
70
- </button>
71
- <button
72
- className={cn({
73
- [styles.view__selector]: true,
74
- [styles['view__selector--selected']]: method === 'month',
75
- })}
76
- type="button"
77
- onClick={() => { setMethod('month'); setSelectMode('month'); }}
78
- >월
79
- </button>
80
- <button
81
- className={cn({
82
- [styles.view__selector]: true,
83
- [styles['view__selector--selected']]: method === 'year',
84
- })}
85
- type="button"
86
- onClick={() => { setMethod('year'); setSelectMode('year'); }}
87
- >년
88
- </button>
89
- </div>
90
-
91
- <div className={styles.nav}>
92
- <button
93
- className={styles.nav__button}
94
- type="button"
95
- onClick={() => onArrowClick('prev')}
96
- disabled={disabled('prev')}
97
- >
98
- ◀︎
99
- </button>
100
- <div className={styles.nav__label}>
101
- {method === 'year' && '연도 선택'}
102
- {method !== 'year' && (
103
- <button
104
- className={cn({
105
- [styles['nav__label--date']]: true,
106
- [styles['nav__label--date-selected']]: selectMode === 'year',
107
- })}
108
- type="button"
109
- onClick={() => setSelectMode('year')}
110
- >
111
- {`${viewDate.getFullYear()}년`}<DropIcon />
112
- </button>
113
- )}
114
- {method === 'day' && (
115
- <button
116
- className={cn({
117
- [styles['nav__label--date']]: true,
118
- [styles['nav__label--date-selected']]: selectMode === 'month',
119
- })}
120
- type="button"
121
- onClick={() => setSelectMode('month')}
122
- >
123
- {`${viewDate.getMonth() + 1}월`}<DropIcon />
124
- </button>
125
- )}
126
- </div>
127
- <button
128
- className={styles.nav__button}
129
- type="button"
130
- onClick={() => onArrowClick('next')}
131
- disabled={disabled('next')}
132
- >►
133
- </button>
134
- </div>
135
-
136
- {(method === 'day' && selectMode === 'day') && (
137
- <DayTile
138
- selectedDate={selectedDate}
139
- weeksInMonth={weeksInMonth}
140
- // selectRange={selectRange}
141
- // selectedRange={selectedRange}
142
- handleDayClick={onDayClick}
143
- tileContent={() => (tileContent ? tileContent(selectedDate, method) : null)}
144
- />
145
- )}
146
-
147
- {((method === 'month' || selectMode === 'month') && selectMode !== 'year') && (
148
- <MonthTile
149
- selectedDate={selectedDate}
150
- viewDate={viewDate}
151
- handleMonthClick={onMonthClick}
152
- tileContent={tileContent}
153
-
154
- />
155
- )}
156
-
157
- {(method === 'year' || selectMode === 'year') && (
158
- <YearTile
159
- selectedDate={selectedDate}
160
- onClick={onYearClick}
161
- tileContent={tileContent}
162
- />
163
- )}
164
- </div>
165
- );
166
- }
@@ -1,45 +0,0 @@
1
- const getWeeksInMonth = (viewDate:Date) => {
2
- const startOfMonth = new Date(viewDate.getFullYear(), viewDate.getMonth(), 1);
3
- const endOfMonth = new Date(viewDate.getFullYear(), viewDate.getMonth() + 1, 0);
4
- const weeks = [];
5
- let currentWeek = [];
6
-
7
- const startDayOfWeek = startOfMonth.getDay();
8
- if (startDayOfWeek !== 0) {
9
- const prevMonthEnd = new Date(startOfMonth);
10
- prevMonthEnd.setDate(0);
11
- for (let i = startDayOfWeek - 1; i >= 0; i -= 1) {
12
- const prevDate = new Date(prevMonthEnd);
13
- prevDate.setDate(prevMonthEnd.getDate() - i);
14
- currentWeek.push({ thisMonth: false, date: prevDate });
15
- }
16
- }
17
-
18
- const currentDate = new Date(startOfMonth);
19
-
20
- while (currentDate <= endOfMonth) {
21
- currentWeek.push({ thisMonth: true, date: new Date(currentDate) });
22
- if (currentDate.getDay() === 6) {
23
- weeks.push(currentWeek);
24
- currentWeek = [];
25
- }
26
- currentDate.setDate(currentDate.getDate() + 1);
27
- }
28
-
29
- const endDayOfWeek = endOfMonth.getDay();
30
- if (endDayOfWeek !== 6) {
31
- for (let i = 1; i <= 6 - endDayOfWeek; i += 1) {
32
- const nextDate = new Date(endOfMonth);
33
- nextDate.setDate(endOfMonth.getDate() + i);
34
- currentWeek.push({ thisMonth: false, date: nextDate });
35
- }
36
- }
37
-
38
- if (currentWeek.length > 0) {
39
- weeks.push(currentWeek);
40
- }
41
-
42
- return weeks;
43
- };
44
-
45
- export default getWeeksInMonth;
@@ -1,8 +0,0 @@
1
- import { CalendarRange } from '../type';
2
-
3
- const isInRange = (day: Date, range:CalendarRange) => {
4
- if (!range.start || !range.end) return false;
5
- return day > range.start && day < range.end;
6
- };
7
-
8
- export default isInRange;
@@ -1,21 +0,0 @@
1
- import { CalendarView } from '../type';
2
-
3
- const isSameDay = (date1: Date | null, date2: Date | null, view: CalendarView = 'day'): boolean => {
4
- if (date1 === null || date2 === null) return false;
5
-
6
- switch (view) {
7
- case 'day':
8
- return date1.getFullYear() === date2.getFullYear()
9
- && date1.getMonth() === date2.getMonth()
10
- && date1.getDate() === date2.getDate();
11
- case 'month':
12
- return date1.getFullYear() === date2.getFullYear()
13
- && date1.getMonth() === date2.getMonth();
14
- case 'year':
15
- return date1.getFullYear() === date2.getFullYear();
16
- default:
17
- return false;
18
- }
19
- };
20
-
21
- export default isSameDay;
@@ -1,16 +0,0 @@
1
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
2
-
3
- <!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
4
- <svg width="64px" height="64px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke="#000000" fill="#000000" stroke-width="0.696">
5
-
6
- <g id="SVGRepo_bgCarrier" stroke-width="0"/>
7
-
8
- <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>
9
-
10
- <g id="SVGRepo_iconCarrier">
11
-
12
- <path fill-rule="evenodd" clip-rule="evenodd" d="M19.207 6.207a1 1 0 0 0-1.414-1.414L12 10.586 6.207 4.793a1 1 0 0 0-1.414 1.414L10.586 12l-5.793 5.793a1 1 0 1 0 1.414 1.414L12 13.414l5.793 5.793a1 1 0 0 0 1.414-1.414L13.414 12l5.793-5.793z" />
13
-
14
- </g>
15
-
16
- </svg>
@@ -1,3 +0,0 @@
1
- <svg width="25" height="25" viewBox="0 0 20 20" fill="none" stroke="#2D2D2D" xmlns="http://www.w3.org/2000/svg">
2
- <path d="M5 7.5L10 13L15 7.5" stroke-width="1.4" stroke-linecap="round"/>
3
- </svg>
package/src/index.tsx DELETED
@@ -1,3 +0,0 @@
1
- import Calendar from './Calendar';
2
-
3
- export { Calendar };
@@ -1,22 +0,0 @@
1
- // 스크롤바 너비 14px 추가
2
- $pc: 1396px;
3
- $tablet: 1395px;
4
- $mobile: 774px;
5
-
6
- @mixin pc {
7
- @media (min-width: $pc) {
8
- @content;
9
- }
10
- }
11
-
12
- @mixin tablet {
13
- @media (max-width: $tablet) {
14
- @content;
15
- }
16
- }
17
-
18
- @mixin mobile {
19
- @media (max-width: $mobile) {
20
- @content;
21
- }
22
- }
package/src/svg.d.ts DELETED
@@ -1,6 +0,0 @@
1
- // svg를 ReactComponent처럼 사용하기 위해 선언
2
- declare module '*.svg' {
3
- import { HTMLAttributes } from 'react';
4
-
5
- export default React.Component<HTMLAttributes<HTMLDivElement>>;
6
- }
package/src/vite-env.d.ts DELETED
@@ -1 +0,0 @@
1
- /// <reference types="vite/client" />
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "composite": true,
5
- "baseUrl": "./src",
6
- "outDir": "dist",
7
- "rootDir": "./src",
8
- "jsx": "react-jsx",
9
- "emitDeclarationOnly": true,
10
- "types": ["node", "vite/client","vite-plugin-svgr/client"],
11
- },
12
- "include": ["./src", "./src/svg.d.ts"]
13
- }
package/vite.config.ts DELETED
@@ -1,58 +0,0 @@
1
- import { defineConfig } from 'vite'
2
- import react from '@vitejs/plugin-react-swc'
3
- import tsconfigPaths from 'vite-tsconfig-paths';
4
- import svgr from 'vite-plugin-svgr';
5
- import checker from 'vite-plugin-checker';
6
- import { resolve } from 'path'
7
- import dts from 'vite-plugin-dts'
8
- import sassDts from 'vite-plugin-sass-dts';
9
-
10
- // https://vitejs.dev/config/
11
- export default defineConfig({
12
- plugins: [
13
- react(),
14
- tsconfigPaths(),
15
- dts(),
16
- sassDts(),
17
- svgr({ include: '**/*.svg' }),
18
- checker({
19
- typescript: true,
20
- eslint: {
21
- lintCommand: 'eslint "./src/**/*.{ts,tsx}"',
22
- },
23
- overlay: {
24
- badgeStyle: 'width:fit-content;font-size:14px;',
25
- },
26
- }),
27
- ],
28
- css: {
29
- modules: {
30
- scopeBehaviour: 'local',
31
- generateScopedName: '[name]__[local]___[hash:base64:5]'
32
- },
33
- preprocessorOptions: {
34
- scss: {
35
- api:'modern-compiler'
36
- }
37
- }
38
- },
39
- build: {
40
- lib: {
41
- entry: resolve(__dirname, './src/index.tsx'),
42
- name:'index',
43
- fileName: 'index'
44
- },
45
- sourcemap: true,
46
- rollupOptions: {
47
- external: ['react', 'sass'],
48
- output: {
49
- assetFileNames:'style.css',
50
- globals: {
51
- react: 'React',
52
- sass: 'sass'
53
- },
54
- }
55
- },
56
- outDir: 'dist'
57
- }
58
- })