@yamada-ui/calendar
Version:
Yamada UI calendar component
1 lines • 5.35 kB
Source Map (JSON)
{"version":3,"sources":["../src/year-list.tsx"],"sourcesContent":["import type { ButtonProps } from \"@yamada-ui/button\"\nimport type { FC, HTMLUIProps } from \"@yamada-ui/core\"\nimport type { CalendarHeaderProps } from \"./calendar-header\"\nimport { Button } from \"@yamada-ui/button\"\nimport { ui } from \"@yamada-ui/core\"\nimport { cx, filterUndefined } from \"@yamada-ui/utils\"\nimport { CalendarHeader } from \"./calendar-header\"\nimport { getFormattedLabel } from \"./calendar-utils\"\nimport { useCalendarContext } from \"./use-calendar\"\nimport { useYearList } from \"./use-year-list\"\n\ninterface YearListOptions {\n /**\n * Props for calendar header element.\n */\n headerProps?: HTMLUIProps\n /**\n * Props for calendar year grid element.\n */\n yearGridProps?: HTMLUIProps\n /**\n * Props for calendar year button element.\n */\n yearProps?: { component?: FC<{ index: number; year: number }> } & ButtonProps\n}\n\nexport interface YearListProps\n extends HTMLUIProps,\n Omit<CalendarHeaderProps, \"index\" | \"label\">,\n YearListOptions {}\n\nexport const YearList: FC<YearListProps> = ({\n className,\n controlProps,\n headerProps,\n labelProps,\n nextProps,\n prevProps,\n yearGridProps,\n yearProps,\n ...rest\n}) => {\n const { locale, styles, yearFormat } = useCalendarContext()\n const { label, rangeYears, getButtonProps, getGridProps } = useYearList()\n\n const { component: customYear, ...computedYearProps } = yearProps ?? {}\n\n const w = rest.w ?? rest.width\n const minW = rest.minW ?? rest.minWidth\n const maxW = rest.maxW ?? rest.maxWidth\n const h = rest.h ?? rest.height\n const minH = rest.minH ?? rest.minHeight\n const maxH = rest.maxH ?? rest.maxHeight\n\n return (\n <ui.div __css={{ ...styles.content }} {...filterUndefined(rest)}>\n <CalendarHeader\n {...{\n ...headerProps,\n label,\n controlProps,\n labelProps,\n nextProps,\n prevProps,\n }}\n />\n\n <ui.div\n className={cx(\"ui-calendar__year-list\", className)}\n __css={{\n display: \"grid\",\n h: styles.content?.h ?? styles.content?.height,\n maxH: styles.content?.maxH ?? styles.content?.maxHeight,\n maxW: styles.content?.maxW ?? styles.content?.maxWidth,\n minH: styles.content?.minH ?? styles.content?.minHeight,\n minW: styles.content?.minW ?? styles.content?.minWidth,\n w: styles.content?.w ?? styles.content?.width,\n ...styles.year,\n }}\n {...getGridProps({\n ...filterUndefined({ h, maxH, maxW, minH, minW, w }),\n ...yearGridProps,\n })}\n >\n {rangeYears.map((year, index) => (\n <Button\n key={index}\n className=\"ui-calendar__year-list__button\"\n variant=\"ghost\"\n __css={{\n fontSize: undefined,\n fontWeight: \"normal\",\n h: \"auto\",\n minW: \"auto\",\n p: 0,\n ...styles.button,\n }}\n {...getButtonProps({ ...computedYearProps, index, value: year })}\n >\n {customYear\n ? customYear({ index, year })\n : getFormattedLabel(year, locale, yearFormat)}\n </Button>\n ))}\n </ui.div>\n </ui.div>\n )\n}\n\nYearList.displayName = \"YearList\"\nYearList.__ui__ = \"YearList\"\n"],"mappings":";;;;;;;;;;;;;;;AAGA,SAAS,cAAc;AACvB,SAAS,UAAU;AACnB,SAAS,IAAI,uBAAuB;AAkDhC,SACE,KADF;AAxBG,IAAM,WAA8B,CAAC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AAzCN;AA0CE,QAAM,EAAE,QAAQ,QAAQ,WAAW,IAAI,mBAAmB;AAC1D,QAAM,EAAE,OAAO,YAAY,gBAAgB,aAAa,IAAI,YAAY;AAExE,QAAM,EAAE,WAAW,YAAY,GAAG,kBAAkB,IAAI,gCAAa,CAAC;AAEtE,QAAM,KAAI,UAAK,MAAL,YAAU,KAAK;AACzB,QAAM,QAAO,UAAK,SAAL,YAAa,KAAK;AAC/B,QAAM,QAAO,UAAK,SAAL,YAAa,KAAK;AAC/B,QAAM,KAAI,UAAK,MAAL,YAAU,KAAK;AACzB,QAAM,QAAO,UAAK,SAAL,YAAa,KAAK;AAC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