repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
senritsu/micro-color-sudoku
src/machines/appMachine.ts
import { Machine, assign } from 'xstate'; import randomize from '../randomize' import puzzles from '../puzzles' interface SudokuContext { size: number, cells: number[], fixedCells: number[] } interface SudokuStateSchema { states: { menu: {}, puzzle: {}, result: {} } } interface StartEvent { ty...
senritsu/micro-color-sudoku
src/math.spec.ts
import { rotateLeft, rotateRight, mirrorHorizontally, mirrorVertically } from './math' describe('matrix rotation', () => { it('rotates 90 degrees left or 270 degrees right', () => { // 1 2 3 3 6 9 // 4 5 6 -> 2 5 8 // 7 8 9 1 4 7 const original = [1, 2, 3, 4, 5, 6, 7, 8, 9] const expected ...
senritsu/micro-color-sudoku
src/composition/layout.ts
import { Ref, computed } from 'vue' export interface Groups { rows: Ref<number[][]>, columns: Ref<number[][]>, blocks: Ref<number[][]> } interface GridPosition { gridRow: string, gridColumn: string } interface GridPositionFunction { (rowMajorIndex: number): GridPosition } interface GridPlacement { cel...
senritsu/micro-color-sudoku
src/composition/validation.ts
import { Ref, computed, watch } from 'vue' import { Groups } from './layout' function isFilled (group: number[]) { return group.every(x => x) } function hasError (group: number[]) { return group.some((x, i, arr) => x && (arr.indexOf(x) !== i)) } type ValidationResult = 'error' | 'correct' | 'incomplete' function...
senritsu/micro-color-sudoku
src/math.ts
<reponame>senritsu/micro-color-sudoku<filename>src/math.ts /** * Rotates a matrix to the left * @param original Square matrix, stored as a flat array in row-major order * @param steps How many multiples of 90 degrees to rotate */ export function rotateLeft(original: number[], steps: number = 1) { steps = steps % ...
senritsu/micro-color-sudoku
src/colors.ts
<reponame>senritsu/micro-color-sudoku<filename>src/colors.ts export default [ // empty cell '#EDEAE0', // 4x4 grid '#C41E3A', '#50C878', '#26619C', '#FFD300', // 9x9 grid '#9966CC', '#FF7A00', '#87CEFA', '#F400A1', '#2D383A' ]
senritsu/micro-color-sudoku
src/randomize.ts
import { rotateLeft, mirrorHorizontally, mirrorVertically } from './math' export default function (puzzle : number[]) { const numbers = Array.from({length: Math.sqrt(puzzle.length)}).map((_, i) => i + 1) const mapping = shuffled(numbers).reduce((map, n, i) => { map[i + 1] = n return map }, {} as { [key: ...
senritsu/micro-color-sudoku
src/composition/layout.spec.ts
import { squarePlacement } from './layout' describe('square grid placement', () => { it('places cells correctly on a 4x4 grid', () => { const placement = squarePlacement(4) // 1 0 2 0 // 0 3 0 0 // 0 0 0 4 // 0 0 5 0 expect(placement.cell(0)).toEqual({ gridRow: '1 / span 1', gridColumn: '1 /...
chadoh/what-is-blockchain
src/renderBlocks/animations.ts
<filename>src/renderBlocks/animations.ts export const animationLength = 350 export const openBlock = (block: HTMLElement): void => { // 1. duplicate the element, position above old element const clone = block.cloneNode(true) as HTMLElement const rect = block.getBoundingClientRect() let styles = ` position:...
chadoh/what-is-blockchain
src/renderIdenticons.ts
import blockies from "blockies-identicon" const identicons = {} export default (): void => { Array.from( document.querySelectorAll(`[data-behavior="identicon"]`) ).forEach((div: HTMLElement) => { const title = div.getAttribute("title") identicons[title] = identicons[title] || blockies.create({ seed: t...
chadoh/what-is-blockchain
src/renderBlocks/formatEth.test.ts
import formatEth from './formatEth'; test.each` input | output ${1} | ${"0.000"} ${1e15} | ${"0.001"} ${1e18} | ${"1"} ${2.187e17} | ${"0.219"} `("when given $input, returns $output", ({ input, output }) => { expect(formatEth(input)).toEqual(output) });
chadoh/what-is-blockchain
src/sendAsyncPromise.ts
<filename>src/sendAsyncPromise.ts // util to wrap `window.ethereum.sendAsync` in a Promise // TODO: find typedefs for Ethereum RPC return values export default function sendAsyncPromise(method: string, params: any[]): Promise<{result: any}> { return new Promise((resolve, reject) => { window.ethereum.sendAsync({ m...
chadoh/what-is-blockchain
src/main.ts
<reponame>chadoh/what-is-blockchain import blockies from "blockies-identicon" import { threeConsecutive, genesis } from "./exampleData" import renderBlocks from "./renderBlocks" import renderIdenticons from "./renderIdenticons" import send from "./sendAsyncPromise" import spacer from "./spacer" document.addEventListen...
chadoh/what-is-blockchain
src/exampleData.test.ts
import { threeConsecutive, genesis } from './exampleData'; describe("threeConsecutive", () => { test("should be an Array", () => { expect(Array.isArray(threeConsecutive)).toBe(true) }) test("should have three items", () => { expect(threeConsecutive.length).toBe(3) }); }); describe("genesis", () => { ...
chadoh/what-is-blockchain
src/renderBlocks/index.ts
import { openBlock, closeBlock, animationLength } from "./animations" import formatEth from "./formatEth" document.addEventListener("click", e => { const target = e.target as HTMLElement if (target.dataset.behavior === "open-block") { e.preventDefault() openBlock(target.closest(".block") as HTMLElement) ...
chadoh/what-is-blockchain
src/spacer.ts
// TODO: move styles to stylesheet; don't use p tag export default ` <div style="text-align: center"> <p style="display: inline-block; height: 1em; width: 1em; margin-right: .5em;"></p> <p style="display: inline-block; height: 1em; width: 1em; margin-right: .5em;"></p> <p style="display: inline-block; hei...
chadoh/what-is-blockchain
src/renderBlocks/formatEth.ts
export default function formatEth(amountInWei: number): string { const options = { style: "decimal", minimumFractionDigits: 3 } // if its a whole, eth amount, leave off the .000 if (amountInWei % 1e18 === 0) options.minimumFractionDigits = 0 const formatter = new Intl.NumberFormat("en-US", options) ...
YaroShkvorets/ant-design-vue
components/vc-picker/hooks/useTextValueMapping.ts
<reponame>YaroShkvorets/ant-design-vue<gh_stars>1000+ import type { ComputedRef, Ref } from 'vue'; import { ref, watch } from 'vue'; export default function useTextValueMapping({ valueTexts, onTextChange, }: { /** Must useMemo, to assume that `valueTexts` only match on the first change */ valueTexts: ComputedR...
YaroShkvorets/ant-design-vue
components/vc-picker/hooks/usePickerInput.ts
import type { ComputedRef, HTMLAttributes, Ref } from 'vue'; import { onBeforeUnmount, watchEffect, watch, ref, computed } from 'vue'; import type { FocusEventHandler } from '../../_util/EventInterface'; import KeyCode from '../../_util/KeyCode'; import { addGlobalMousedownEvent, getTargetFromEvent } from '../utils/uiU...
YaroShkvorets/ant-design-vue
plugin/md/utils/tsToJs.ts
import { transformSync } from '@babel/core'; import { CLIEngine } from 'eslint'; import path from 'path'; const engine = new CLIEngine({ fix: true, useEslintrc: false, baseConfig: require(path.join(process.cwd(), '.eslintrc.js')), }); const tsToJs = (content: string): string => { if (!content) { return ''; ...
YaroShkvorets/ant-design-vue
components/vc-mentions/src/KeywordTrigger.tsx
import PropTypes from '../../_util/vue-types'; import Trigger from '../../vc-trigger'; import DropdownMenu from './DropdownMenu'; import type { PropType } from 'vue'; import { computed, defineComponent } from 'vue'; import type { OptionProps } from './Option'; const BUILT_IN_PLACEMENTS = { bottomRight: { points:...
YaroShkvorets/ant-design-vue
components/config-provider/renderEmpty.tsx
<reponame>YaroShkvorets/ant-design-vue import type { VNodeChild } from 'vue'; import { inject } from 'vue'; import Empty from '../empty'; import { defaultConfigProvider } from '.'; export interface RenderEmptyProps { componentName?: string; } const RenderEmpty = (props: RenderEmptyProps) => { const configProvider...
YaroShkvorets/ant-design-vue
components/progress/progress.tsx
<gh_stars>1000+ import type { VNodeChild } from 'vue'; import { computed, defineComponent } from 'vue'; import initDefaultProps from '../_util/props-util/initDefaultProps'; import CloseOutlined from '@ant-design/icons-vue/CloseOutlined'; import CheckOutlined from '@ant-design/icons-vue/CheckOutlined'; import CheckCircl...
YaroShkvorets/ant-design-vue
components/vc-progress/src/Line.tsx
<gh_stars>1000+ import useRefs from '../../_util/hooks/useRefs'; import { computed, defineComponent } from 'vue'; import initDefaultProps from '../../_util/props-util/initDefaultProps'; import { useTransitionDuration, defaultProps } from './common'; import { propTypes } from './types'; export default defineComponent({...
YaroShkvorets/ant-design-vue
components/badge/utils.ts
<reponame>YaroShkvorets/ant-design-vue<filename>components/badge/utils.ts import { PresetColorTypes } from '../_util/colors'; export function isPresetColor(color?: string): boolean { return (PresetColorTypes as any[]).indexOf(color) !== -1; }
YaroShkvorets/ant-design-vue
components/card/Grid.tsx
import { defineComponent, computed } from 'vue'; import useConfigInject from '../_util/hooks/useConfigInject'; export default defineComponent({ name: 'ACardGrid', __ANT_CARD_GRID: true, props: { prefixCls: String, hoverable: { type: Boolean, default: true }, }, setup(props, { slots }) { const { p...
YaroShkvorets/ant-design-vue
components/breadcrumb/BreadcrumbSeparator.tsx
<reponame>YaroShkvorets/ant-design-vue import type { ExtractPropTypes } from 'vue'; import { defineComponent } from 'vue'; import PropTypes from '../_util/vue-types'; import { flattenChildren } from '../_util/props-util'; import useConfigInject from '../_util/hooks/useConfigInject'; const breadcrumbSeparatorProps = { ...
YaroShkvorets/ant-design-vue
components/skeleton/Avatar.tsx
import { computed, defineComponent } from 'vue'; import classNames from '../_util/classNames'; import PropTypes from '../_util/vue-types'; import { tuple } from '../_util/type'; import initDefaultProps from '../_util/props-util/initDefaultProps'; import useConfigInject from '../_util/hooks/useConfigInject'; import type...
YaroShkvorets/ant-design-vue
components/vc-tree-select/hooks/useKeyValueMap.ts
<filename>components/vc-tree-select/hooks/useKeyValueMap.ts import type { ComputedRef, Ref } from 'vue'; import { shallowRef, watchEffect } from 'vue'; import type { FlattenDataNode, Key, RawValueType } from '../interface'; /** * Return cached Key Value map with DataNode. * Only re-calculate when `flattenOptions` ch...
YaroShkvorets/ant-design-vue
components/vc-align/index.ts
// based on rc-align 4.0.9 import Align from './Align'; export default Align;
YaroShkvorets/ant-design-vue
components/_util/responsiveObserve.ts
export type Breakpoint = 'xxl' | 'xl' | 'lg' | 'md' | 'sm' | 'xs'; export type BreakpointMap = Record<Breakpoint, string>; export type ScreenMap = Partial<Record<Breakpoint, boolean>>; export type ScreenSizeMap = Partial<Record<Breakpoint, number>>; export const responsiveArray: Breakpoint[] = ['xxl', 'xl', 'lg', 'md'...
YaroShkvorets/ant-design-vue
components/date-picker/PickerTag.tsx
<reponame>YaroShkvorets/ant-design-vue import type { TagProps } from '../tag'; import Tag from '../tag'; export default function PickerTag(props: TagProps, { slots, attrs }) { return <Tag color="blue" {...props} {...attrs} v-slots={slots} />; }
YaroShkvorets/ant-design-vue
components/slider/index.tsx
import type { CSSProperties, VNodeTypes, PropType } from 'vue'; import { computed, ref, defineComponent } from 'vue'; import VcSlider from '../vc-slider/src/Slider'; import VcRange from '../vc-slider/src/Range'; import VcHandle from '../vc-slider/src/Handle'; import type { VueNode } from '../_util/type'; import { withI...
YaroShkvorets/ant-design-vue
components/vc-steps/index.ts
// base rc-steps 4.1.3 import Steps from './Steps'; import Step from './Step'; Steps.Step = Step; export { Step }; export default Steps;
YaroShkvorets/ant-design-vue
components/vc-table/FixedHolder/index.tsx
<reponame>YaroShkvorets/ant-design-vue<filename>components/vc-table/FixedHolder/index.tsx import type { HeaderProps } from '../Header/Header'; import ColGroup from '../ColGroup'; import type { ColumnsType, ColumnType, DefaultRecordType } from '../interface'; import type { Ref } from 'vue'; import { computed, define...
YaroShkvorets/ant-design-vue
typings/vue-tsx-shim.d.ts
<gh_stars>1000+ import 'vue'; type EventHandler = (...args: any[]) => void; declare module 'vue' { interface ComponentCustomProps { role?: string; tabindex?: number | string; // should be removed after Vue supported component events typing // see: https://github.com/vuejs/vue-next/issues/1553 //...
YaroShkvorets/ant-design-vue
components/vc-mentions/src/Mentions.tsx
import type { ExtractPropTypes } from 'vue'; import { toRef, watchEffect, defineComponent, provide, withDirectives, ref, reactive, onUpdated, nextTick, computed, } from 'vue'; import classNames from '../../_util/classNames'; import KeyCode from '../../_util/KeyCode'; import { initDefaultProps } from...
YaroShkvorets/ant-design-vue
components/calendar/dayjs.tsx
import generateConfig from '../vc-picker/generate/dayjs'; import { withInstall } from '../_util/type'; import type { CalendarProps } from './generateCalendar'; import generateCalendar from './generateCalendar'; const Calendar = generateCalendar(generateConfig); export type { CalendarProps }; export default withInstal...
YaroShkvorets/ant-design-vue
components/time-picker/locale/ga_IE.tsx
<filename>components/time-picker/locale/ga_IE.tsx import type { TimePickerLocale } from '../index'; const locale: TimePickerLocale = { placeholder: 'Roghnaigh am', rangePlaceholder: ['Am tosaigh', 'Am deiridh'], }; export default locale;
YaroShkvorets/ant-design-vue
components/typography/index.tsx
<reponame>YaroShkvorets/ant-design-vue import type { App, Plugin } from 'vue'; import Base from './Base'; import Link from './Link'; import Paragraph from './Paragraph'; import Text from './Text'; import Title from './Title'; import Typography from './Typography'; export type { TypographyProps } from './Typography'; ...
YaroShkvorets/ant-design-vue
components/_util/vue-types/index.ts
<gh_stars>1000+ import type { CSSProperties } from 'vue'; import type { VueTypeValidableDef, VueTypesInterface } from 'vue-types'; import { createTypes } from 'vue-types'; import type { VueNode } from '../type'; const PropTypes = createTypes({ func: undefined, bool: undefined, string: undefined, number: undefin...
YaroShkvorets/ant-design-vue
components/vc-table/context/ResizeContext.tsx
<filename>components/vc-table/context/ResizeContext.tsx import type { InjectionKey } from 'vue'; import { inject, provide } from 'vue'; import type { Key } from '../interface'; interface ResizeContextProps { onColumnResize: (columnKey: Key, width: number) => void; } export const ResizeContextKey: InjectionKey<Resiz...
YaroShkvorets/ant-design-vue
components/radio/interface.ts
<filename>components/radio/interface.ts import type { RadioProps } from './Radio'; import type { Ref } from 'vue'; export interface RadioChangeEventTarget extends RadioProps { checked: boolean; } export interface RadioChangeEvent { target: RadioChangeEventTarget; stopPropagation: () => void; preventDefault: ()...
YaroShkvorets/ant-design-vue
components/vc-table/sugar/ColumnGroup.tsx
<filename>components/vc-table/sugar/ColumnGroup.tsx import type { ColumnType } from '../interface'; import type { FunctionalComponent } from 'vue'; /* istanbul ignore next */ /** * This is a syntactic sugar for `columns` prop. * So HOC will not work on this. */ // eslint-disable-next-line @typescript-eslint/no-unuse...
YaroShkvorets/ant-design-vue
components/vc-tree-select/props.ts
<reponame>YaroShkvorets/ant-design-vue<gh_stars>1000+ import type { ExtractPropTypes, PropType } from 'vue'; import type { DataNode, ChangeEventExtra, DefaultValueType, FieldNames, FlattenDataNode, LabelValueType, LegacyDataNode, RawValueType, SimpleModeConfig, } from './interface'; import { selectBas...
YaroShkvorets/ant-design-vue
components/vc-pagination/index.ts
<filename>components/vc-pagination/index.ts<gh_stars>1000+ // based on rc-pagination 3.1.9 export { default } from './Pagination';
YaroShkvorets/ant-design-vue
components/vc-picker/PanelContext.tsx
<filename>components/vc-picker/PanelContext.tsx<gh_stars>1000+ import type { InjectionKey, Ref } from 'vue'; import { inject, provide } from 'vue'; import type { OnSelect, PanelMode } from './interface'; export type ContextOperationRefProps = { onKeydown?: (e: KeyboardEvent) => boolean; onClose?: () => void; }; e...
YaroShkvorets/ant-design-vue
components/vc-drawer/src/IDrawerPropTypes.ts
<reponame>YaroShkvorets/ant-design-vue import PropTypes from '../../_util/vue-types'; import type { PropType } from 'vue'; export type IPlacement = 'left' | 'top' | 'right' | 'bottom'; type ILevelMove = number | [number, number]; const props = () => ({ prefixCls: PropTypes.string, width: PropTypes.oneOfType([PropT...
YaroShkvorets/ant-design-vue
components/date-picker/index.tsx
import DatePicker from './dayjs'; export * from './dayjs'; export default DatePicker;
YaroShkvorets/ant-design-vue
components/time-picker/locale/sr_RS.tsx
import type { TimePickerLocale } from '../index'; const locale: TimePickerLocale = { placeholder: 'Izaberi vreme', rangePlaceholder: ['Vreme početka', 'Vreme završetka'], }; export default locale;
YaroShkvorets/ant-design-vue
components/vc-table/Body/BodyRow.tsx
import Cell from '../Cell'; import { getColumnsKey } from '../utils/valueUtil'; import type { CustomizeComponent, GetComponentProps, Key, GetRowKey } from '../interface'; import ExpandedRow from './ExpandedRow'; import { computed, defineComponent, ref, watchEffect } from 'vue'; import { useInjectTable } from '../contex...
YaroShkvorets/ant-design-vue
components/table/ColumnGroup.tsx
<reponame>YaroShkvorets/ant-design-vue<filename>components/table/ColumnGroup.tsx import { defineComponent } from 'vue'; import type { ColumnGroupProps } from '../vc-table/sugar/ColumnGroup'; export default defineComponent<ColumnGroupProps<any>>({ name: 'ATableColumnGroup', slots: ['title'], __ANT_TABLE_COLUMN_GR...
YaroShkvorets/ant-design-vue
components/date-picker/locale/nb_NO.tsx
import CalendarLocale from '../../vc-picker/locale/nb_NO'; import TimePickerLocale from '../../time-picker/locale/nb_NO'; import type { PickerLocale } from '../generatePicker'; // Merge into a locale object const locale: PickerLocale = { lang: { placeholder: 'Velg dato', yearPlaceholder: 'Velg år', quart...
YaroShkvorets/ant-design-vue
plugin/docs/vueToMarkdown.ts
import path from 'path'; import LRUCache from 'lru-cache'; import slash from 'slash'; import fetchCode from '../md/utils/fetchCode'; // eslint-disable-next-line @typescript-eslint/no-var-requires const debug = require('debug')('vitepress:md'); const cache = new LRUCache<string, MarkdownCompileResult>({ max: 1024 }); ...
YaroShkvorets/ant-design-vue
components/vc-tree/index.ts
<gh_stars>1000+ import type { TreeProps, TreeNodeProps } from './props'; import Tree from './Tree'; import TreeNode from './TreeNode'; export { TreeNode }; export type { TreeProps, TreeNodeProps }; export default Tree;
YaroShkvorets/ant-design-vue
components/vc-picker/panels/MonthPanel/MonthBody.tsx
import type { GenerateConfig } from '../../generate'; import type { Locale } from '../../interface'; import { formatValue, isSameMonth } from '../../utils/dateUtil'; import { useInjectRange } from '../../RangeContext'; import useCellClassName from '../../hooks/useCellClassName'; import PanelBody from '../PanelBody'; im...
YaroShkvorets/ant-design-vue
components/vc-drawer/src/DrawerWrapper.tsx
<reponame>YaroShkvorets/ant-design-vue import Child from './DrawerChild'; import { initDefaultProps } from '../../_util/props-util'; import { defineComponent, ref } from 'vue'; import { drawerProps } from './IDrawerPropTypes'; import PortalWrapper from '../../_util/PortalWrapper'; const DrawerWrapper = defineComponent...
YaroShkvorets/ant-design-vue
components/vc-pagination/locale/pl_PL.ts
<gh_stars>1000+ export default { // Options.jsx items_per_page: 'na stronę', jump_to: 'Idź do', jump_to_confirm: 'potwierdź', page: '', // Pagination.jsx prev_page: 'Poprzednia strona', next_page: 'Następna strona', prev_5: 'Poprzednie 5 stron', next_5: 'Następne 5 stron', prev_3: 'Poprzednie 3 s...
YaroShkvorets/ant-design-vue
components/_util/hooks/usePrefixCls.ts
<filename>components/_util/hooks/usePrefixCls.ts import type { ComputedRef } from 'vue'; import { computed, inject } from 'vue'; import { defaultConfigProvider } from '../../config-provider'; export default (name: string, props: Record<any, any>): ComputedRef<string> => { const configProvider = inject('configProvide...
YaroShkvorets/ant-design-vue
components/menu/src/SubMenuList.tsx
import classNames from '../../_util/classNames'; import type { FunctionalComponent } from 'vue'; import { useInjectMenu } from './hooks/useMenuContext'; const InternalSubMenuList: FunctionalComponent<any> = (_props, { slots, attrs }) => { const { prefixCls, mode } = useInjectMenu(); return ( <ul {...attrs...
YaroShkvorets/ant-design-vue
components/date-picker/locale/az_AZ.tsx
import CalendarLocale from '../../vc-picker/locale/az_AZ'; import TimePickerLocale from '../../time-picker/locale/az_AZ'; import type { PickerLocale } from '../generatePicker'; const locale: PickerLocale = { lang: { placeholder: 'Tarix seçin', rangePlaceholder: ['Başlama tarixi', 'Bitmə tarixi'], ...Cale...
YaroShkvorets/ant-design-vue
components/vc-picker/utils/miscUtil.ts
<filename>components/vc-picker/utils/miscUtil.ts<gh_stars>1000+ export function leftPad(str: string | number, length: number, fill = '0') { let current = String(str); while (current.length < length) { current = `${fill}${str}`; } return current; } export const tuple = <T extends string[]>(...args: T) => ar...
YaroShkvorets/ant-design-vue
components/skeleton/index.tsx
<gh_stars>1000+ import type { App, Plugin } from 'vue'; import Skeleton from './Skeleton'; import SkeletonButton from './Button'; import SkeletonInput from './Input'; import SkeletonImage from './Image'; import SkeletonAvatar from './Avatar'; export type { SkeletonProps } from './Skeleton'; export { skeletonProps } fr...
YaroShkvorets/ant-design-vue
components/vc-picker/panels/TimePanel/TimeUnitColumn.tsx
<gh_stars>1000+ import { scrollTo, waitElementReady } from '../../utils/uiUtil'; import { useInjectPanel } from '../../PanelContext'; import classNames from '../../../_util/classNames'; import { ref, onBeforeUnmount, watch, defineComponent, nextTick } from 'vue'; export type Unit = { label: any; value: number; d...
YaroShkvorets/ant-design-vue
components/tabs/src/hooks/useOffsets.ts
import type { Ref } from 'vue'; import { ref, watchEffect } from 'vue'; import type { TabSizeMap, TabOffsetMap, Tab, TabOffset } from '../interface'; const DEFAULT_SIZE = { width: 0, height: 0, left: 0, top: 0 }; export default function useOffsets( tabs: Ref<Tab[]>, tabSizes: Ref<TabSizeMap>, // holderScrollWid...
YaroShkvorets/ant-design-vue
site/src/SymbolKey.ts
export const GLOBAL_CONFIG = Symbol('globalConfig');
YaroShkvorets/ant-design-vue
components/table/index.tsx
import Table, { tableProps } from './Table'; import Column from './Column'; import ColumnGroup from './ColumnGroup'; import type { TableProps, TablePaginationConfig } from './Table'; import { defineComponent } from 'vue'; import type { App } from 'vue'; import { Summary, SummaryCell, SummaryRow } from '../vc-table'; im...
YaroShkvorets/ant-design-vue
components/col/index.ts
import { Col } from '../grid'; import { withInstall } from '../_util/type'; export type { ColProps } from '../grid'; export default withInstall(Col);
YaroShkvorets/ant-design-vue
components/table/util.ts
<reponame>YaroShkvorets/ant-design-vue import { camelize } from 'vue'; import { flattenChildren } from '../_util/props-util'; import type { ColumnType, ColumnsType, ColumnTitle, ColumnTitleProps, Key } from './interface'; export function getColumnKey<RecordType>(column: ColumnType<RecordType>, defaultKey: string): Key...
YaroShkvorets/ant-design-vue
components/table/hooks/useLazyKVMap.ts
<filename>components/table/hooks/useLazyKVMap.ts import type { Ref } from 'vue'; import { watch, shallowRef } from 'vue'; import type { Key, GetRowKey } from '../interface'; interface MapCache<RecordType> { kvMap?: Map<Key, RecordType>; } export default function useLazyKVMap<RecordType>( dataRef: Ref<readonly Rec...
YaroShkvorets/ant-design-vue
components/vc-pagination/locale/gl_ES.ts
<gh_stars>1000+ export default { // Options.jsx items_per_page: '/ páxina', jump_to: 'Ir a', jump_to_confirm: 'confirmar', page: '', // Pagination.jsx prev_page: 'Páxina anterior', next_page: 'Páxina seguinte', prev_5: '5 páxinas previas', next_5: '5 páxinas seguintes', prev_3: '3 páxinas previas...
YaroShkvorets/ant-design-vue
components/vc-overflow/context.ts
import type { ComputedRef, InjectionKey, PropType } from 'vue'; import { computed, defineComponent, inject, provide } from 'vue'; import type { Key } from '../_util/type'; export interface OverflowContextProviderValueType { prefixCls: string; responsive: boolean; order: number; registerSize: (key: Key, width: ...
YaroShkvorets/ant-design-vue
components/vc-picker/RangeContext.tsx
<reponame>YaroShkvorets/ant-design-vue<filename>components/vc-picker/RangeContext.tsx import type { InjectionKey, PropType, Ref } from 'vue'; import { defineComponent, inject, provide, ref, toRef, watch } from 'vue'; import type { NullableDateType, RangeValue } from './interface'; export type RangeContextProps = { /...
YaroShkvorets/ant-design-vue
components/vc-table/hooks/useSticky.ts
<gh_stars>1000+ import canUseDom from '../../_util/canUseDom'; import type { ComputedRef, Ref } from 'vue'; import { computed } from 'vue'; import type { TableSticky } from '../interface'; // fix ssr render const defaultContainer = canUseDom() ? window : null; /** Sticky header hooks */ export default function useSti...
YaroShkvorets/ant-design-vue
components/vc-resize-observer/index.tsx
// based on rc-resize-observer 1.0.0 import type { PropType } from 'vue'; import ResizeObserver from 'resize-observer-polyfill'; import { defineComponent, getCurrentInstance, onMounted, onUnmounted, onUpdated, reactive, watch, } from 'vue'; import { findDOMNode } from '../_util/props-util'; interface Res...
YaroShkvorets/ant-design-vue
components/date-picker/util.ts
<filename>components/date-picker/util.ts import type { PickerMode } from '../vc-picker/interface'; import type { PickerLocale } from './generatePicker'; export function getPlaceholder( picker: PickerMode | undefined, locale: PickerLocale, customizePlaceholder?: string, ): string { if (customizePlaceholder !== ...
YaroShkvorets/ant-design-vue
components/radio/Group.tsx
import { provide, nextTick, defineComponent, ref, watch } from 'vue'; import type { PropType, ExtractPropTypes } from 'vue'; import classNames from '../_util/classNames'; import PropTypes from '../_util/vue-types'; import Radio from './Radio'; import useConfigInject from '../_util/hooks/useConfigInject'; import { tuple...
YaroShkvorets/ant-design-vue
components/transfer/ListBody.tsx
<gh_stars>1000+ import type { ExtractPropTypes } from 'vue'; import { defineComponent, computed, ref, watch } from 'vue'; import classNames from '../_util/classNames'; import ListItem from './ListItem'; import Pagination from '../pagination'; import PropTypes from '../_util/vue-types'; import type { TransferItem } from...
YaroShkvorets/ant-design-vue
components/vc-virtual-list/hooks/useHeights.tsx
<reponame>YaroShkvorets/ant-design-vue import type { VNodeProps } from 'vue'; import { reactive } from 'vue'; import type { GetKey } from '../interface'; type CacheMap = Record<string, number>; export default function useHeights<T>( getKey: GetKey<T>, onItemAdd?: ((item: T) => void) | null, onItemRemove?: ((ite...
YaroShkvorets/ant-design-vue
components/_util/hooks/useFlexGapSupport.ts
<gh_stars>1000+ import { onMounted, ref } from 'vue'; import { detectFlexGapSupported } from '../styleChecker'; export default () => { const flexible = ref(false); onMounted(() => { flexible.value = detectFlexGapSupported(); }); return flexible; };
YaroShkvorets/ant-design-vue
site/src/typings.d.ts
interface Window { docsearch: any; notBlockEnabled: any; } interface Header { level: number; title: string; slug: string; content: string; } interface PageData { title: string; description: string; headers: Header[]; frontmatter: Record<string, any>; } declare module '*.md' { import type { Define...
YaroShkvorets/ant-design-vue
components/vc-pagination/locale/ja_JP.ts
export default { // Options.jsx items_per_page: '件 / ページ', jump_to: '移動', jump_to_confirm: '確認する', page: 'ページ', // Pagination.jsx prev_page: '前のページ', next_page: '次のページ', prev_5: '前 5ページ', next_5: '次 5ページ', prev_3: '前 3ページ', next_3: '次 3ページ', };
YaroShkvorets/ant-design-vue
components/vc-slider/src/common/Steps.tsx
import type { CSSProperties } from 'vue'; import classNames from '../../../_util/classNames'; import type { VueNode } from '../../../_util/type'; import warning from '../../../_util/warning'; const calcPoints = ( _vertical: boolean, marks: Record<number, VueNode | { style?: CSSProperties; label?: string }>, dots...
YaroShkvorets/ant-design-vue
components/progress/Circle.tsx
<reponame>YaroShkvorets/ant-design-vue import type { CSSProperties } from 'vue'; import { computed, defineComponent } from 'vue'; import { presetPrimaryColors } from '@ant-design/colors'; import { Circle as VCCircle } from '../vc-progress'; import { getSuccessPercent, validProgress } from './utils'; import type { Progr...
YaroShkvorets/ant-design-vue
components/vc-table/context/TableContext.tsx
<reponame>YaroShkvorets/ant-design-vue import type { InjectionKey } from 'vue'; import { inject, provide } from 'vue'; import type { GetComponent, TransformCellText } from '../interface'; import type { FixedInfo } from '../utils/fixUtil'; export interface TableContextProps { // Table context prefixCls: string; ...
YaroShkvorets/ant-design-vue
components/divider/index.tsx
import { flattenChildren } from '../_util/props-util'; import type { ExtractPropTypes, PropType } from 'vue'; import { computed, defineComponent, inject } from 'vue'; import { defaultConfigProvider } from '../config-provider'; import { withInstall } from '../_util/type'; export const dividerProps = { prefixCls: Stri...
YaroShkvorets/ant-design-vue
components/vc-dropdown/Dropdown.tsx
import { computed, defineComponent, ref, watch } from 'vue'; import PropTypes from '../_util/vue-types'; import Trigger from '../vc-trigger'; import placements from './placements'; import { cloneElement } from '../_util/vnode'; import classNames from '../_util/classNames'; export default defineComponent({ props: { ...
YaroShkvorets/ant-design-vue
plugin/md/index.ts
import { createMarkdownToVueRenderFn } from './markdownToVue'; import type { MarkdownOptions } from './markdown/markdown'; import type { Plugin } from 'vite'; interface Options { root?: string; markdown?: MarkdownOptions; } export default (options: Options = {}): Plugin => { const { root, markdown } = options; ...
YaroShkvorets/ant-design-vue
components/vc-picker/utils/dateUtil.ts
import { DECADE_UNIT_DIFF } from '../panels/DecadePanel/index'; import type { PanelMode, NullableDateType, PickerMode, Locale, CustomFormat } from '../interface'; import type { GenerateConfig } from '../generate'; export const WEEK_DAY_COUNT = 7; export function isNullEqual<T>(value1: T, value2: T): boolean | undefin...
YaroShkvorets/ant-design-vue
components/grid/context.ts
import { computed, inject, provide } from 'vue'; import type { Ref, InjectionKey, ComputedRef } from 'vue'; export interface RowContext { gutter: ComputedRef<[number, number]>; wrap: ComputedRef<boolean>; supportFlexGap: Ref<boolean>; } export const RowContextKey: InjectionKey<RowContext> = Symbol('rowContextKe...
YaroShkvorets/ant-design-vue
components/vc-table/ColGroup.tsx
import type { ColumnType } from './interface'; import { INTERNAL_COL_DEFINE } from './utils/legacyUtil'; export interface ColGroupProps<RecordType> { colWidths: readonly (number | string)[]; columns?: readonly ColumnType<RecordType>[]; columCount?: number; } function ColGroup<RecordType>({ colWidths, columns, c...
YaroShkvorets/ant-design-vue
components/menu/src/Divider.tsx
<gh_stars>1000+ import { defineComponent } from 'vue'; import { useInjectMenu } from './hooks/useMenuContext'; export default defineComponent({ name: 'AMenuDivider', setup() { const { prefixCls } = useInjectMenu(); return () => { return <li class={`${prefixCls.value}-item-divider`} />; }; }, })...
YaroShkvorets/ant-design-vue
components/vc-select/Selector/index.tsx
/** * Cursor rule: * 1. Only `showSearch` enabled * 2. Only `open` is `true` * 3. When typing, set `open` to `true` which hit rule of 2 * * Accessibility: * - https://www.w3.org/TR/wai-aria-practices/examples/combobox/aria1.1pattern/listbox-combo.html */ import KeyCode from '../../_util/KeyCode'; import Multip...
YaroShkvorets/ant-design-vue
components/table/context.ts
<gh_stars>1-10 import type { ComputedRef, InjectionKey } from 'vue'; import { computed, inject, provide } from 'vue'; import type { ColumnType } from './interface'; export type ContextSlots = { emptyText?: (...args: any[]) => any; expandIcon?: (...args: any[]) => any; title?: (...args: any[]) => any; footer?: ...
YaroShkvorets/ant-design-vue
components/progress/Steps.tsx
<reponame>YaroShkvorets/ant-design-vue<gh_stars>1000+ import type { ExtractPropTypes, PropType, VNodeChild } from 'vue'; import { computed, defineComponent } from 'vue'; import PropTypes from '../_util/vue-types'; import type { ProgressSize } from './props'; import { progressProps } from './props'; const stepsProps = ...
YaroShkvorets/ant-design-vue
components/vc-picker/panels/DatetimePanel/index.tsx
import type { DatePanelProps } from '../DatePanel'; import DatePanel from '../DatePanel'; import type { SharedTimeProps } from '../TimePanel'; import TimePanel from '../TimePanel'; import { tuple } from '../../utils/miscUtil'; import { setDateTime as setTime } from '../../utils/timeUtil'; import type { PanelRefProps, D...
YaroShkvorets/ant-design-vue
components/_util/Portal.tsx
import PropTypes from './vue-types'; import { defineComponent, nextTick, onBeforeUnmount, onUpdated, Teleport } from 'vue'; export default defineComponent({ name: 'Portal', inheritAttrs: false, props: { getContainer: PropTypes.func.isRequired, didUpdate: PropTypes.func, }, setup(props, { slots }) { ...
YaroShkvorets/ant-design-vue
components/tree/utils/dropIndicator.tsx
import type { CSSProperties } from 'vue'; export const offset = 4; export default function dropIndicatorRender(props: { dropPosition: -1 | 0 | 1; dropLevelOffset: number; indent: number; prefixCls: string; direction: 'ltr' | 'rtl'; }) { const { dropPosition, dropLevelOffset, prefixCls, indent, direction =...
YaroShkvorets/ant-design-vue
components/_util/hooks/useBreakpoint.ts
import type { Ref } from 'vue'; import { onMounted, onUnmounted, ref } from 'vue'; import type { ScreenMap } from '../../_util/responsiveObserve'; import ResponsiveObserve from '../../_util/responsiveObserve'; function useBreakpoint(): Ref<ScreenMap> { const screens = ref<ScreenMap>({}); let token = null; onMou...
YaroShkvorets/ant-design-vue
components/skeleton/Image.tsx
<reponame>YaroShkvorets/ant-design-vue import { computed, defineComponent } from 'vue'; import classNames from '../_util/classNames'; import useConfigInject from '../_util/hooks/useConfigInject'; import type { SkeletonElementProps } from './Element'; import { skeletonElementProps } from './Element'; export type Skelet...