@shoplflow/base 0.31.7 → 0.31.9

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.
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { motion, AnimatePresence, LayoutGroup, LazyMotion, domAnimation } from '
5
5
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
6
6
  import { createPortal } from 'react-dom';
7
7
  import { css } from '@emotion/react';
8
- import { useMergeRefs, noop, OutSideClick, useSelect, useParentElementClick, isNullOrUndefined } from '@shoplflow/utils';
8
+ import { useMergeRefs, noop, OutSideClick, useSelect, useParentElementClick, useOutsideClick, isNullOrUndefined } from '@shoplflow/utils';
9
9
  import Scrollbars from 'react-custom-scrollbars-2';
10
10
  import { FloatingPortal, autoUpdate, offset, autoPlacement } from '@floating-ui/react';
11
11
  export { arrow, flip, hide, inline, offset, shift, size } from '@floating-ui/react';
@@ -14,6 +14,11 @@ import * as ShoplAssets from '@shoplflow/shopl-assets';
14
14
  import { DownArrowSolidXsmallIcon, DownArrowIcon, FirstPageIcon, LeftArrowIcon, RightArrowIcon, EndPageIcon } from '@shoplflow/shopl-assets';
15
15
  import * as HadaAssets from '@shoplflow/hada-assets';
16
16
  import { flip, shift } from '@floating-ui/core';
17
+ import DatePicker2 from 'react-datepicker';
18
+ import 'react-datepicker/dist/react-datepicker.css';
19
+ import SimpleBarReact from 'simplebar-react';
20
+ import { ko } from 'date-fns/locale';
21
+ import { getISOWeek, getISOWeekYear, startOfMonth, endOfMonth, differenceInCalendarMonths, getISOWeeksInYear, differenceInCalendarISOWeeks, startOfISOWeek, addWeeks, endOfISOWeek } from 'date-fns';
17
22
 
18
23
  var __create = Object.create;
19
24
  var __defProp = Object.defineProperty;
@@ -3133,7 +3138,7 @@ var Input = forwardRef(
3133
3138
  };
3134
3139
  const handleOnBlur = (event) => {
3135
3140
  onBlur && onBlur(event);
3136
- !isHovered && setIsFocused(false);
3141
+ setIsFocused(false);
3137
3142
  };
