-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
251 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { createItemsContext } from '@utils/createItemsContext'; | ||
import { createItemsContext } from '@utils/createItemsContext2'; | ||
|
||
const { getItems, getSetItemFn } = createItemsContext('anchor'); | ||
export const { useItems, withItemsContextProvider, ItemHandler } = | ||
createItemsContext(); | ||
|
||
export { getItems, getSetItemFn }; | ||
export * from '@utils/createItemsContext'; | ||
export * from '@utils/createItemsContext2'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { sveltify } from '@svelte-preprocess-react'; | ||
import React from 'react'; | ||
import type { AnchorLinkItemProps } from 'antd/es/anchor/Anchor'; | ||
|
||
import { ItemHandler, type ItemHandlerProps } from '../context'; | ||
|
||
export const AnchorItem = sveltify<AnchorLinkItemProps & ItemHandlerProps>( | ||
(props) => { | ||
return ( | ||
<> | ||
<ItemHandler<['default']> | ||
{...props} | ||
allowedSlots={['default']} | ||
itemChildren={(items) => { | ||
return items.default.length > 0 ? items.default : undefined; | ||
}} | ||
/> | ||
</> | ||
); | ||
} | ||
); | ||
|
||
export default AnchorItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,13 @@ | ||
import { sveltify } from '@svelte-preprocess-react'; | ||
import React, { useEffect, useRef } from 'react'; | ||
import React from 'react'; | ||
import { type Col as ACol, type GetProps } from 'antd'; | ||
import { isEqual } from 'lodash-es'; | ||
|
||
import { type Item, useItems } from '../context'; | ||
import { ItemHandler, type ItemHandlerProps } from '../context'; | ||
|
||
export const Col = sveltify< | ||
GetProps<typeof ACol> & { | ||
itemIndex: number; | ||
itemSlotKey?: string; | ||
itemElement?: HTMLElement; | ||
}, | ||
['children'] | ||
>(({ itemIndex, itemSlotKey, itemElement, slots, ...props }) => { | ||
const prevValueRef = useRef<Item>(); | ||
const { setItem } = useItems(); | ||
useEffect(() => { | ||
if (itemElement) { | ||
const value: Item = { | ||
el: itemElement, | ||
props, | ||
slots, | ||
}; | ||
if (!isEqual(prevValueRef.current, value)) { | ||
prevValueRef.current = value; | ||
setItem(itemSlotKey, itemIndex, value); | ||
} | ||
} | ||
}, [itemIndex, itemSlotKey, itemElement, props, setItem, slots]); | ||
return <span />; | ||
}); | ||
export const Col = sveltify<GetProps<typeof ACol> & ItemHandlerProps>( | ||
(props) => { | ||
return <ItemHandler {...props} />; | ||
} | ||
); | ||
|
||
export default Col; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { createItemsContext } from '@utils/createItemsContext2'; | ||
|
||
export const { withItemsContext, useItems } = createItemsContext(); | ||
export const { withItemsContextProvider, useItems, ItemHandler } = | ||
createItemsContext(); | ||
|
||
export * from '@utils/createItemsContext2'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.