3138
3143
  const handleOnChange = (event) => {
3139
3144
  onChange && onChange(event);
@@ -4164,6 +4169,1491 @@ var ToggleButtonSizeVariants = {
4164
4169
  S: "S",
4165
4170
  M: "M"
4166
4171
  };
4172
+ var SmallStyledDayDatepickerWrapper = styled6.div`
4173
+ display: flex;
4174
+ width: 280px;
4175
+ height: 100%;
4176
+ flex-direction: column;
4177
+
4178
+ & .dayDatepickerArea .react-datepicker {
4179
+ width: 100%;
4180
+ height: 100%;
4181
+ border: none;
4182
+ margin: 0;
4183
+ padding: 16px;
4184
+ box-sizing: border-box;
4185
+ font-family: 'Pretendard', 'Pretendard JP', sans-serif !important;
4186
+
4187
+ & .highlighted-sundays {
4188
+ color: ${colorTokens.red300};
4189
+ }
4190
+
4191
+ &__month-text--selected {
4192
+ color: #fff;
4193
+ }
4194
+
4195
+ &-popper {
4196
+ width: 432px;
4197
+ padding-top: 0;
4198
+ }
4199
+
4200
+ &__month-container {
4201
+ width: 100%;
4202
+ }
4203
+
4204
+ &__month {
4205
+ margin: 0;
4206
+ }
4207
+
4208
+ &__header {
4209
+ border: none;
4210
+ background-color: transparent;
4211
+ padding: 0;
4212
+ font-size: 14px;
4213
+ font-style: normal;
4214
+ line-height: 18px;
4215
+ }
4216
+
4217
+ &__month-wrapper {
4218
+ display: grid;
4219
+ grid-template-columns: 1fr 1fr 1fr 1fr;
4220
+ /* gap: 1.75rem; */
4221
+ }
4222
+
4223
+ &__month-text {
4224
+ display: flex;
4225
+ justify-content: center;
4226
+ align-items: center;
4227
+ width: 48px;
4228
+ height: 48px;
4229
+ border-radius: 50%;
4230
+ font-size: 16px;
4231
+ color: #333;
4232
+ font-weight: 400;
4233
+
4234
+ :hover {
4235
+ background-color: ${colorTokens.primary100};
4236
+ color: ${colorTokens.primary300};
4237
+ }
4238
+
4239
+ &--keyboard-selected {
4240
+ background-color: ${colorTokens.primary100};
4241
+ color: ${colorTokens.neutral700};
4242
+ }
4243
+
4244
+ &--selected:not(.react-datepicker--keyboard-selected) {
4245
+ background-color: ${colorTokens.primary300};
4246
+ color: ${colorTokens.neutral0};
4247
+ }
4248
+ }
4249
+
4250
+ &__week {
4251
+ width: 100%;
4252
+ display: flex;
4253
+ justify-content: space-between;
4254
+
4255
+ &:first-of-type {
4256
+ margin-top: 0;
4257
+ }
4258
+ }
4259
+
4260
+ &__day-names {
4261
+ width: 100%;
4262
+ height: 18px;
4263
+ margin: 8px 0 0;
4264
+ display: flex;
4265
+ justify-content: space-between;
4266
+ align-items: center;
4267
+ }
4268
+
4269
+ &__day-name {
4270
+ color: ${colorTokens.neutral400};
4271
+ width: 32px;
4272
+ margin: 0;
4273
+ font-size: 13px;
4274
+ font-weight: 500;
4275
+ line-height: 1rem;
4276
+
4277
+ :last-of-type {
4278
+ margin: 0;
4279
+ }
4280
+ }
4281
+
4282
+ &__day {
4283
+ width: 32px;
4284
+ height: 32px;
4285
+ display: flex;
4286
+ justify-content: center;
4287
+ align-items: center;
4288
+ line-height: 32px;
4289
+ color: ${colorTokens.neutral700};
4290
+ border-radius: 50%;
4291
+ font-size: 14px;
4292
+ font-weight: 500;
4293
+ margin: 0px;
4294
+
4295
+ &--keyboard-selected {
4296
+ background-color: transparent;
4297
+ }
4298
+
4299
+ &--outside-month {
4300
+ color: ${colorTokens.neutral400};
4301
+ }
4302
+
4303
+ &--today {
4304
+ color: ${colorTokens.primary300};
4305
+ font-weight: ${fontWeightTokens.fontWeightRegular};
4306
+ }
4307
+
4308
+ &--in-selecting-range:not(
4309
+ .react-datepicker__day--in-range,
4310
+ .react-datepicker__month-text--in-range,
4311
+ .react-datepicker__quarter-text--in-range,
4312
+ .react-datepicker__year-text--in-range,
4313
+ .react-datepicker__day--selecting-range-start
4314
+ ) {
4315
+ background-color: ${colorTokens.primary100};
4316
+ }
4317
+
4318
+ &--in-range {
4319
+ background-color: ${colorTokens.primary300};
4320
+ color: ${colorTokens.neutral0};
4321
+ position: relative;
4322
+
4323
+ &:not(.react-datepicker__day--range-start):not(.react-datepicker__day--range-end) {
4324
+ border-radius: 0;
4325
+ background-color: ${colorTokens.primary100};
4326
+ color: ${colorTokens.primary300};
4327
+ }
4328
+
4329
+ &:not(.react-datepicker__day--range-end):after {
4330
+ width: 4px;
4331
+ height: 100%;
4332
+ background-color: ${colorTokens.primary100};
4333
+ position: absolute;
4334
+ content: '';
4335
+ right: -4px;
4336
+ top: 0;
4337
+ z-index: 1;
4338
+ }
4339
+
4340
+ &.react-datepicker__day--range-start {
4341
+ width: 32px;
4342
+ height: 32px;
4343
+ background-color: ${colorTokens.primary100};
4344
+ margin-right: 0;
4345
+ box-sizing: border-box;
4346
+ border: unset;
4347
+ border-radius: 50% 0 0 50%;
4348
+ }
4349
+
4350
+ &.react-datepicker__day--range-end {
4351
+ width: 32px;
4352
+ height: 32px;
4353
+ background-color: ${colorTokens.primary100};
4354
+ box-sizing: border-box;
4355
+ border: unset;
4356
+ border-radius: 0 50% 50% 0;
4357
+ }
4358
+ &.react-datepicker__day--range-end.react-datepicker__day--range-start {
4359
+ width: 32px;
4360
+ height: 32px;
4361
+ background-color: ${colorTokens.primary100};
4362
+ box-sizing: border-box;
4363
+ border: unset;
4364
+ border-radius: 50%;
4365
+ }
4366
+ &.react-datepicker__day--range-start .each-day {
4367
+ width: 32px;
4368
+ height: 32px;
4369
+ background-color: ${colorTokens.primary300};
4370
+ border-radius: 100%;
4371
+ }
4372
+
4373
+ &.react-datepicker__day--range-end .each-day {
4374
+ width: 32px;
4375
+ height: 32px;
4376
+ background-color: ${colorTokens.primary300};
4377
+ border-radius: 100%;
4378
+ }
4379
+ }
4380
+
4381
+ &--selected {
4382
+ color: ${colorTokens.neutral0};
4383
+ background-color: ${colorTokens.primary300};
4384
+ }
4385
+
4386
+ &--highlighted {
4387
+ color: ${colorTokens.neutral0};
4388
+ background-color: ${colorTokens.primary300};
4389
+ }
4390
+
4391
+ &--disabled {
4392
+ cursor: not-allowed;
4393
+ opacity: 0.3;
4394
+ color: ${colorTokens.neutral700};
4395
+
4396
+ &.react-datepicker__day--keyboard-selected {
4397
+ background-color: ${colorTokens.neutral200};
4398
+ }
4399
+ &.react-datepicker__day--excluded {
4400
+ color: ${colorTokens.neutral0};
4401
+ }
4402
+ }
4403
+
4404
+ &:not(&--disabled):not(&--selected):not(&--highlighted):not(&--range-end):hover {
4405
+ color: ${colorTokens.primary300};
4406
+ background-color: ${colorTokens.primary100};
4407
+ display: flex;
4408
+ align-items: center;
4409
+ justify-content: center;
4410
+ }
4411
+ }
4412
+
4413
+ &__year {
4414
+ &-wrapper {
4415
+ justify-content: center;
4416
+ }
4417
+ }
4418
+ }
4419
+ `;
4420
+ var StyledDayDatepicker = styled6.div`
4421
+ display: flex;
4422
+ width: 100%;
4423
+ height: 100%;
4424
+ flex-direction: column;
4425
+
4426
+ & .dayDatepickerArea .react-datepicker {
4427
+ width: 100%;
4428
+ height: 100%;
4429
+ border: none;
4430
+ margin: 0;
4431
+ padding: 16px 30px 16px;
4432
+ box-sizing: border-box;
4433
+ font-family: 'Pretendard', 'Pretendard JP', sans-serif !important;
4434
+
4435
+ & .highlighted-sundays {
4436
+ color: ${colorTokens.red300};
4437
+ }
4438
+
4439
+ &__month-text--selected {
4440
+ color: #fff;
4441
+ }
4442
+
4443
+ &-popper {
4444
+ width: 432px;
4445
+ padding-top: 0;
4446
+ }
4447
+
4448
+ &__month-container {
4449
+ width: 100%;
4450
+ }
4451
+
4452
+ &__month {
4453
+ margin: 12px 0 0;
4454
+ }
4455
+
4456
+ &__header {
4457
+ border: none;
4458
+ background-color: transparent;
4459
+ padding: 0;
4460
+ }
4461
+
4462
+ &__month-wrapper {
4463
+ display: grid;
4464
+ grid-template-columns: 1fr 1fr 1fr 1fr;
4465
+ /* gap: 1.75rem; */
4466
+ }
4467
+
4468
+ &__month-text {
4469
+ display: flex;
4470
+ justify-content: center;
4471
+ align-items: center;
4472
+ width: 48px;
4473
+ height: 48px;
4474
+ border-radius: 50%;
4475
+ font-size: 16px;
4476
+ color: #333;
4477
+
4478
+ :hover {
4479
+ background-color: ${colorTokens.primary100};
4480
+ color: ${colorTokens.primary300};
4481
+ }
4482
+
4483
+ &--keyboard-selected {
4484
+ background-color: ${colorTokens.primary100};
4485
+ color: ${colorTokens.neutral700};
4486
+ }
4487
+
4488
+ &--selected:not(.react-datepicker--keyboard-selected) {
4489
+ background-color: ${colorTokens.primary300};
4490
+ color: ${colorTokens.neutral0};
4491
+ }
4492
+ }
4493
+
4494
+ &__week {
4495
+ margin-top: 8px;
4496
+
4497
+ &:first-of-type {
4498
+ margin-top: 0;
4499
+ }
4500
+ }
4501
+
4502
+ &__day-names {
4503
+ height: 18px;
4504
+ margin: 12px 0 0;
4505
+ }
4506
+
4507
+ &__day-name {
4508
+ width: 40px;
4509
+ margin: 0 10px 0 0;
4510
+ color: ${colorTokens.navy300};
4511
+ font-size: 13px;
4512
+ font-weight: 500;
4513
+ line-height: 1rem;
4514
+
4515
+ :last-of-type {
4516
+ margin: 0;
4517
+ }
4518
+ }
4519
+
4520
+ &__day {
4521
+ width: 40px;
4522
+ height: 40px;
4523
+ line-height: 40px;
4524
+ margin: 0 10px 0 0;
4525
+ color: ${colorTokens.neutral700};
4526
+ border-radius: 50%;
4527
+ font-size: 14px;
4528
+ font-weight: 500;
4529
+
4530
+ &--keyboard-selected {
4531
+ background-color: transparent;
4532
+ }
4533
+
4534
+ &--outside-month {
4535
+ color: ${colorTokens.neutral400};
4536
+ }
4537
+
4538
+ &--today {
4539
+ color: ${colorTokens.primary300};
4540
+ font-weight: ${fontWeightTokens.fontWeightRegular};
4541
+ }
4542
+
4543
+ &--in-selecting-range:not(
4544
+ .react-datepicker__day--in-range,
4545
+ .react-datepicker__month-text--in-range,
4546
+ .react-datepicker__quarter-text--in-range,
4547
+ .react-datepicker__year-text--in-range,
4548
+ .react-datepicker__day--selecting-range-start
4549
+ ) {
4550
+ background-color: ${colorTokens.primary100};
4551
+ }
4552
+
4553
+ &--in-range {
4554
+ background-color: ${colorTokens.primary300};
4555
+ color: ${colorTokens.neutral0};
4556
+ position: relative;
4557
+
4558
+ &:not(.react-datepicker__day--range-start):not(.react-datepicker__day--range-end) {
4559
+ border-radius: 0;
4560
+ background-color: ${colorTokens.primary100};
4561
+ color: ${colorTokens.primary300};
4562
+ }
4563
+
4564
+ &:not(.react-datepicker__day--range-end):not(.react-datepicker__day--range-start):after {
4565
+ width: 10px;
4566
+ height: 100%;
4567
+ background-color: ${colorTokens.primary100};
4568
+ position: absolute;
4569
+ content: '';
4570
+ right: -10px;
4571
+ top: 0;
4572
+ z-index: 1;
4573
+ }
4574
+
4575
+ &.react-datepicker__day--range-start {
4576
+ width: 50px;
4577
+ height: 40px;
4578
+ background-color: ${colorTokens.primary100};
4579
+ margin-right: 0;
4580
+ padding-right: 10px;
4581
+ box-sizing: border-box;
4582
+ border: unset;
4583
+ border-radius: 50% 0 0 50%;
4584
+ }
4585
+
4586
+ &.react-datepicker__day--range-end {
4587
+ width: 40px;
4588
+ height: 40px;
4589
+ background-color: ${colorTokens.primary100};
4590
+ box-sizing: border-box;
4591
+ border: unset;
4592
+ border-radius: 0 50% 50% 0;
4593
+ }
4594
+ &.react-datepicker__day--range-end.react-datepicker__day--range-start {
4595
+ width: 40px;
4596
+ height: 40px;
4597
+ background-color: ${colorTokens.primary100};
4598
+ box-sizing: border-box;
4599
+ border: unset;
4600
+ border-radius: 50%;
4601
+ margin-right: 10px;
4602
+ }
4603
+ &.react-datepicker__day--range-start .each-day {
4604
+ width: 40px;
4605
+ height: 40px;
4606
+ background-color: ${colorTokens.primary300};
4607
+ border-radius: 100%;
4608
+ }
4609
+
4610
+ &.react-datepicker__day--range-end .each-day {
4611
+ width: 40px;
4612
+ height: 40px;
4613
+ background-color: ${colorTokens.primary300};
4614
+ border-radius: 100%;
4615
+ }
4616
+ }
4617
+
4618
+ &--selected {
4619
+ color: ${colorTokens.neutral0};
4620
+ background-color: ${colorTokens.primary300};
4621
+ }
4622
+
4623
+ &--highlighted {
4624
+ color: ${colorTokens.neutral0};
4625
+ background-color: ${colorTokens.primary300};
4626
+ }
4627
+
4628
+ &--disabled {
4629
+ cursor: not-allowed;
4630
+ opacity: 0.3;
4631
+ color: ${colorTokens.neutral700};
4632
+
4633
+ &.react-datepicker__day--keyboard-selected {
4634
+ background-color: ${colorTokens.neutral200};
4635
+ }
4636
+ &.react-datepicker__day--excluded {
4637
+ color: ${colorTokens.neutral0};
4638
+ }
4639
+ }
4640
+
4641
+ &:not(&--disabled):not(&--selected):not(&--highlighted):not(&--range-end):hover {
4642
+ color: ${colorTokens.primary300};
4643
+ background-color: ${colorTokens.primary100};
4644
+ }
4645
+ }
4646
+
4647
+ &__year {
4648
+ &-wrapper {
4649
+ justify-content: center;
4650
+ }
4651
+ }
4652
+ }
4653
+ `;
4654
+ var Header = styled6.div`
4655
+ display: flex;
4656
+ justify-content: center;
4657
+ align-items: center;
4658
+ position: relative;
4659
+ width: 100%;
4660
+ height: 32px;
4661
+ gap: 8px;
4662
+ `;
4663
+ var Month = styled6.p`
4664
+ font-size: 18px;
4665
+ color: ${colorTokens.neutral700};
4666
+ cursor: pointer;
4667
+ `;
4668
+ var DatePickerWrapper = styled6.div`
4669
+ position: absolute;
4670
+ z-index: 10;
4671
+ top: 36px;
4672
+ border-radius: 16px;
4673
+ overflow: hidden;
4674
+ box-shadow: 0px 10px 30px 0px rgba(51, 51, 51, 0.2);
4675
+ height: fit-content;
4676
+ padding: 16px 24px 24px 24px;
4677
+ background-color: ${colorTokens.neutral0};
4678
+
4679
+ & .react-datepicker {
4680
+ padding: 0px !important;
4681
+
4682
+ &__header--custom {
4683
+ margin-bottom: 16px;
4684
+ }
4685
+
4686
+ &__month-wrapper {
4687
+ column-gap: 8px;
4688
+ margin-top: 8px;
4689
+ }
4690
+
4691
+ &__month-text--today {
4692
+ font-weight: ${fontWeightTokens.fontWeightRegular};
4693
+ }
4694
+ }
4695
+ `;
4696
+ styled6.div`
4697
+ display: flex;
4698
+ justify-content: center;
4699
+ align-items: center;
4700
+ position: relative;
4701
+ width: 100%;
4702
+ height: 32px;
4703
+ gap: 8px;
4704
+ `;
4705
+ styled6.p`
4706
+ font-size: 18px;
4707
+ color: ${colorTokens.neutral700};
4708
+ cursor: pointer;
4709
+ `;
4710
+ styled6.div`
4711
+ position: absolute;
4712
+ z-index: 10;
4713
+ top: 3rem;
4714
+
4715
+ border: 1px solid #eaeaea;
4716
+ box-shadow: 0px 10px 30px 0px rgba(51, 51, 51, 0.2);
4717
+ .react-datepicker {
4718
+ border: 1px solid #eaeaea;
4719
+ }
4720
+ `;
4721
+ var Container5 = styled6.div`
4722
+ border-radius: 4px;
4723
+ background-color: ${colorTokens.neutral0};
4724
+ box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.12);
4725
+ padding: 4px;
4726
+ z-index: 10;
4727
+ position: relative;
4728
+ top: 0px;
4729
+ left: 0px;
4730
+
4731
+ & .simplebar-placeholder {
4732
+ height: 0px !important;
4733
+ }
4734
+ `;
4735
+ var OptionList = styled6.ul`
4736
+ height: fit-content;
4737
+
4738
+ ${({ maxHeight }) => {
4739
+ if (maxHeight) {
4740
+ return `
4741
+ max-height: ${maxHeight};
4742
+ overflow: auto;
4743
+ overflow-y: scroll;
4744
+
4745
+ -ms-overflow-style: none; /* IE and Edge */
4746
+ scrollbar-width: none; /* Firefox */
4747
+
4748
+ &::-webkit-scrollbar {
4749
+ display: none; /* Chrome, Safari, Opera*/
4750
+ }
4751
+ `;
4752
+ }
4753
+ }}
4754
+ `;
4755
+ var OptionListItem = styled6.li`
4756
+ padding: 7px 8px;
4757
+ font-size: 14px;
4758
+ font-weight: 500;
4759
+ line-height: 18px;
4760
+ text-align: left;
4761
+ white-space: break-spaces;
4762
+ cursor: pointer;
4763
+ border-radius: 4px;
4764
+ background-color: ${({ isActive }) => isActive && colorTokens.primary300};
4765
+ color: ${({ isActive }) => isActive && colorTokens.neutral0};
4766
+
4767
+ &:hover {
4768
+ background-color: ${({ isActive }) => !isActive && colorTokens.neutral100};
4769
+ }
4770
+ `;
4771
+ var YearSelect = ({ optionList, className, parentClassName, activeValue, maxHeight, onClick }) => {
4772
+ const optionListRef = useRef([]);
4773
+ const parentRef = useRef(null);
4774
+ const [isAllRefMounted, setIsAllRefMounted] = useState(false);
4775
+ const [isOpened, setIsOpened] = useOutsideClick({
4776
+ selector: `.${parentClassName}` || ""
4777
+ });
4778
+ useEffect(() => {
4779
+ setIsOpened(isOpened);
4780
+ }, []);
4781
+ useEffect(() => {
4782
+ var _a, _b, _c, _d, _e, _f;
4783
+ if (!isAllRefMounted || !activeValue || !maxHeight) {
4784
+ return;
4785
+ }
4786
+ const selectedOptionIndex = optionList.findIndex((option) => (option == null ? void 0 : option.value) === activeValue);
4787
+ const heightPerOption = (_b = (_a = optionListRef.current[selectedOptionIndex]) == null ? void 0 : _a.offsetHeight) != null ? _b : 0;
4788
+ const parentHeight = (_e = (_d = (_c = optionListRef.current[selectedOptionIndex]) == null ? void 0 : _c.closest("ul")) == null ? void 0 : _d.clientHeight) != null ? _e : 0;
4789
+ if (heightPerOption * (selectedOptionIndex + 1) >= parentHeight) {
4790
+ (_f = parentRef.current) == null ? void 0 : _f.scrollTo({ top: heightPerOption * selectedOptionIndex });
4791
+ }
4792
+ }, [isAllRefMounted, activeValue, maxHeight]);
4793
+ return /* @__PURE__ */ jsx(Container5, { className: `${parentClassName} ${className}`, children: /* @__PURE__ */ jsx(OptionList, { ref: parentRef, maxHeight, children: /* @__PURE__ */ jsx(
4794
+ SimpleBarReact,
4795
+ {
4796
+ style: {
4797
+ maxHeight
4798
+ },
4799
+ placeholder: void 0,
4800
+ children: optionList == null ? void 0 : optionList.map((option, index) => /* @__PURE__ */ jsx(
4801
+ OptionListItem,
4802
+ {
4803
+ onClick: (event) => {
4804
+ event.stopPropagation();
4805
+ onClick(option);
4806
+ },
4807
+ isActive: activeValue === option.value,
4808
+ ref: (el) => {
4809
+ optionListRef.current[index] = el;
4810
+ index + 1 === optionList.length && setIsAllRefMounted(true);
4811
+ },
4812
+ children: option.label
4813
+ },
4814
+ option.value
4815
+ ))
4816
+ }
4817
+ ) }) });
4818
+ };
4819
+ var YearSelect_default = YearSelect;
4820
+ var YearStepper = ({
4821
+ date,
4822
+ decreaseYear,
4823
+ prevYearButtonDisabled,
4824
+ nextYearButtonDisabled,
4825
+ increaseYear,
4826
+ changeYear,
4827
+ minDate,
4828
+ maxDate
4829
+ }) => {
4830
+ const [isOpen, setIsOpen] = useOutsideClick({
4831
+ selector: ".react-datepicker-year-stepper"
4832
+ });
4833
+ const startYear = minDate ? minDate.getFullYear() : 2e3;
4834
+ const endYear = maxDate ? maxDate.getFullYear() : 2100;
4835
+ const OptionList2 = useMemo(
4836
+ () => Array.from({ length: endYear - startYear + 1 }).fill(0).map((_, index) => ({ value: startYear + index, label: `${startYear + index}` })),
4837
+ [startYear, endYear]
4838
+ );
4839
+ return /* @__PURE__ */ jsxs(Header, { className: "calendarHeader", children: [
4840
+ /* @__PURE__ */ jsx(
4841
+ IconButton_default,
4842
+ {
4843
+ styleVar: "GHOST",
4844
+ sizeVar: "S",
4845
+ onClick: decreaseYear,
4846
+ disabled: prevYearButtonDisabled || date.getFullYear() === startYear,
4847
+ children: /* @__PURE__ */ jsx(Icon_default, { iconSource: LeftArrowIcon, sizeVar: "XS", color: prevYearButtonDisabled ? "neutral200" : "neutral700" })
4848
+ }
4849
+ ),
4850
+ /* @__PURE__ */ jsxs(Popper_default, { placement: "bottom", middlewares: [flip(), shift({ padding: 5 })], children: [
4851
+ /* @__PURE__ */ jsx(Popper_default.Trigger, { isOpen, children: /* @__PURE__ */ jsx(
4852
+ Month,
4853
+ {
4854
+ className: "react-datepicker-year-stepper",
4855
+ onClick: (event) => {
4856
+ event.stopPropagation();
4857
+ setIsOpen((prev) => !prev);
4858
+ },
4859
+ children: /* @__PURE__ */ jsx(Text_default, { typography: "title1_700", children: `${date.getFullYear()}` })
4860
+ }
4861
+ ) }),
4862
+ /* @__PURE__ */ jsx(Popper_default.Portal, { children: /* @__PURE__ */ jsx(
4863
+ YearSelect_default,
4864
+ {
4865
+ className: "react-datepicker-year-stepper",
4866
+ optionList: OptionList2,
4867
+ onClick: ({ value }) => {
4868
+ changeYear(value);
4869
+ setIsOpen(false);
4870
+ },
4871
+ parentClassName: "react-datepicker-year-stepper",
4872
+ maxHeight: `200px`,
4873
+ activeValue: date.getFullYear()
4874
+ }
4875
+ ) })
4876
+ ] }),
4877
+ /* @__PURE__ */ jsx(
4878
+ IconButton_default,
4879
+ {
4880
+ styleVar: "GHOST",
4881
+ sizeVar: "S",
4882
+ onClick: increaseYear,
4883
+ disabled: nextYearButtonDisabled || date.getFullYear() === endYear,
4884
+ children: /* @__PURE__ */ jsx(Icon_default, { iconSource: RightArrowIcon, sizeVar: "XS", color: nextYearButtonDisabled ? "neutral200" : "neutral700" })
4885
+ }
4886
+ )
4887
+ ] });
4888
+ };
4889
+ var YearStepper_default = YearStepper;
4890
+ var MonthStepper = ({
4891
+ date,
4892
+ monthDate,
4893
+ decreaseMonth,
4894
+ increaseMonth,
4895
+ changeYear,
4896
+ changeMonth,
4897
+ minDate,
4898
+ maxDate,
4899
+ locale,
4900
+ sizeVar,
4901
+ prevMonthButtonDisabled,
4902
+ nextMonthButtonDisabled
4903
+ }) => {
4904
+ const [isOpen, setIsOpen] = useOutsideClick({
4905
+ selector: ".react-datepicker__header"
4906
+ });
4907
+ return /* @__PURE__ */ jsxs(Header, { className: "calendarHeader", children: [
4908
+ /* @__PURE__ */ jsx(IconButton_default, { styleVar: "GHOST", sizeVar: "S", onClick: decreaseMonth, disabled: prevMonthButtonDisabled, children: /* @__PURE__ */ jsx(Icon_default, { iconSource: LeftArrowIcon, sizeVar: "XS", color: prevMonthButtonDisabled ? "neutral200" : "neutral700" }) }),
4909
+ /* @__PURE__ */ jsx(
4910
+ Month,
4911
+ {
4912
+ className: "react-datepicker__header",
4913
+ onClick: () => {
4914
+ setIsOpen((prev) => !prev);
4915
+ },
4916
+ children: /* @__PURE__ */ jsx(Text_default, { typography: sizeVar === "M" ? "title1_700" : "body1_700", children: `${date.getFullYear()}.${monthDate.getMonth() + 1}` })
4917
+ }
4918
+ ),
4919
+ isOpen && /* @__PURE__ */ jsx(DatePickerWrapper, { children: /* @__PURE__ */ jsx("div", { className: "datepicker-header-wrapper", children: /* @__PURE__ */ jsx(
4920
+ DatePicker2,
4921
+ {
4922
+ className: "datepicker-custom-month",
4923
+ onChange: (date2) => {
4924
+ if (!date2) {
4925
+ return;
4926
+ }
4927
+ changeYear && changeYear(date2.getFullYear());
4928
+ changeMonth && changeMonth(date2.getMonth());
4929
+ setIsOpen(false);
4930
+ },
4931
+ inline: true,
4932
+ selectsEnd: true,
4933
+ dateFormat: "mm",
4934
+ selected: date,
4935
+ minDate,
4936
+ maxDate,
4937
+ locale: locale != null ? locale : ko,
4938
+ showMonthYearPicker: true,
4939
+ renderCustomHeader: (props) => /* @__PURE__ */ jsx(YearStepper_default, __spreadValues({}, props)),
4940
+ showFourColumnMonthYearPicker: true
4941
+ }
4942
+ ) }) }),
4943
+ /* @__PURE__ */ jsx(IconButton_default, { styleVar: "GHOST", sizeVar: "S", onClick: increaseMonth, disabled: nextMonthButtonDisabled, children: /* @__PURE__ */ jsx(Icon_default, { iconSource: RightArrowIcon, sizeVar: "XS", color: nextMonthButtonDisabled ? "neutral200" : "neutral700" }) })
4944
+ ] });
4945
+ };
4946
+ var MonthStepper_default = MonthStepper;
4947
+ var DayDatepicker = (_a) => {
4948
+ var _b = _a, { sizeVar, children, calendarType } = _b, rest = __objRest(_b, ["sizeVar", "children", "calendarType"]);
4949
+ const Wrapper2 = sizeVar === "S" ? SmallStyledDayDatepickerWrapper : StyledDayDatepicker;
4950
+ if (calendarType.type === "range") {
4951
+ return /* @__PURE__ */ jsx(Wrapper2, { "data-shoplflow": "DayDatepicker", children: /* @__PURE__ */ jsx("div", { className: "dayDatepickerArea", children: /* @__PURE__ */ jsx(
4952
+ DatePicker2,
4953
+ __spreadProps(__spreadValues({
4954
+ inline: true,
4955
+ renderCustomHeader: (props) => /* @__PURE__ */ jsx(MonthStepper_default, __spreadValues({ sizeVar: sizeVar || "M" }, props)),
4956
+ renderDayContents: (dayOfMonth) => {
4957
+ return /* @__PURE__ */ jsx("div", { className: "each-day", children: dayOfMonth });
4958
+ }
4959
+ }, rest), {
4960
+ selectsRange: true,
4961
+ selectsMultiple: void 0,
4962
+ onChange: calendarType.handleDayRangeChange,
4963
+ children
4964
+ })
4965
+ ) }) });
4966
+ }
4967
+ if (calendarType.type === "multiple") {
4968
+ return /* @__PURE__ */ jsx(Wrapper2, { "data-shoplflow": "DayDatepicker", children: /* @__PURE__ */ jsx("div", { className: "dayDatepickerArea", children: /* @__PURE__ */ jsx(
4969
+ DatePicker2,
4970
+ __spreadProps(__spreadValues({
4971
+ inline: true,
4972
+ renderCustomHeader: (props) => /* @__PURE__ */ jsx(MonthStepper_default, __spreadValues({ sizeVar: sizeVar || "M" }, props)),
4973
+ renderDayContents: (dayOfMonth) => {
4974
+ return /* @__PURE__ */ jsx("div", { className: "each-day", children: dayOfMonth });
4975
+ }
4976
+ }, rest), {
4977
+ selectsMultiple: true,
4978
+ onChange: calendarType.handleMutlipleDaysChange,
4979
+ children
4980
+ })
4981
+ ) }) });
4982
+ }
4983
+ return /* @__PURE__ */ jsx(Wrapper2, { "data-shoplflow": "DayDatepicker", children: /* @__PURE__ */ jsx("div", { className: "dayDatepickerArea", children: /* @__PURE__ */ jsx(
4984
+ DatePicker2,
4985
+ __spreadProps(__spreadValues({
4986
+ inline: true,
4987
+ renderCustomHeader: (props) => /* @__PURE__ */ jsx(MonthStepper_default, __spreadValues({ sizeVar: sizeVar || "M" }, props)),
4988
+ renderDayContents: (dayOfMonth) => {
4989
+ return /* @__PURE__ */ jsx("div", { className: "each-day", children: dayOfMonth });
4990
+ }
4991
+ }, rest), {
4992
+ onChange: calendarType.handleDayChange,
4993
+ children
4994
+ })
4995
+ ) }) });
4996
+ };
4997
+ var DayDatepicker_default = DayDatepicker;
4998
+
4999
+ // src/components/Datepickers/DayDatepicker/DayDatepicker.types.ts
5000
+ var DayDatepickerSizeVariants = {
5001
+ S: "S",
5002
+ M: "M"
5003
+ };
5004
+ var getEachDateStyle = (props) => {
5005
+ const { inRange, isStart, isEnd, disabled } = props;
5006
+ if (isStart || isEnd) {
5007
+ return css`
5008
+ background-color: ${colorTokens.primary300};
5009
+ color: ${colorTokens.neutral0};
5010
+ `;
5011
+ }
5012
+ if (inRange) {
5013
+ return css`
5014
+ background-color: ${colorTokens.primary100};
5015
+ color: ${colorTokens.neutral700};
5016
+ `;
5017
+ }
5018
+ if (disabled) {
5019
+ return css`
5020
+ color: ${colorTokens.neutral400};
5021
+ cursor: not-allowed;
5022
+ `;
5023
+ }
5024
+ return css`
5025
+ &:hover {
5026
+ background-color: ${colorTokens.primary100};
5027
+ }
5028
+ `;
5029
+ };
5030
+ var getEachMonthAreaStyle = (props) => {
5031
+ const { inRange, isStart, isEnd, isReady, disabled } = props;
5032
+ if (isStart && isReady) {
5033
+ return css`
5034
+ &::after {
5035
+ content: '';
5036
+ position: absolute;
5037
+ right: 0;
5038
+ top: 0;
5039
+ bottom: 0;
5040
+ width: 48px;
5041
+ background: ${colorTokens.primary100};
5042
+ }
5043
+ `;
5044
+ }
5045
+ if (isEnd && !isStart) {
5046
+ return css`
5047
+ &::after {
5048
+ content: '';
5049
+ position: absolute;
5050
+ left: 0;
5051
+ top: 0;
5052
+ bottom: 0;
5053
+ width: 48px;
5054
+ background: ${colorTokens.primary100};
5055
+ }
5056
+ `;
5057
+ }
5058
+ if (inRange) {
5059
+ return css`
5060
+ background-color: ${colorTokens.primary100};
5061
+ color: ${colorTokens.neutral700};
5062
+ `;
5063
+ }
5064
+ if (disabled) {
5065
+ return css`
5066
+ cursor: not-allowed;
5067
+ `;
5068
+ }
5069
+ };
5070
+ var MonthContainer = styled6.div`
5071
+ display: flex;
5072
+ flex-direction: column;
5073
+ width: 400px;
5074
+ max-width: 400px;
5075
+ gap: 16px;
5076
+ padding: 16px 24px 24px;
5077
+ `;
5078
+ var MonthArea = styled6.div`
5079
+ width: 100%;
5080
+ display: grid;
5081
+ grid-template-columns: repeat(4, 1fr);
5082
+ grid-row-gap: 16px;
5083
+ `;
5084
+ var EachMonthArea = styled6.div`
5085
+ width: 100%;
5086
+ height: 48px;
5087
+ display: flex;
5088
+ justify-content: center;
5089
+ align-items: center;
5090
+ position: relative;
5091
+
5092
+ ${(props) => getEachMonthAreaStyle(props)}
5093
+ `;
5094
+ var EachMonthDate = styled6.div`
5095
+ width: 48px;
5096
+ height: 48px;
5097
+ text-align: center;
5098
+ font-size: 14px;
5099
+ line-height: 48px;
5100
+ padding: 0;
5101
+ border-radius: 50%;
5102
+ cursor: pointer;
5103
+ position: absolute;
5104
+ z-index: 10;
5105
+
5106
+ ${(props) => getEachDateStyle(props)}
5107
+ `;
5108
+ var MonthDatepicker = ({
5109
+ handleMonthClick,
5110
+ initStartDate,
5111
+ initEndDate,
5112
+ minDate,
5113
+ maxDate,
5114
+ onlySingleMonth
5115
+ }) => {
5116
+ const [currentDate, setCurrentDate] = useState(initStartDate || /* @__PURE__ */ new Date());
5117
+ const [selectedStartMonthAndYear, setSelectedStartMonthAndYear] = useState(
5118
+ initStartDate ? [initStartDate.getMonth(), initStartDate.getFullYear()] : null
5119
+ );
5120
+ const [selectedEndMonthAndYear, setSelectedEndMonthAndYear] = useState(
5121
+ initEndDate ? [initEndDate.getMonth(), initEndDate.getFullYear()] : null
5122
+ );
5123
+ const Months = useMemo(() => {
5124
+ return Array.from({ length: 12 }).map((_, index) => index + 1);
5125
+ }, []);
5126
+ const clickMonth = (month, year) => {
5127
+ if (onlySingleMonth) {
5128
+ setSelectedStartMonthAndYear([month, year]);
5129
+ handleMonthClick({
5130
+ startDate: startOfMonth(new Date(year, month - 1)),
5131
+ endDate: endOfMonth(new Date(year, month - 1)),
5132
+ selectedMonthRange: 1
5133
+ });
5134
+ return;
5135
+ }
5136
+ if (!selectedStartMonthAndYear || selectedStartMonthAndYear && selectedEndMonthAndYear) {
5137
+ const startDate = startOfMonth(new Date(year, month - 1));
5138
+ const endDate = endOfMonth(new Date(year, month - 1));
5139
+ setSelectedStartMonthAndYear([month, year]);
5140
+ setSelectedEndMonthAndYear(null);
5141
+ handleMonthClick({
5142
+ startDate,
5143
+ endDate,
5144
+ // 현재 달 까지 포함
5145
+ selectedMonthRange: differenceInCalendarMonths(endDate, startDate) + 1
5146
+ });
5147
+ return;
5148
+ }
5149
+ if (selectedStartMonthAndYear && !selectedEndMonthAndYear) {
5150
+ const [selectedMonth, selectedYear] = selectedStartMonthAndYear;
5151
+ if (selectedYear > year || selectedYear === year && selectedMonth > month) {
5152
+ const startDate2 = startOfMonth(new Date(year, month - 1));
5153
+ const endDate2 = endOfMonth(new Date(selectedYear, selectedMonth - 1));
5154
+ setSelectedStartMonthAndYear([month, year]);
5155
+ setSelectedEndMonthAndYear([selectedMonth, selectedYear]);
5156
+ handleMonthClick({
5157
+ startDate: startDate2,
5158
+ endDate: endDate2,
5159
+ // 현재 달 까지 포함
5160
+ selectedMonthRange: differenceInCalendarMonths(endDate2, startDate2) + 1
5161
+ });
5162
+ return;
5163
+ }
5164
+ if (selectedMonth !== month || selectedYear !== year) {
5165
+ setSelectedEndMonthAndYear([month, year]);
5166
+ }
5167
+ const startDate = startOfMonth(new Date(selectedYear, selectedMonth - 1));
5168
+ const endDate = endOfMonth(new Date(year, month - 1));
5169
+ handleMonthClick({
5170
+ startDate,
5171
+ endDate,
5172
+ // 현재 달까지 포함
5173
+ selectedMonthRange: differenceInCalendarMonths(endDate, startDate) + 1
5174
+ });
5175
+ }
5176
+ };
5177
+ return /* @__PURE__ */ jsxs(MonthContainer, { "data-shoplflow": "MonthDatepicker", children: [
5178
+ /* @__PURE__ */ jsx(
5179
+ YearStepper_default,
5180
+ {
5181
+ date: currentDate,
5182
+ decreaseYear: () => {
5183
+ setCurrentDate(new Date(currentDate.getFullYear() - 1, currentDate.getMonth(), currentDate.getDate()));
5184
+ },
5185
+ minDate,
5186
+ maxDate,
5187
+ prevYearButtonDisabled: minDate ? minDate.getFullYear() === currentDate.getFullYear() : false,
5188
+ nextYearButtonDisabled: maxDate ? maxDate.getFullYear() === currentDate.getFullYear() : false,
5189
+ increaseYear: () => {
5190
+ setCurrentDate(new Date(currentDate.getFullYear() + 1, currentDate.getMonth(), currentDate.getDate()));
5191
+ },
5192
+ changeYear: (year) => {
5193
+ setCurrentDate(new Date(year, currentDate.getMonth(), currentDate.getDate()));
5194
+ }
5195
+ }
5196
+ ),
5197
+ /* @__PURE__ */ jsx(MonthArea, { children: Months.map((month) => {
5198
+ const currentYear = currentDate.getFullYear();
5199
+ const isStart = currentYear === (selectedStartMonthAndYear == null ? void 0 : selectedStartMonthAndYear[1]) && month === (selectedStartMonthAndYear == null ? void 0 : selectedStartMonthAndYear[0]);
5200
+ const isEnd = (selectedEndMonthAndYear == null ? void 0 : selectedEndMonthAndYear[1]) === currentYear && (selectedEndMonthAndYear == null ? void 0 : selectedEndMonthAndYear[0]) === month;
5201
+ const isReady = isStart && Boolean(selectedEndMonthAndYear);
5202
+ let inRange = false;
5203
+ let disabled = false;
5204
+ if (minDate) {
5205
+ const minMonth = minDate.getMonth() + 1;
5206
+ const minYear = minDate.getFullYear();
5207
+ if (currentYear < minYear) {
5208
+ disabled = true;
5209
+ }
5210
+ if (currentYear === minYear) {
5211
+ if (month <= minMonth) {
5212
+ disabled = true;
5213
+ }
5214
+ }
5215
+ }
5216
+ if (maxDate) {
5217
+ const maxMonth = maxDate.getMonth() + 1;
5218
+ const maxYear = maxDate.getFullYear();
5219
+ if (currentYear > maxYear) {
5220
+ disabled = true;
5221
+ }
5222
+ if (currentYear === maxYear) {
5223
+ if (month >= maxMonth) {
5224
+ disabled = true;
5225
+ }
5226
+ }
5227
+ }
5228
+ if (selectedStartMonthAndYear && selectedEndMonthAndYear) {
5229
+ const [startMonth, startYear] = selectedStartMonthAndYear;
5230
+ const [endMonth, endYear] = selectedEndMonthAndYear;
5231
+ if (currentYear > startYear && currentYear < endYear) {
5232
+ inRange = true;
5233
+ }
5234
+ if (currentYear === startYear && currentYear === endYear) {
5235
+ if (month >= startMonth && month <= endMonth) {
5236
+ inRange = true;
5237
+ }
5238
+ }
5239
+ if (currentYear === startYear && currentYear !== endYear) {
5240
+ if (month >= startMonth) {
5241
+ inRange = true;
5242
+ }
5243
+ }
5244
+ if (currentYear === endYear && currentYear !== startYear) {
5245
+ if (month <= endMonth) {
5246
+ inRange = true;
5247
+ }
5248
+ }
5249
+ }
5250
+ return /* @__PURE__ */ jsx(
5251
+ EachMonthArea,
5252
+ {
5253
+ inRange,
5254
+ isStart,
5255
+ isReady,
5256
+ isEnd,
5257
+ disabled,
5258
+ onClick: () => {
5259
+ if (disabled) {
5260
+ return;
5261
+ }
5262
+ clickMonth(month, currentDate.getFullYear());
5263
+ },
5264
+ children: /* @__PURE__ */ jsx(EachMonthDate, { inRange, isStart, isEnd, disabled, children: month })
5265
+ },
5266
+ month
5267
+ );
5268
+ }) })
5269
+ ] });
5270
+ };
5271
+ var MonthDatepicker_default = MonthDatepicker;
5272
+ var getEachDateStyle2 = (props) => {
5273
+ const { isSelected, disabled } = props;
5274
+ if (isSelected) {
5275
+ return css`
5276
+ background-color: ${colorTokens.primary300};
5277
+ color: ${colorTokens.neutral0};
5278
+ `;
5279
+ }
5280
+ if (disabled) {
5281
+ return css`
5282
+ color: ${colorTokens.neutral400};
5283
+ cursor: not-allowed;
5284
+ `;
5285
+ }
5286
+ return css`
5287
+ &:hover {
5288
+ background-color: ${colorTokens.primary100};
5289
+ }
5290
+ `;
5291
+ };
5292
+ var getEachYearAreaStyle = (props) => {
5293
+ const { disabled } = props;
5294
+ if (disabled) {
5295
+ return css`
5296
+ cursor: not-allowed;
5297
+ `;
5298
+ }
5299
+ };
5300
+ var YearContainer = styled6.div`
5301
+ display: flex;
5302
+ flex-direction: column;
5303
+ width: 400px;
5304
+ max-width: 400px;
5305
+ gap: 16px;
5306
+ padding: 16px 24px 24px;
5307
+ `;
5308
+ var YearArea = styled6.div`
5309
+ width: 100%;
5310
+ display: grid;
5311
+ grid-template-columns: repeat(4, 1fr);
5312
+ grid-row-gap: 16px;
5313
+ `;
5314
+ var EachYearArea = styled6.div`
5315
+ width: 100%;
5316
+ height: 48px;
5317
+ display: flex;
5318
+ justify-content: center;
5319
+ align-items: center;
5320
+ position: relative;
5321
+
5322
+ ${(props) => getEachYearAreaStyle(props)}
5323
+ `;
5324
+ var EachYearDate = styled6.div`
5325
+ width: 48px;
5326
+ height: 48px;
5327
+ text-align: center;
5328
+ font-size: 14px;
5329
+ line-height: 48px;
5330
+ padding: 0;
5331
+ border-radius: 50%;
5332
+ cursor: pointer;
5333
+ position: absolute;
5334
+ z-index: 10;
5335
+
5336
+ ${(props) => getEachDateStyle2(props)}
5337
+ `;
5338
+ var AnnualDatepicker = ({
5339
+ startYear = 2e3,
5340
+ endYear = 2100,
5341
+ currentYear,
5342
+ handleYearClick
5343
+ }) => {
5344
+ const [selectedYear, setSelectedYear] = useState(currentYear || (/* @__PURE__ */ new Date()).getFullYear());
5345
+ const Years = Array.from({ length: endYear - startYear + 1 }).map((_, index) => startYear + index);
5346
+ const clickYear = (year) => {
5347
+ setSelectedYear(year);
5348
+ handleYearClick(year);
5349
+ };
5350
+ return /* @__PURE__ */ jsx(YearContainer, { "data-shoplflow": "AnnualDatepicker", children: /* @__PURE__ */ jsx(YearArea, { children: Years.map((year) => {
5351
+ return /* @__PURE__ */ jsx(
5352
+ EachYearArea,
5353
+ {
5354
+ isSelected: selectedYear === year,
5355
+ onClick: () => {
5356
+ clickYear(year);
5357
+ },
5358
+ children: /* @__PURE__ */ jsx(EachYearDate, { isSelected: selectedYear === year, children: year })
5359
+ },
5360
+ year
5361
+ );
5362
+ }) }) });
5363
+ };
5364
+ var AnnualDatepicker_default = AnnualDatepicker;
5365
+ var getEachDateStyle3 = (props) => {
5366
+ const { inRange, isStart, isEnd, disabled } = props;
5367
+ if (isStart || isEnd) {
5368
+ return css`
5369
+ background-color: ${colorTokens.primary300};
5370
+ color: ${colorTokens.neutral0};
5371
+ `;
5372
+ }
5373
+ if (inRange) {
5374
+ return css`
5375
+ background-color: ${colorTokens.primary100};
5376
+ color: ${colorTokens.neutral700};
5377
+ `;
5378
+ }
5379
+ if (disabled) {
5380
+ return css`
5381
+ color: ${colorTokens.neutral400};
5382
+ cursor: not-allowed;
5383
+ `;
5384
+ }
5385
+ return css`
5386
+ &:hover {
5387
+ background-color: ${colorTokens.primary100};
5388
+ }
5389
+ `;
5390
+ };
5391
+ var getEachWeekAreaStyle = (props) => {
5392
+ const { inRange, isStart, isEnd, isReady, disabled } = props;
5393
+ if (isStart && isReady) {
5394
+ return css`
5395
+ &::after {
5396
+ content: '';
5397
+ position: absolute;
5398
+ right: 0;
5399
+ top: 0;
5400
+ bottom: 0;
5401
+ width: 24px;
5402
+ background: ${colorTokens.primary100};
5403
+ }
5404
+ `;
5405
+ }
5406
+ if (isEnd && !isStart) {
5407
+ return css`
5408
+ &::after {
5409
+ content: '';
5410
+ position: absolute;
5411
+ left: 0;
5412
+ top: 0;
5413
+ bottom: 0;
5414
+ width: 24px;
5415
+ background: ${colorTokens.primary100};
5416
+ }
5417
+ `;
5418
+ }
5419
+ if (inRange) {
5420
+ return css`
5421
+ background-color: ${colorTokens.primary100};
5422
+ color: ${colorTokens.neutral700};
5423
+ `;
5424
+ }
5425
+ if (disabled) {
5426
+ return css`
5427
+ cursor: not-allowed;
5428
+ `;
5429
+ }
5430
+ };
5431
+ var WeekContainer = styled6.div`
5432
+ display: flex;
5433
+ flex-direction: column;
5434
+ width: 400px;
5435
+ max-width: 400px;
5436
+ gap: 16px;
5437
+ padding: 16px 24px 24px;
5438
+ `;
5439
+ var WeekArea = styled6.div`
5440
+ width: 100%;
5441
+ display: grid;
5442
+ grid-template-columns: repeat(7, 1fr);
5443
+ grid-row-gap: 8px;
5444
+ `;
5445
+ var EachWeekArea = styled6.div`
5446
+ width: 100%;
5447
+ height: 48px;
5448
+ display: flex;
5449
+ justify-content: center;
5450
+ align-items: center;
5451
+ position: relative;
5452
+
5453
+ ${(props) => getEachWeekAreaStyle(props)}
5454
+ `;
5455
+ var EachWeekDate = styled6.div`
5456
+ width: 48px;
5457
+ height: 48px;
5458
+ text-align: center;
5459
+ font-size: 14px;
5460
+ line-height: 48px;
5461
+ padding: 0;
5462
+ border-radius: 50%;
5463
+ cursor: pointer;
5464
+ position: absolute;
5465
+ z-index: 10;
5466
+
5467
+ ${(props) => getEachDateStyle3(props)}
5468
+ `;
5469
+ function getWeeksInYear(year) {
5470
+ return getISOWeeksInYear(new Date(year, 5, 5));
5471
+ }
5472
+ var getStartOfISOWeek = (week, year) => {
5473
+ const januaryFourth = new Date(year, 0, 4);
5474
+ const firstWeekStart = startOfISOWeek(januaryFourth);
5475
+ const startOfWeek = addWeeks(firstWeekStart, week - 1);
5476
+ return startOfWeek;
5477
+ };
5478
+ var getEndOfISOWeek = (week, year) => {
5479
+ const januaryFourth = new Date(year, 0, 4);
5480
+ const firstWeekStart = startOfISOWeek(januaryFourth);
5481
+ const startOfWeek = addWeeks(firstWeekStart, week - 1);
5482
+ const endOfWeek = endOfISOWeek(startOfWeek);
5483
+ return endOfWeek;
5484
+ };
5485
+ var WeekDatepicker = ({
5486
+ handleWeekClick,
5487
+ initStartDate,
5488
+ initEndDate,
5489
+ minDate,
5490
+ maxDate,
5491
+ onlySingleWeek
5492
+ }) => {
5493
+ const year = (initStartDate == null ? void 0 : initStartDate.getFullYear()) || (/* @__PURE__ */ new Date()).getFullYear();
5494
+ const [currentDate, setCurrentDate] = useState(new Date(year, 5, 5));
5495
+ const [selectedStartWeekAndYear, setSelectedStartWeekAndYear] = useState(
5496
+ initStartDate ? [getISOWeek(initStartDate || /* @__PURE__ */ new Date()), getISOWeekYear(initStartDate || /* @__PURE__ */ new Date())] : null
5497
+ );
5498
+ const [selectedEndWeekAndYear, setSelectedEndWeekAndYear] = useState(
5499
+ initEndDate ? [getISOWeek(initEndDate || /* @__PURE__ */ new Date()), getISOWeekYear(initEndDate || /* @__PURE__ */ new Date())] : null
5500
+ );
5501
+ const selectedYear = currentDate.getFullYear();
5502
+ const Years = useMemo(() => {
5503
+ return Array.from({ length: getWeeksInYear(selectedYear) }).map((_, index) => {
5504
+ return String(index + 1).padStart(2, "0");
5505
+ });
5506
+ }, [selectedYear]);
5507
+ const clickWeek = (week, year2) => {
5508
+ if (onlySingleWeek || !selectedStartWeekAndYear || selectedStartWeekAndYear && selectedEndWeekAndYear) {
5509
+ setSelectedStartWeekAndYear([week, year2]);
5510
+ setSelectedEndWeekAndYear(null);
5511
+ handleWeekClick({
5512
+ startYear: year2,
5513
+ startWeek: week,
5514
+ startDate: getStartOfISOWeek(week, year2),
5515
+ endYear: year2,
5516
+ endWeek: week,
5517
+ endDate: getEndOfISOWeek(week, year2),
5518
+ selectedWeeksRange: 1
5519
+ });
5520
+ return;
5521
+ }
5522
+ if (selectedStartWeekAndYear && !selectedEndWeekAndYear) {
5523
+ const [selectedWeek, selectedYear2] = selectedStartWeekAndYear;
5524
+ if (selectedYear2 > year2 || selectedYear2 === year2 && selectedWeek > week) {
5525
+ const startDate2 = getStartOfISOWeek(week, year2);
5526
+ const endDate2 = getEndOfISOWeek(selectedWeek, selectedYear2);
5527
+ setSelectedStartWeekAndYear([week, year2]);
5528
+ setSelectedEndWeekAndYear([selectedWeek, selectedYear2]);
5529
+ handleWeekClick({
5530
+ startYear: year2,
5531
+ startWeek: week,
5532
+ startDate: startDate2,
5533
+ endYear: selectedYear2,
5534
+ endWeek: selectedWeek,
5535
+ endDate: endDate2,
5536
+ // 현재 주까지 포함
5537
+ selectedWeeksRange: differenceInCalendarISOWeeks(endDate2, startDate2) + 1
5538
+ });
5539
+ return;
5540
+ }
5541
+ if (selectedWeek !== week || selectedYear2 !== year2) {
5542
+ setSelectedEndWeekAndYear([week, year2]);
5543
+ }
5544
+ const startDate = getStartOfISOWeek(selectedWeek, selectedYear2);
5545
+ const endDate = getEndOfISOWeek(week, year2);
5546
+ handleWeekClick({
5547
+ startYear: selectedYear2,
5548
+ startWeek: selectedWeek,
5549
+ startDate,
5550
+ endYear: year2,
5551
+ endWeek: week,
5552
+ endDate,
5553
+ // 현재 주까지 포함
5554
+ selectedWeeksRange: differenceInCalendarISOWeeks(endDate, startDate) + 1
5555
+ });
5556
+ }
5557
+ };
5558
+ return /* @__PURE__ */ jsxs(WeekContainer, { children: [
5559
+ /* @__PURE__ */ jsx(
5560
+ YearStepper_default,
5561
+ {
5562
+ date: currentDate,
5563
+ decreaseYear: () => {
5564
+ setCurrentDate(new Date(currentDate.getFullYear() - 1, currentDate.getMonth(), currentDate.getDate()));
5565
+ },
5566
+ minDate,
5567
+ maxDate,
5568
+ prevYearButtonDisabled: minDate ? minDate.getFullYear() === currentDate.getFullYear() : false,
5569
+ nextYearButtonDisabled: maxDate ? maxDate.getFullYear() === currentDate.getFullYear() : false,
5570
+ increaseYear: () => {
5571
+ setCurrentDate(new Date(currentDate.getFullYear() + 1, currentDate.getMonth(), currentDate.getDate()));
5572
+ },
5573
+ changeYear: (year2) => {
5574
+ setCurrentDate(new Date(year2, currentDate.getMonth(), currentDate.getDate()));
5575
+ }
5576
+ }
5577
+ ),
5578
+ /* @__PURE__ */ jsx(WeekArea, { children: Years.map((each, index) => {
5579
+ const currentYear = currentDate.getFullYear();
5580
+ const currentWeek = Number(each);
5581
+ const isStart = currentYear === (selectedStartWeekAndYear == null ? void 0 : selectedStartWeekAndYear[1]) && currentWeek === (selectedStartWeekAndYear == null ? void 0 : selectedStartWeekAndYear[0]);
5582
+ const isEnd = (selectedEndWeekAndYear == null ? void 0 : selectedEndWeekAndYear[1]) === currentYear && (selectedEndWeekAndYear == null ? void 0 : selectedEndWeekAndYear[0]) === currentWeek;
5583
+ const isReady = isStart && Boolean(selectedEndWeekAndYear);
5584
+ let inRange = false;
5585
+ let disabled = false;
5586
+ if (minDate) {
5587
+ const minWeek = getISOWeek(minDate);
5588
+ const minYear = getISOWeekYear(minDate);
5589
+ if (currentYear < minYear) {
5590
+ disabled = true;
5591
+ }
5592
+ if (currentYear === minYear) {
5593
+ if (currentWeek <= minWeek) {
5594
+ disabled = true;
5595
+ }
5596
+ }
5597
+ }
5598
+ if (maxDate) {
5599
+ const maxWeek = getISOWeek(maxDate);
5600
+ const maxYear = getISOWeekYear(maxDate);
5601
+ if (currentYear > maxYear) {
5602
+ disabled = true;
5603
+ }
5604
+ if (currentYear === maxYear) {
5605
+ if (currentWeek >= maxWeek) {
5606
+ disabled = true;
5607
+ }
5608
+ }
5609
+ }
5610
+ if (selectedStartWeekAndYear && selectedEndWeekAndYear) {
5611
+ const [startWeek, startYear] = selectedStartWeekAndYear;
5612
+ const [endWeek, endYear] = selectedEndWeekAndYear;
5613
+ if (currentYear > startYear && currentYear < endYear) {
5614
+ inRange = true;
5615
+ }
5616
+ if (currentYear === startYear && currentYear === endYear) {
5617
+ if (currentWeek >= startWeek && currentWeek <= endWeek) {
5618
+ inRange = true;
5619
+ }
5620
+ }
5621
+ if (currentYear === startYear && currentYear !== endYear) {
5622
+ if (currentWeek >= startWeek) {
5623
+ inRange = true;
5624
+ }
5625
+ }
5626
+ if (currentYear === endYear && currentYear !== startYear) {
5627
+ if (currentWeek <= endWeek) {
5628
+ inRange = true;
5629
+ }
5630
+ }
5631
+ }
5632
+ return /* @__PURE__ */ jsx(
5633
+ EachWeekArea,
5634
+ {
5635
+ inRange,
5636
+ isStart,
5637
+ isReady,
5638
+ isEnd,
5639
+ disabled,
5640
+ onClick: () => {
5641
+ if (disabled) {
5642
+ return;
5643
+ }
5644
+ clickWeek(Number(each), currentDate.getFullYear());
5645
+ },
5646
+ children: /* @__PURE__ */ jsxs(EachWeekDate, { inRange, isStart, isEnd, disabled, children: [
5647
+ "W",
5648
+ each
5649
+ ] })
5650
+ },
5651
+ index
5652
+ );
5653
+ }) })
5654
+ ] });
5655
+ };
5656
+ var WeekDatepicker_default = WeekDatepicker;
4167
5657
  var SpaceMarginWrapper = styled6(motion.div)`
4168
5658
  position: relative;
4169
5659
  display: flex;
@@ -4218,6 +5708,6 @@ classnames/index.js:
4218
5708
  *)
4219
5709
  */
4220
5710
 
4221
- export { Avatar_default as Avatar, AvatarSizeVariants, Button_default as Button, ButtonSizeVariants, ButtonStyleVariants, CHECKBOX_SYMBOL_KEY, Callout_default as Callout, CalloutTypes, Checkbox_default as Checkbox, CheckboxStyleVariants, ChipButton_default as ChipButton, ChipButtonSizeVariants, ChipButtonStyleVariants, ChipToggle_default as ChipToggle, ChipToggleSizeVariants, ChipToggleStyleVariants, Dropdown_default as Dropdown, Icon_default as Icon, IconButton_default as IconButton, IconButtonSizeVariants, IconButtonStyleVariants, IconSizeVariants, Input_default as Input, InputButton_default as InputButton, List_default as List, MODAL_FOOTER_KEY, MODAL_HEADER_KEY, Menu_default as Menu, MenuSizeVariants, MinusButton_default as MinusButton, Modal, ModalContext, ModalHandlerContext, ModalPortal_default as ModalProvider, ModalSize, MotionStack, MotionStackContainer, Pagination_default as Pagination, Popper_default as Popper, PopperPortal, PopperTrigger, RADIO_SYMBOL_KEY, Radio_default as Radio, ScrollArea_default as ScrollArea, SelectInputButton_default as SelectInputButton, ShoplflowProvider_default as ShoplflowProvider, Stack_default as Stack, StackContainer_default as StackContainer, StyledIcon, StyledStack, StyledStackContainer, Switch_default as Switch, TREE_SYMBOL_KEY, TabSizeVariants, TabStyleVariants, Tabs_default as Tabs, TabsContext, Tag_default as Tag, TagSizeVariants, TagStyleVariants, Text_default as Text, Text2Rows, TextArea_default as TextArea, ToggleButton_default as ToggleButton, ToggleButtonSizeVariants, Tooltip_default as Tooltip, Tree_default as Tree, TreeItem, borderRadiusTokens, boxShadowTokens, colorTokens, fontWeightTokens, getDomain, spacingTokens, typographyTokens, useDomain, useHandleModal, useModalValue, useTabs };
5711
+ export { AnnualDatepicker_default as AnnualDatepicker, Avatar_default as Avatar, AvatarSizeVariants, Button_default as Button, ButtonSizeVariants, ButtonStyleVariants, CHECKBOX_SYMBOL_KEY, Callout_default as Callout, CalloutTypes, Checkbox_default as Checkbox, CheckboxStyleVariants, ChipButton_default as ChipButton, ChipButtonSizeVariants, ChipButtonStyleVariants, ChipToggle_default as ChipToggle, ChipToggleSizeVariants, ChipToggleStyleVariants, DayDatepicker_default as DayDatepicker, DayDatepickerSizeVariants, Dropdown_default as Dropdown, Icon_default as Icon, IconButton_default as IconButton, IconButtonSizeVariants, IconButtonStyleVariants, IconSizeVariants, Input_default as Input, InputButton_default as InputButton, List_default as List, MODAL_FOOTER_KEY, MODAL_HEADER_KEY, Menu_default as Menu, MenuSizeVariants, MinusButton_default as MinusButton, Modal, ModalContext, ModalHandlerContext, ModalPortal_default as ModalProvider, ModalSize, MonthDatepicker_default as MonthDatepicker, MotionStack, MotionStackContainer, Pagination_default as Pagination, Popper_default as Popper, PopperPortal, PopperTrigger, RADIO_SYMBOL_KEY, Radio_default as Radio, ScrollArea_default as ScrollArea, SelectInputButton_default as SelectInputButton, ShoplflowProvider_default as ShoplflowProvider, Stack_default as Stack, StackContainer_default as StackContainer, StyledIcon, StyledStack, StyledStackContainer, Switch_default as Switch, TREE_SYMBOL_KEY, TabSizeVariants, TabStyleVariants, Tabs_default as Tabs, TabsContext, Tag_default as Tag, TagSizeVariants, TagStyleVariants, Text_default as Text, Text2Rows, TextArea_default as TextArea, ToggleButton_default as ToggleButton, ToggleButtonSizeVariants, Tooltip_default as Tooltip, Tree_default as Tree, TreeItem, WeekDatepicker_default as WeekDatepicker, borderRadiusTokens, boxShadowTokens, colorTokens, fontWeightTokens, getDomain, spacingTokens, typographyTokens, useDomain, useHandleModal, useModalValue, useTabs };
4222
5712
  //# sourceMappingURL=out.js.map
4223
5713
  //# sourceMappingURL=index.js.map