diff --git a/packages/react/components/Editor/swizzle/components/auth-wrapper.mjs b/packages/react/components/Editor/swizzle/components/auth-wrapper.mjs
deleted file mode 100644
index 26ff0ad6be6..00000000000
--- a/packages/react/components/Editor/swizzle/components/auth-wrapper.mjs
+++ /dev/null
@@ -1,210 +0,0 @@
-import { useState, useEffect } from 'react'
-
-export const AuthMessageWrapper = ({ children }) => (
-
{children}
-)
-
-export const ContactSupport = ({ t, Swizzled }) => (
-
-
- {t('contactSupport')}
-
-
-)
-
-export const AuthRequired = ({ t, banner, Swizzled }) => (
-
- {banner}
- {Swizzled.methods.t('pe:authRequired')}
- {t('pe:membersOnly')}
-
-
-
- {t('pe:signUp')}
-
-
-
- {t('signIn')}
-
-
-
-)
-
-export const AccountInactive = ({ t, banner, Swizzled }) => (
-
- {banner}
- {t('accountInactive')}
- {t('accountInactiveMsg')}
- {t('signupAgain')}
-
-
- {t('signUp')}
-
-
-
-)
-
-export const AccountDisabled = ({ t, banner, Swizzled }) => (
-
- {banner}
- {t('accountDisabled')}
- {t('accountDisabledMsg')}
-
-
-)
-
-export const AccountProhibited = ({ t, banner, Swizzled }) => (
-
- {banner}
- {t('accountProhibited')}
- {t('accountProhibitedMsg')}
-
-
-)
-
-export const AccountStatusUnknown = ({ t, banner, Swizzled }) => (
-
- {banner}
- {t('statusUnknown')}
- {t('statusUnknownMsg')}
-
-
-)
-
-export const RoleLacking = ({ t, requiredRole, role, banner, Swizzled }) => (
-
- {banner}
- {t('roleLacking')}
-
-
-
-)
-
-export const ConsentLacking = ({ banner, Swizzled }) => {
- //const { setAccount, setToken, setSeenUser } = Swizzled.hooks.useAccount()
- //const backend = Swizzled.hooks.useBackend()
-
- //const updateConsent = async ({ consent1, consent2 }) => {
- // let consent = 0
- // if (consent1) consent = 1
- // if (consent1 && consent2) consent = 2
- // if (consent > 0) {
- // const result = await backend.updateConsent(consent)
- // if (result.success) {
- // setToken(result.data.token)
- // setAccount(result.data.account)
- // setSeenUser(result.data.account.username)
- // refresh()
- // } else {
- // console.log('something went wrong', result)
- // refresh()
- // }
- // }
- //}
-
- return (
-
-
- {banner}
-
FIXME: Handle content form
- {/*
*/}
-
-
- )
-}
-
-export const AuthWrapper = ({ children, requiredRole = 'user', Swizzled }) => {
- const { t } = Swizzled.methods
- const { useAccount, useBackend } = Swizzled.hooks
- const { account, setAccount, token, admin, stopImpersonating, signOut } = useAccount()
- const backend = useBackend()
-
- const [ready, setReady] = useState(false)
- const [impersonating, setImpersonating] = useState(false)
- const [error, setError] = useState(false)
- const [refreshCount, setRefreshCount] = useState(0)
-
- /*
- * Avoid hydration errors
- */
- useEffect(() => {
- const verifyAdmin = async () => {
- const result = await backend.adminPing(admin.token)
- if (result.success && result.data.account.role === 'admin') {
- setImpersonating({
- admin: result.data.account.username,
- user: account.username,
- })
- }
- setReady(true)
- }
- const verifyUser = async () => {
- const result = await backend.ping()
- if (result.success) {
- // Refresh account in local storage
- setAccount({
- ...account,
- ...result.data.account,
- })
- } else {
- if (result.data?.error?.error) setError(result.data.error.error)
- else signOut()
- }
- setReady(true)
- }
- if (admin && admin.token) verifyAdmin()
- if (token) verifyUser()
- else setReady(true)
- }, [admin, token, refreshCount])
-
- const refresh = () => {
- setRefreshCount(refreshCount + 1)
- setError(false)
- }
-
- if (!ready) return
-
- const banner = impersonating ? (
-
-
- Hi {impersonating.admin} , you are currently impersonating {impersonating.user}
-
-
- Stop Impersonating
-
-
- ) : null
-
- const childProps = { t, banner, Swizzled }
-
- if (!token || !account.username) return
- if (error) {
- if (error === 'accountInactive') return
- if (error === 'accountDisabled') return
- if (error === 'accountBlocked') return
- if (error === 'consentLacking')
- return
- return
- }
-
- if (
- !Swizzled.config.roles.levels[account.role] ||
- Swizzled.config.roles.levels[account.role] < Swizzled.config.roles.levels[requiredRole]
- ) {
- return (
-
- )
- }
-
- return children
-}
diff --git a/packages/react/components/Editor/swizzle/components/dynamic-mdx.mjs b/packages/react/components/Editor/swizzle/components/dynamic-mdx.mjs
deleted file mode 100644
index 27319260e6e..00000000000
--- a/packages/react/components/Editor/swizzle/components/dynamic-mdx.mjs
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * Loading MDX dynamically is non-trivial an depends on the
- * environment in which the component is loaded.
- * By default, we use this component, which disabled loading
- * inline docs. If you want this to work, you need to pass in
- * your own DynamicMdx component into the editor:
- *
- *
- */
-export const DynamicMdx = ({ Swizzled }) => (
- Not implemented
-)
diff --git a/packages/react/components/Editor/swizzle/components/error-view.mjs b/packages/react/components/Editor/swizzle/components/error-view.mjs
deleted file mode 100644
index d2997094f14..00000000000
--- a/packages/react/components/Editor/swizzle/components/error-view.mjs
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * The error view is loaded if and only an error occurs that we can't handle
- *
- * @param {object} props - The component's props
- * @param {object} props.Swizzled - Swizzled code
- * @param {function} props.Design - The design constructor
- * @param {object} props.state - The ViewWrapper state object
- * @param {object} props.state.settings - The current settings
- * @param {object} props.update - Helper object for updating the ViewWrapper state
- * @param {array} props.missingMeasurements - List of missing measurements for the current design
- * @param {object} props.components - The possibly swizzled components
- * @param {object} props.methods - The possibly swizzled methods
- * @param {function} props.methods.t - The translation method
- * @param {object} props.config - The possibly swizzled pattern editor configuration
- * @return {function} MeasurementsView - React component
- */
-export const ErrorView = ({ Swizzled, state }) => (
-
-
{Swizzled.methods.t('oops')}
-
FIXME: Something went wrong
-
{JSON.stringify(state, null, 2)}
-
-)
diff --git a/packages/react/components/Editor/swizzle/components/icons.mjs b/packages/react/components/Editor/swizzle/components/icons.mjs
deleted file mode 100644
index b62c5272b44..00000000000
--- a/packages/react/components/Editor/swizzle/components/icons.mjs
+++ /dev/null
@@ -1,1135 +0,0 @@
-import React from 'react'
-/*
- * Used inside the pattern editor
- */
-export const logoPath =
- 'm18.56 0c-0.4945 0.3515-0.469 0.3065-0.8685 0.437-0.916 0.2995-1.7945 0.135-2.837 0.048-0.3135-0.035-0.6245-0.0555-0.928-0.0575-1.5325-0.0105-2.834 0.439-3.0805 1.694-0.4545 0.2755-0.8725 0.609-1.2865 0.943-0.884 0.6975-1.5495 1.55-2.0035 2.5775-0.62 1.5175-0.06 3.146 0.2175 4.684 0.066 0.36 0.135 0.703 0.172 0.8355 0.0525 0.1865 0.145 0.3645 0.2455 0.5245 0.0235 4e-3 0.1475-0.187 0.177-0.2715 0.043-0.123 0.0385-0.3205-0.0085-0.4905-0.104-0.3825-0.203-0.693-0.2115-0.849-0.015-0.293 0.042-0.5635 0.149-0.6975 0.038-0.0475 0.125 0.1975 0.1025 0.2885-0.0265 0.1095-0.0465 0.297-0.038 0.3835 0.0235 0.293 0.0665 0.6065 0.12 0.8805 0.0685 0.3535 0.098 0.5805 0.0855 0.6685-9e-3 0.064-0.039 0.1285-0.154 0.3265-0.1 0.1735-0.152 0.314-0.16 0.438-0.0085 0.121 0.028 0.4235 0.062 0.4975 0.0495 0.1155 0.1985 0.237 0.3285 0.267 0.1245 0.0475 0.187 0.146 0.251 0.2565 0.1555 0.2965 0.2755 0.6575 0.3945 1.2015 0.058 0.2605 0.1065 0.493 0.122 0.615-0.96 1e-3 -2.1895 0.0015-3.3095 0.0015-0.377 6e-3 -1.058-0.171-1.6825-0.212-0.0905-0.977-0.5195-2.112-1.2535-2.178-0.501-0.0455-0.9165 0.145-1.268 0.9365l0.01 0.0425c0.2075-0.1735 0.4265-0.704 1.2155-0.6675 0.606 0.0275 0.808 1.1745 0.868 1.8645-0.369 0.027-0.683 0.1405-0.847 0.424h-0.0035c0 5e-4 0 0.0015 0.0015 0.0025-0.0015 1e-3 -0.0015 2e-3 -0.0015 3e-3h0.0035c0.169 0.2905 0.4945 0.403 0.877 0.4255 0.2555 7.225 7.047 8.157 8.903 8.157 6.924 0 9.348-4.705 9.7125-6.5685 0.1705 0.794-0.3665 1.8055-0.495 2.552 1.4605-1.6885 1.1965-3.312 0.9295-4.945 0.222 0.264 0.5225 0.4275 0.93 0.337-0.2905-0.194-0.6845-0.058-0.9205-0.8765-0.103-0.3535-0.192-0.6185-0.2805-0.841-0.191-0.7165-0.462-1.401-0.795-2.068-0.281-0.7235-0.0955-1.1925-0.1235-1.8135 0.5055 1.667 0.8215 2.1105 1.4115 2.285-1.484-1.788-0.976-4.5565-1.8145-7.0275 0.3795 0.223 0.8125 0.29 1.2735 0.0175-0.446-0.127-0.891 0.2085-1.531-0.732-0.5405-1.0515-1.3235-1.828-2.2735-2.513-0.509-0.332-1.074-0.555-1.642-0.762 0.5785-0.145 1.2245-0.66 1.2545-1.0445zm-0.9705 5.5535c0.762 0.278 1.602 1.334 1.5925 2.37v0.058c-0.0205 1.407-0.66 2.1635-0.633 3.1005 0.0345 1.1035 0.5095 1.4885 0.604 1.6725-0.162-0.6805-0.257-1.5365-0.043-2.2145 0.275-0.872 0.5525-1.594 0.5325-2.277-0.01-0.16-0.078-0.7585-0.1235-1.0235 0.817 1.179-0.177 2.8935 0.109 4.0155 0.497 1.9545 2.7245 2.2015 2.0615 6.1395-0.5835 3.462-4.5815 6.0895-8.6795 6.0895-3.038 0-8.3025-1.6815-8.5625-7.646 0.6175-0.044 1.2815-0.216 1.654-0.21 1.126 0 2.412 5e-4 3.381 1e-3 0.182 0.821 0.3185 1.019 1.009 1.566 0.768 0.604 0.947 0.6775 2.083 0.6885 1.1365 0.0115 1.4735-0.232 2.576-1.275 0.238-0.279 0.341-0.6445 0.4565-0.988 1.134-0.0105 1.961-0.0305 2.7745-0.0685 0.8285-0.0375 0.9455 0 2.2805-0.1375-1.335-0.1375-1.452-0.1-2.2805-0.138-0.792-0.036-1.594-0.0565-2.6785-0.0665 0.091-0.4085 0.221-0.8075 0.3595-1.202 0.0855-0.2325 0.186-0.459 0.289-0.6845l0.1125-0.035c0.217-0.077 0.409-0.242 0.4855-0.465 0.0985-0.2955 0.0285-0.6275-0.162-0.869-0.0655-0.0905-0.147-0.206-0.1805-0.257-0.1005-0.159-0.103-0.2475-0.018-0.8385 0.0715-0.495 0.0795-0.754 0.03-1.005-0.01-0.1435-0.011-0.4385-0.0155-0.518 0.038 0.021 0.1205 0.209 0.204 0.4635 0.083 0.2555 0.0965 0.3085 0.1155 0.526 0.021 0.247-0.0715 0.43-0.1475 0.7985-0.038 0.19-0.0715 0.3665-0.0715 0.3905 0 0.0255 0.018 0.0795 0.037 0.1215 0.0445 0.094 0.128 0.226 0.1435 0.226 0.2725-0.3005 0.4325-0.6715 0.575-1.048 0.15-0.426 0.194-0.878 0.299-1.3165 0.085-0.382 0.183-0.7645 0.2135-1.1565 0.0615-0.765 0.0255-1.305-0.1435-2.102-0.0405-0.18-0.1575-0.5235-0.239-0.6855zm-2.68 3.7685c0.2925-0.0035 0.582 0.032 0.8575 0.1115 0.3745 0.1435 0.427 0.478 0.496 0.8535 0.0385 0.24 0.037 0.4125-0.0065 0.6945-0.0305 0.409-0.193 0.7255-0.548 0.948-0.5355 0.099-1.108 0.1945-1.562-0.16-0.381-0.525-0.6105-1.1885-0.523-1.8355 0.0555-0.2655 0.179-0.4035 0.433-0.486 0.2735-0.0785 0.563-0.1215 0.853-0.126zm-4.4415 0.0475c0.2735-0.0025 0.55 0.0265 0.702 0.1235 0.6525 0.4415 0.443 1.16 0.185 1.7905-0.3755 0.8255-1.1875 0.795-1.9745 0.7885-0.4355-0.1275-0.4755-0.4845-0.5385-0.866-0.054-0.3685-0.169-0.7635-0.073-1.134 0.2465-0.596 1.1475-0.6645 1.699-0.7025zm9.9515 0.103c0.0035 1.5865 0.2745 2.366 0.8185 3.4895-0.3205-0.6115-0.7785-0.9595-0.949-1.6905-0.326-1.4115 0.0255-1.3325 0.1305-1.799zm-7.9065 1.149c0.086 0.087 0.1275 0.207 0.202 0.3025 0.0575-0.0985 0.1165-0.1965 0.1905-0.284 0.0385 1e-3 0.0855 0.077 0.128 0.213 0.182 0.503 0.2175 1.0565 0.4535 1.54 0.2205 0.35-0.0805 0.554-0.411 0.57-0.241-5e-4 -0.343-0.165-0.4845-0.328-0.0365 0.1065-0.106 0.175-0.189 0.247-0.211 0.177-0.6245 0.1115-0.6885-0.1675 0.085-0.533 0.3565-1.0225 0.5345-1.5335 0.0885-0.1865 0.0895-0.3295 0.2645-0.5595zm-3.096 2.6925c0.1065 0 0.399 0.1985 0.4585 0.3105 0.041 0.0745 0.1345 0.3645 0.141 0.435 0.0105 0.084-0.015 0.283-0.041 0.337-0.019 0.0385-0.0335 0.044-0.0555 0.019-0.0185-0.021-0.2635-0.491-0.42-0.802-0.123-0.249-0.136-0.2995-0.083-0.2995zm6.111 0.1555c4e-3 5e-4 0.01 2e-3 0.0155 0.0035 0.033 0.0135 0.01 0.1305-0.114 0.5555-0.0235 0.128-0.0805 0.229-0.164 0.313-0.0275 0-0.04-0.032-0.083-0.2095-0.0365-0.1515-0.0405-0.2865-0.015-0.4075 0.044-0.1515 0.222-0.198 0.3605-0.255zm-0.7415 0.9265c0.0105-2e-3 0.0205 0.0035 0.0335 0.014 0.045 0.0315 0.0515 0.1145 0.0215 0.277-0.0365 0.209-0.0445 0.232-0.0985 0.2535-0.0235 0.0105-0.0655 0.018-0.0935 0.018-0.0505-9e-3 -0.0635-0.05-0.0515-0.112 0-0.13 0.038-0.243 0.124-0.3765 0.0325-0.05 0.049-0.0715 0.0645-0.074zm-4.3165 0.0095c0.0345 0 0.1385 0.075 0.177 0.127 0.043 0.055 0.092 0.3825 0.0645 0.439-0.0315 0.071-0.1855 0.0355-0.228-0.053-0.026-0.053-0.0875-0.339-0.0875-0.407 0-0.063 0.0305-0.106 0.074-0.106zm3.9455 0.0865c0.042 0.06 0.053 0.137 0.044 0.306l-0.0085 0.154-0.044 0.044c-0.0265 0.0245-0.0715 0.0545-0.0985 0.067-0.0595 0.028-0.105 0.0305-0.1135 8e-3 -0.01-0.03 7e-3 -0.221 0.0255-0.2855 0.0215-0.0665 0.118-0.265 0.15-0.307 0.0145-0.0385 0.0315 0.0095 0.045 0.0135zm-2.5105-9e-3c0.0905 0.023 0.1305 0.1045 0.18 0.1785l0.0335 0.066-0.047 0.1635c-0.025 0.09-0.0515 0.171-0.0595 0.18-9e-3 0.01-0.0425 0.015-0.092 0.0145-0.132-0.0035-0.147-9e-3 -0.1825-0.063l-0.033-0.049 0.028-0.1375c0.0405-0.198 0.06-0.2575 0.105-0.3085 0.0235-0.0275 0.047-0.0425 0.0675-0.0445zm-0.8355 0.1415 0.0745 0.0745 0.0125 0.1685c0.0065 0.092 0.0095 0.1775 0.0045 0.188-0.0045 0.0145-0.0315 0.0185-0.115 0.0185h-0.1085c-0.058-0.0635-0.076-0.141-0.1005-0.221-0.057-0.2405-0.057-0.35 2e-3 -0.3645 0.0965 6e-3 0.16 0.076 0.2305 0.136zm2.9-0.1155c0.118 0.0315 0.0945 0.219 0.094 0.353-9e-3 0.217-0.0175 0.262-0.0455 0.29-0.0485 0.0485-0.1835 0.0215-0.249-0.0505-0.0215-0.026-0.0235-0.034-0.0065-0.1395 0.0195-0.1285 0.0445-0.2085 0.1-0.3185 0.0405-0.079 0.0785-0.1285 0.107-0.1345zm-2.663 0.01c0.0065-5e-4 0.017 0 0.027 1e-3 0.075 6e-3 0.145 0.055 0.207 0.145l0.05 0.0735c0.0045 0.1205 0 0.2475-0.0215 0.3595-0.013 0.0065-0.067 0.0165-0.12 0.0215-0.092 0.0085-0.1005 0.0065-0.1325-0.0215-0.0445-0.038-0.057-0.1085-0.068-0.3425-0.0065-0.191-2e-3 -0.2335 0.058-0.2365zm1.1345 0.04c0.0805 0.017 0.1315 0.06 0.154 0.1305 0.018 0.0605 0.029 0.399 0.0115 0.4225-6e-3 0.01-0.044 0.0225-0.0875 0.028-0.162 0.0205-0.305 5e-3 -0.319-0.0335-0.018-0.044 0.1025-0.48 0.147-0.534 0.019-0.042 0.065-0.0095 0.094-0.0135zm1.049 3e-3c0.0355-0.0035 0.0735 0.0305 0.1105 0.103 0.03 0.0605 0.0345 0.0815 0.0345 0.217 0 0.108-0.0065 0.1545-0.018 0.1645-0.01 8e-3 -0.0505 0.0225-0.0935 0.0335-0.075 0.0195-0.0915 0.0215-0.115 0.0135l-0.1125-0.0205 0.0085-0.067c8e-3 -0.0875 0.0655-0.2815 0.106-0.3655 0.024-0.05 0.0515-0.075 0.0795-0.0785zm-0.489 0.0015c0.0235-1e-3 0.0345 0.0045 0.0495 0.021 0.0355 0.042 0.0805 0.166 0.109 0.2985 0.038 0.1865 0.038 0.186-0.0435 0.2105-0.0355 0.011-0.1105 0.0225-0.164 0.0255-0.1765 9e-3 -0.19-0.0015-0.1685-0.1575 0.017-0.139 0.0855-0.358 0.115-0.374 0.032-0.017 0.069-0.0165 0.1025-0.024zm-8.9965 0.7045c0.0015-5e-4 0.0035 0 0.0035 0 0.0045 0.0975 0.0045 0.196 0.0065 0.294-0.2475-0.019-0.4295-0.078-0.4295-0.1475 0-0.0685 0.1755-0.127 0.4195-0.1465zm0.4325 0.0085c0.2005 0.025 0.339 0.0775 0.3365 0.138 0 0.061-0.134 0.113-0.333 0.1375-2e-3 -0.0915-2e-3 -0.1835-0.0035-0.2755zm9.363 0.2665c0.017-0.0015 0.0245-3e-3 0.0505-5e-4 0.104 0.0105 0.119 0.017 0.119 0.052 0 0.046-0.079 0.1845-0.1325 0.2325-0.025 0.024-0.0595 0.044-0.0715 0.044-0.06 0-0.095-0.1265-0.067-0.243 0.017-0.063 0.048-0.0825 0.1015-0.085zm-0.3775 0.0415c0.0465-4e-3 0.0915 0.0085 0.1365 0.0145-0.013 0.1315-0.072 0.239-0.1815 0.3105-0.027 0-0.0405-0.0515-0.0405-0.164 0-0.134 7e-3 -0.1595 0.0855-0.161zm-0.414 0.0485c0.0965 0 0.1815 0.0045 0.1855 0.01 0.018 0.017-0.034 0.146-0.1105 0.277-0.0655 0.1165-0.075 0.125-0.1155 0.128-0.159-0.018-0.1545-0.2045-0.179-0.3325 0-0.076 0.017-0.0825 0.2195-0.0825zm-1.5045 0.0145c0.1105 2e-3 0.1535 0.0185 0.1535 0.061 0 0.054-0.041 0.1615-0.0645 0.175-0.0355 0.0195-0.0385 0.0185-0.1085-0.0545-0.1105-0.124-0.123-0.147 0.0195-0.1815zm0.532 0.0055c2e-3 3e-3 0.0235 0.042 0.045 0.086 0.047 0.0915 0.0505 0.1315 0.017 0.162-0.079 0.045-0.0955 0.0195-0.167-0.026-0.083-0.0785-0.1485-0.184-0.127-0.206 0.074-0.0265 0.1555-0.0165 0.232-0.016zm0.211 0.0025 0.1975 0.0035c0.077 0 0.1435 4e-3 0.147 0.01 0.0135 0.012-0.03 0.269-0.0535 0.327-0.027 0.065-0.1215 0.0655-0.1705-0.0115-0.07-0.1105-0.116-0.2035-0.1175-0.2675z'
-
-export const IconWrapper = ({
- className = 'w-6 h-6',
- stroke = 2,
- children = null,
- fill = false,
- fillOpacity = 1,
- dasharray = null,
- wrapped = true,
-}) =>
- wrapped ? (
-
- {children}
-
- ) : (
- <> {children} >
- )
-
-// Looks like a play triangle
-export const ApplyIcon = (props) => (
-
-
-
-)
-
-// Looks like a lab beaker
-export const BeakerIcon = (props) => (
-
-
-
-)
-
-// Looks like a left U-turn that we slightly rotate
-export const BackIcon = (props) => (
-
-
-
-)
-
-// Looks like a red X
-export const BoolNoIcon = ({ size = 6 }) => (
-
-)
-
-// Looks like a green checkbox
-export const BoolYesIcon = ({ size = 6 }) => (
-
-)
-
-// Looks like a bookmark
-export const BookmarkIcon = (props) => (
-
-
-
-)
-
-// Looks lik a speech bubble
-export const ChatIcon = (props) => (
-
-
-
-)
-
-// Looks like a circle
-export const CircleIcon = (props) => (
-
-
-
-)
-
-// Looks like a X
-export const CloseIcon = (props) => (
-
-
-
-)
-
-// Looks like a museum building
-export const CuratedMeasurementsSetIcon = (props) => (
-
-
-
-)
-
-// Looks like a coathanger
-export const DesignIcon = (props) => (
-
-
-
-)
-
-// Looks like a left and right pane with different level of detail
-export const DetailIcon = (props) => (
-
-
-
-)
-
-// Looks like a document icon
-export const DocsIcon = (props) => (
-
-
-
-)
-
-// Looks like a down pointing chevron
-export const DownIcon = (props) => (
-
-
-
-)
-
-// Looks like a pencil
-export const EditIcon = (props) => (
-
-
-
-)
-
-// Looks like FIXME
-export const ErrorIcon = (props) => (
-
-
-
-)
-
-// Looks like arrows pointing outwards
-export const ExpandIcon = (props) => (
-
-
-
-)
-
-// Looks like a file/sheet with an arrow pointing downwards
-export const ExportIcon = (props) => (
-
-
-
-)
-
-// Looks like a ! in a triangle, is intended to be shown on an error background
-export const FailureIcon = ({ size = 6 }) => (
-
-)
-
-// Looks lik a flag
-export const FlagIcon = (props) => (
-
-
-
-)
-
-// Looks like a gauge or speedometer
-export const GaugeIcon = (props) => (
-
-
-
-
-)
-
-// Looks like abox
-export const GroupIcon = (props) => (
-
-
-
-)
-
-// Looks like a question mark in a circle
-export const HelpIcon = (props) => (
-
-
-
-)
-
-// Looks like a pie with a slice a bit out of it
-export const IncludeIcon = (props) => (
-
-
-
-
-)
-
-// Looks like a rectangle with rounded corners (like a full screen display)
-export const KioskIcon = (props) => (
-
-
-
-)
-
-// Looks like a left pointing chevron
-export const LeftIcon = (props) => (
-
-
-
-)
-
-// Looks like a bullet list
-export const ListIcon = (props) => (
-
-
-
-)
-
-// Looks like a padlock
-export const LockIcon = (props) => (
-
-
-
-)
-
-// Looks like 4 boxes spaces out
-export const MarginIcon = (props) => (
-
-
-
-)
-
-// Looks like a tape measure
-export const MeasurementsIcon = (props) => (
-
-
-
-)
-
-// Looks like two people's heads next/behinf to each other, one bigger, one smaller
-export const MeasurementsSetIcon = (props) => (
-
-
-
-)
-
-// Looks like 3 horizontal lines (hamburger menu)
-export const MenuIcon = (props) => (
-
-
-
-)
-
-// Looks like a X
-export const NoIcon = (props) => (
-
-
-
-)
-
-// Looks like a checkmark
-export const OkIcon = (props) => (
-
-
-
-)
-
-// Looks like sliders on a mixing panel
-export const OptionsIcon = (props) => (
-
-
-
-)
-
-// Looks like a grid
-export const PaperlessIcon = (props) => (
-
-
-
-
-)
-
-// Looks like a +
-export const PlusIcon = (props) => (
-
-
-
-)
-
-// Looks like a printer
-export const PrintIcon = (props) => (
-
-
-
-)
-
-// Looks like a single rewind arrow
-export const ResetIcon = (props) => (
-
-
-
-)
-
-// Looks like a double rewind arrow
-export const ResetAllIcon = (props) => (
-
-
-
-)
-
-// Looks like a right pointing chevron
-export const RightIcon = (props) => (
-
-
-
-)
-
-// Looks like a rocket
-export const RocketIcon = (props) => (
-
-
-
-)
-
-// Looks like two arrows in a circular layout
-export const RotateIcon = (props) => (
-
-
-
-)
-
-// Looks like a cloud with a plus sign in it
-export const SaveIcon = (props) => (
-
-
-
-)
-
-// Looks like a cloud with a plus sign in it
-export const SaveAsIcon = (props) => (
-
-
-
-)
-
-// Looks like a small solid circle with a larger dashed circle around it
-export const SaIcon = (props) => (
-
-
-
-
-)
-
-// Looks like lines of varying thickness
-export const ScaleIcon = (props) => (
-
-
-
-
-
-)
-
-// Looks like a gear
-export const SettingsIcon = (props) => (
-
-
-
-
-)
-
-// Looks like a spinning circle
-export const SpinnerIcon = (props) => (
-
-
-
-
-)
-
-// Looks like a white checkbox, intended to be shown on a success-colored background
-export const SuccessIcon = ({ size = 6 }) => (
-
-)
-
-// Looks like a light bulb
-export const TipIcon = (props) => (
-
-
-
-)
-
-// Looks like a trashcan
-export const TrashIcon = (props) => (
-
-
-
-)
-
-// Looks like a desktop screen
-export const UiIcon = (props) => (
-
-
-
-)
-
-// Looks like a rewind arrow, but takes text to go inside it
-export const UndoIcon = (props) => (
-
-
- {props.text ? (
-
- {props.text}
-
- ) : null}
-
-)
-
-// Looks like a bit of measuring tape
-export const UnitsIcon = (props) => (
-
-
-
-
-)
-
-// Looks like an up pointing chevron
-export const UpIcon = (props) => (
-
-
-
-)
-// Looks like a cloud with an arrow pointing upwards in it
-export const UploadIcon = (props) => (
-
-
-
-)
-
-// Looks like old-timey scales
-export const UxIcon = (props) => (
-
-
-
-)
-
-// Looks like an ! in a triangle
-export const WarningIcon = (props) => (
-
-
-
-)
-
-// Looks like a wrench
-export const WrenchIcon = (props) => (
-
-
-
-)
-
-// Looks like a box in dashed lines
-export const XrayIcon = (props) => (
-
-
-
-)
-
-// These icons all reuse existing icons
-export const ViewDraftIcon = OptionsIcon
-export const ViewMeasurementsIcon = MeasurementsIcon
-export const ViewTestIcon = BeakerIcon
-export const ViewTimingIcon = GaugeIcon
-export const ViewPrintLayoutIcon = PrintIcon
-export const ViewSaveIcon = SaveIcon
-export const ViewExportIcon = ExportIcon
-export const ViewEditSettingsIcon = EditIcon
-export const ViewLogsIcon = ListIcon
-export const ViewInspectIcon = XrayIcon
-export const ViewDocsIcon = DocsIcon
-export const ViewDesignsIcon = DesignIcon
-export const ViewViewPickerIcon = UiIcon
-export const ViewUndosIcon = BackIcon
-// Flag icons
-export const FlagNoteIcon = ChatIcon
-export const FlagInfoIcon = DocsIcon
-export const FlagTipIcon = TipIcon
-export const FlagWarningIcon = WarningIcon
-export const FlagErrorIcon = ErrorIcon
-export const FlagFixmeIcon = WrenchIcon
-export const FlagExpandIcon = ExpandIcon
-export const FlagOtionsIcon = OptionsIcon
-
-/*
- * Not used inside the pattern editor
-// Used in several icons
-const page =
- 'M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z'
-
-export const BeakerIcon = (props) => (
-
-
-
-)
-
-export const BioIcon = (props) => (
-
-
-
-)
-
-
-export const BoxIcon = (props) => (
-
-
-
-)
-
-export const BriefcaseIcon = (props) => (
-
-
-
-)
-
-export const BugIcon = (props) => (
-
-
-
-)
-
-export const BulletIcon = (props) => (
-
-
-
-)
-
-export const CalendarIcon = (props) => (
-
-
-
-)
-
-export const CameraIcon = (props) => (
-
-
-
-
-)
-
-export const CcByIcon = (props) => (
-
-
-
-)
-
-export const CisFemaleIcon = (props) => (
-
-
-
-)
-
-export const CisMaleIcon = (props) => (
-
-
-
-)
-
-export const ClearIcon = (props) => (
-
-
-
-)
-
-export const CloneIcon = (props) => (
-
-
-
-)
-
-export const CodeIcon = (props) => (
-
-
-
-)
-
-export const CogIcon = (props) => (
-
-
-
-)
-
-export const CommunityIcon = (props) => (
-
-
-
-)
-
-export const CompareIcon = (props) => (
-
-
-
-)
-
-export const CopyIcon = (props) => (
-
-
-
-)
-
-export const CoverPageIcon = (props) => (
-
-
-
-
-
-
-)
-
-export const CsetIcon = (props) => (
-
-
-
-)
-export const CuratedMeasurementsSetIcon = CsetIcon
-
-export const CloudIcon = (props) => (
-
-
-
-)
-
-export const CutIcon = (props) => (
-
-
-
-)
-
-export const CuttingLayoutIcon = (props) => (
-
-
-
-
-)
-
-export const DetailIcon = (props) => (
-
-
-
-
-)
-
-export const DiscordIcon = (props) => (
-
-
-
-)
-
-export const DoubleLeftIcon = (props) => (
-
-
-
-)
-export const DoubleRightIcon = (props) => (
-
-
-
-)
-
-export const DownloadIcon = (props) => (
-
-
-
-)
-
-export const EmailIcon = (props) => (
-
-
-
-)
-
-export const FacebookIcon = (props) => (
-
-
-
-)
-
-export const FilterIcon = (props) => (
-
-
-
-)
-
-export const FingerprintIcon = (props) => (
-
-
-
-)
-
-export const ForbiddenIcon = (props) => (
-
-
-
-)
-
-export const FreeSewingIcon = (props) => (
-
-
-
-)
-
-export const GaugeIcon = (props) => (
-
-
-
-
-)
-
-export const GitHubIcon = (props) => (
-
-
-
-)
-
-export const GuideIcon = (props) => (
-
-
-
-)
-
-export const GoogleIcon = (props) => (
-
-
-
-)
-
-export const HeartIcon = (props) => (
-
-
-
-)
-
-export const HomeIcon = (props) => (
-
-
-
-)
-
-export const I18nIcon = (props) => (
-
-
-
-)
-
-export const ImportIcon = (props) => (
-
-
-
-)
-
-export const IncludeIcon = (props) => (
-
-
-
-
-)
-
-export const InstagramIcon = (props) => (
-
-
-
-)
-
-export const KeyIcon = (props) => (
-
-
-
-)
-
-export const LabelIcon = (props) => (
-
-
-
-
-)
-
-export const LeftRightIcon = (props) => (
-
-
-
-)
-
-export const LinkIcon = (props) => (
-
-
-
-)
-
-export const MastodonIcon = (props) => (
-
-
-
-)
-
-export const MarginIcon = (props) => (
-
-
-
-)
-
-export const MeasieIcon = (props) => (
-
-
-
-)
-
-export const MegaphoneIcon = (props) => (
-
-
-
-)
-
-export const MenuAltIcon = (props) => (
-
-
-
-)
-
-export const MeasurementsSetIcon = MsetIcon
-
-export const MsfIcon = (props) => (
-
-
-
-)
-
-// NarrowIcon - Looks like two arrow pointing inwards
-export const NarrowIcon = (props) => (
-
-
-
-)
-
-export const NewMsetIcon = (props) => (
-
-
-
-)
-
-export const NewsletterIcon = (props) => (
-
-
-
-)
-
-export const NoteIcon = (props) => (
-
-
-
-)
-
-export const OpackIcon = (props) => (
-
-
-
-)
-export const OptionPackIcon = OpackIcon
-
-export const OpenSourceIcon = (props) => (
-
-
-
-)
-
-export const PageMarginIcon = (props) => (
-
-
-
-
-)
-
-export const PageOrientationIcon = (props) => (
-
-
-
-
-)
-
-export const PageSizeIcon = (props) => (
-
-
-
-
-)
-
-export const PatternIcon = (props) => (
-
-
-
-)
-
-export const NewPatternIcon = (props) => (
-
-
-
-)
-
-export const PluginIcon = (props) => (
-
-
-
-)
-
-
-export const PrintIcon = (props) => (
-
-
-
-)
-
-export const PrivacyIcon = (props) => (
-
-
-
-)
-
-export const RedditIcon = (props) => (
-
-
-
-)
-
-export const ReloadIcon = (props) => (
-
-
-
-)
-
-export const RssIcon = (props) => (
-
-
-
-)
-
-export const ScaleIcon = (props) => (
-
-
-
-
-
-)
-
-export const SearchIcon = (props) => (
-
-
-
-)
-
-export const ShieldIcon = (props) => (
-
-
-
-)
-
-export const ShowcaseIcon = (props) => (
-
-
-
-
-)
-
-export const SigninIcon = (props) => (
-
-
-
-)
-
-export const SignoutIcon = (props) => (
-
-
-
-)
-
-export const StarIcon = (props) => (
-
-
-
-)
-
-export const ThemeIcon = (props) => (
-
-
-
-)
-
-export const TikTokIcon = (props) => (
-
-
-
-)
-
-export const TutorialIcon = (props) => (
-
-
-
-
-
-)
-
-export const TrophyIcon = (props) => (
-
-
-
-)
-
-export const TwitchIcon = (props) => (
-
-
-
-)
-
-export const TwitterIcon = (props) => (
-
-
-
-)
-
-
-export const UserIcon = (props) => (
-
-
-
-)
-
-export const VersionIcon = (props) => (
-
-
-
-)
-
-// WideIcon - Looks like two arrow pointing outwards
-export const WideIcon = (props) => (
-
-
-
-)
-
-export const XrayIcon = (props) => (
-
-
-
-)
-
-export const YouTubeIcon = (props) => (
-
-
-
-)
-
-export const ZoomInIcon = (props) => (
-
-
-
-)
-
-export const ZoomOutIcon = (props) => (
-
-
-
-)
-*/
diff --git a/packages/react/components/Editor/swizzle/components/index.mjs b/packages/react/components/Editor/swizzle/components/index.mjs
deleted file mode 100644
index f7a6dcdfdc4..00000000000
--- a/packages/react/components/Editor/swizzle/components/index.mjs
+++ /dev/null
@@ -1,659 +0,0 @@
-/*************************************************************************
- * *
- * FreeSewing's pattern editor allows swizzling components *
- * *
- * To 'swizzle' means to replace the default implementation of a *
- * component with a custom one. It allows one to customize *
- * the pattern editor. *
- * *
- * This file holds the 'swizzleComponents' method that will return *
- * the various components that can be swizzled, or their default *
- * implementation. *
- * *
- * To use a custom version, simply pas it as a prop into the editor *
- * under the 'components' key. So to pass a custom 'TemporaryLoader' *
- * component, you do: *
- * *
- * *
- * *
- *************************************************************************/
-
-/*
- * Import of components that can be swizzled
- */
-import { Link, AnchorLink, PageLink, WebLink, CardLink } from './link.mjs'
-// Accordion
-import { BaseAccordion, SubAccordion, Accordion } from './accordion.mjs'
-// Auth wrapper
-import {
- AuthWrapper,
- AuthMessageWrapper,
- ContactSupport,
- AuthRequired,
- AccountInactive,
- AccountDisabled,
- AccountProhibited,
- AccountStatusUnknown,
- RoleLacking,
- ConsentLacking,
-} from './auth-wrapper.mjs'
-// Ux
-import { Ux } from './ux.mjs'
-// Popout
-import { Popout } from './popout.mjs'
-// Loader
-import { TemporaryLoader } from './loaders.mjs'
-// Measurements Sets
-import { UserSetPicker, BookmarkedSetPicker, CuratedSetPicker } from './sets.mjs'
-// Curated Measurements Sets
-import { CuratedMeasurementsSetLineup } from './curated-sets.mjs'
-import { MeasurementsSetCard } from './measurements-set-card.mjs'
-// Icons
-import {
- ApplyIcon,
- BackIcon,
- BeakerIcon,
- BookmarkIcon,
- BoolNoIcon,
- BoolYesIcon,
- CircleIcon,
- CloseIcon,
- CuratedMeasurementsSetIcon,
- DesignIcon,
- DetailIcon,
- DocsIcon,
- DownIcon,
- EditIcon,
- ExpandIcon,
- ExportIcon,
- FailureIcon,
- FlagIcon,
- FlagNoteIcon,
- FlagInfoIcon,
- FlagTipIcon,
- FlagWarningIcon,
- FlagErrorIcon,
- FlagFixmeIcon,
- FlagExpandIcon,
- FlagOtionsIcon,
- GaugeIcon,
- GroupIcon,
- IncludeIcon,
- HelpIcon,
- KioskIcon,
- LeftIcon,
- ListIcon,
- LockIcon,
- MarginIcon,
- MeasurementsIcon,
- MeasurementsSetIcon,
- MenuIcon,
- NoIcon,
- OkIcon,
- OptionsIcon,
- PaperlessIcon,
- PlusIcon,
- PrintIcon,
- ResetAllIcon,
- ResetIcon,
- RightIcon,
- RocketIcon,
- RotateIcon,
- SaIcon,
- SaveIcon,
- SaveAsIcon,
- ScaleIcon,
- SettingsIcon,
- SpinnerIcon,
- SuccessIcon,
- TipIcon,
- TrashIcon,
- UiIcon,
- UndoIcon,
- UnitsIcon,
- UpIcon,
- UploadIcon,
- UxIcon,
- XrayIcon,
- ViewDraftIcon,
- ViewMeasurementsIcon,
- ViewTestIcon,
- ViewTimingIcon,
- ViewPrintLayoutIcon,
- ViewSaveIcon,
- ViewExportIcon,
- ViewEditSettingsIcon,
- ViewLogsIcon,
- ViewInspectIcon,
- ViewDocsIcon,
- ViewDesignsIcon,
- ViewViewPickerIcon,
- ViewUndosIcon,
-} from './icons.mjs'
-// Measurements Editor
-import { MeasurementsEditor } from './measurements-editor.mjs'
-// Zoomable pattern
-import { ZoomablePattern, ZoomContextProvider } from './zoomable-pattern.mjs'
-import { PatternLayout } from './pattern-layout.mjs'
-// inputs
-import {
- FormControl,
- ButtonFrame,
- NumberInput,
- StringInput,
- ListInput,
- MarkdownInput,
- MeasurementInput,
- ToggleInput,
-} from './inputs.mjs'
-// Views
-import { DesignsView } from './designs-view.mjs'
-import { DraftView } from './draft-view.mjs'
-import { ErrorView } from './error-view.mjs'
-import { MeasurementsView } from './measurements-view.mjs'
-import { SaveView } from './save-view.mjs'
-import { ViewPicker } from './view-picker.mjs'
-import { UndoStep, UndoStepTimeAgo, UndosView } from './undos-view.mjs'
-// Pattern
-import { Pattern } from '@freesewing/react-components/pattern'
-// Menus
-import { DraftMenu } from './menus/draft-menu.mjs'
-import { CoreSettingsMenu, CoreSetting } from './menus/core-settings-menu.mjs'
-import { DesignOptionsMenu, DesignOption } from './menus/design-options-menu.mjs'
-import { UiPreferencesMenu, UiPreference } from './menus/ui-preferences-menu.mjs'
-import { MenuItem, MenuItemGroup, MenuItemTitle } from './menus/containers.mjs'
-import {
- MenuBoolInput,
- MenuConstantInput,
- MenuDegInput,
- MenuEditOption,
- MenuListInput,
- MenuListToggle,
- MenuMmInput,
- //MenuNumberInput,
- MenuUxSettingInput,
- MenuOnlySettingInput,
- MenuPctInput,
- MenuSliderInput,
-} from './menus/shared-inputs.mjs'
-import {
- MenuBoolValue,
- MenuConstantOptionValue,
- MenuCountOptionValue,
- MenuDegOptionValue,
- MenuHighlightValue,
- MenuListOptionValue,
- MenuListValue,
- MenuMmOptionValue,
- MenuMmValue,
- MenuOnlySettingValue,
- MenuPctOptionValue,
- MenuScaleSettingValue,
- MenuShowValue,
-} from './menus/shared-values.mjs'
-import {
- HeaderMenu,
- HeaderMenuAllViews,
- HeaderMenuDraftView,
- HeaderMenuButton,
- HeaderMenuDropdown,
- HeaderMenuDraftViewDesignOptions,
- HeaderMenuDraftViewCoreSettings,
- HeaderMenuDraftViewUiPreferences,
- HeaderMenuDraftViewFlags,
- HeaderMenuDraftViewIcons,
- HeaderMenuIcon,
- HeaderMenuIconSpacer,
- HeaderMenuSaveIcons,
- HeaderMenuUndoIcons,
- HeaderMenuViewMenu,
-} from './header-menu.mjs'
-// Flags
-import { Flag, FlagTypeIcon, FlagsAccordionTitle, FlagsAccordionEntries } from './flags.mjs'
-// View Menu
-import {
- AsideViewMenu,
- AsideViewMenuIcons,
- AsideViewMenuButton,
- AsideViewMenuSpacer,
- ViewTypeIcon,
-} from './aside-view-menu.mjs'
-import { Null } from './null.mjs'
-import { LargeScreenOnly } from './large-screen-only.mjs'
-import { Tooltip } from './tooltip.mjs'
-import { LoadingStatus } from './loading-status.mjs'
-import { Spinner, Loading } from './spinner.mjs'
-import { Tab, Tabs } from './tabs.mjs'
-import { Markdown } from './markdown.mjs'
-import { HtmlSpan } from './html-span.mjs'
-/**
- * This object holds all components that can be swizzled
- */
-const defaultComponents = {
- Accordion,
- AuthWrapper,
- AuthMessageWrapper,
- BackIcon,
- ContactSupport,
- AuthRequired,
- AccountInactive,
- AccountDisabled,
- AccountProhibited,
- AccountStatusUnknown,
- AnchorLink,
- AsideViewMenu,
- AsideViewMenuIcons,
- AsideViewMenuButton,
- AsideViewMenuSpacer,
- RoleLacking,
- ConsentLacking,
- BaseAccordion,
- BookmarkedSetPicker,
- ButtonFrame,
- CardLink,
- CircleIcon,
- CoreSetting,
- CoreSettingsMenu,
- CuratedMeasurementsSetIcon,
- CuratedMeasurementsSetLineup,
- CuratedSetPicker,
- DesignOption,
- DesignOptionsMenu,
- DesignsView,
- DraftMenu,
- DraftView,
- ErrorView,
- SaveView,
- Flag,
- FlagsAccordionTitle,
- FlagsAccordionEntries,
- FlagTypeIcon,
- FormControl,
- HeaderMenu,
- HeaderMenuAllViews,
- HeaderMenuDraftView,
- HeaderMenuDraftViewDesignOptions,
- HeaderMenuDraftViewCoreSettings,
- HeaderMenuDraftViewUiPreferences,
- HeaderMenuDraftViewFlags,
- HeaderMenuDraftViewIcons,
- HeaderMenuButton,
- HeaderMenuDropdown,
- HeaderMenuIcon,
- HeaderMenuIconSpacer,
- HeaderMenuSaveIcons,
- HeaderMenuUndoIcons,
- HtmlSpan,
- LargeScreenOnly,
- Link,
- ListInput,
- Loading,
- LoadingStatus,
- Markdown,
- MarkdownInput,
- MeasurementInput,
- MeasurementsSetCard,
- MeasurementsView,
- MeasurementsEditor,
- MenuIcon,
- NumberInput,
- Null,
- PageLink,
- Pattern,
- PatternLayout,
- Popout,
- StringInput,
- SubAccordion,
- Spinner,
- SpinnerIcon,
- Tab,
- Tabs,
- TemporaryLoader,
- ToggleInput,
- Tooltip,
- UiPreferencesMenu,
- UiPreference,
- UndoStep,
- UndoStepTimeAgo,
- UndosView,
- UserSetPicker,
- Ux,
- HeaderMenuViewMenu,
- ViewPicker,
- ViewTypeIcon,
- WebLink,
- ZoomablePattern,
- ZoomContextProvider,
- // icons
- ApplyIcon,
- BeakerIcon,
- BookmarkIcon,
- BoolNoIcon,
- BoolYesIcon,
- CloseIcon,
- DesignIcon,
- DetailIcon,
- DocsIcon,
- DownIcon,
- EditIcon,
- ExpandIcon,
- ExportIcon,
- FailureIcon,
- FlagIcon,
- FlagNoteIcon,
- FlagInfoIcon,
- FlagTipIcon,
- FlagWarningIcon,
- FlagErrorIcon,
- FlagFixmeIcon,
- FlagExpandIcon,
- FlagOtionsIcon,
- GaugeIcon,
- GroupIcon,
- HelpIcon,
- IncludeIcon,
- KioskIcon,
- LeftIcon,
- ListIcon,
- LockIcon,
- MarginIcon,
- MeasurementsIcon,
- MeasurementsSetIcon,
- NoIcon,
- OkIcon,
- OptionsIcon,
- PaperlessIcon,
- PlusIcon,
- PrintIcon,
- ResetAllIcon,
- ResetIcon,
- RightIcon,
- RocketIcon,
- RotateIcon,
- SaIcon,
- SaveIcon,
- SaveAsIcon,
- ScaleIcon,
- SettingsIcon,
- SuccessIcon,
- TipIcon,
- TrashIcon,
- UiIcon,
- UndoIcon,
- UnitsIcon,
- UpIcon,
- UploadIcon,
- UxIcon,
- XrayIcon,
- ViewDraftIcon,
- ViewMeasurementsIcon,
- ViewTestIcon,
- ViewTimingIcon,
- ViewPrintLayoutIcon,
- ViewSaveIcon,
- ViewExportIcon,
- ViewEditSettingsIcon,
- ViewLogsIcon,
- ViewInspectIcon,
- ViewDocsIcon,
- ViewDesignsIcon,
- ViewViewPickerIcon,
- ViewUndosIcon,
- // menus
- MenuItem,
- MenuItemGroup,
- MenuItemTitle,
- MenuBoolInput,
- MenuConstantInput,
- MenuDegInput,
- MenuEditOption,
- MenuListInput,
- MenuListToggle,
- MenuMmInput,
- //MenuNumberInput,
- MenuUxSettingInput,
- MenuOnlySettingInput,
- MenuPctInput,
- MenuSliderInput,
- MenuBoolValue,
- MenuConstantOptionValue,
- MenuCountOptionValue,
- MenuDegOptionValue,
- MenuHighlightValue,
- MenuListOptionValue,
- MenuListValue,
- MenuMmOptionValue,
- MenuMmValue,
- MenuOnlySettingValue,
- MenuPctOptionValue,
- MenuScaleSettingValue,
- MenuShowValue,
-}
-
-/*
- * This method returns a component that can be swizzled
- * So either the passed-in component, or the default one
- */
-const swizzleComponents = (components = {}, Swizzled) => {
- /*
- * We need to return all resulting components, swizzled or not
- * So we create this object so we can pass that down
- */
- const all = {}
- for (let [name, Component] of Object.entries(defaultComponents)) {
- all[name] = components[name]
- ? (props) => components[name]({ Swizzled, ...props })
- : (props) =>
- }
-
- /*
- * Return all components
- */
- return all
-}
-
-/*
- * Named exports
- */
-export {
- swizzleComponents,
- // Re-export all components for specific imports
- Accordion,
- AuthWrapper,
- AuthMessageWrapper,
- BackIcon,
- ContactSupport,
- AuthRequired,
- AccountInactive,
- AccountDisabled,
- AccountProhibited,
- AccountStatusUnknown,
- AnchorLink,
- AsideViewMenu,
- AsideViewMenuIcons,
- AsideViewMenuButton,
- AsideViewMenuSpacer,
- RoleLacking,
- ConsentLacking,
- BaseAccordion,
- BookmarkedSetPicker,
- ButtonFrame,
- CardLink,
- CircleIcon,
- CoreSetting,
- CoreSettingsMenu,
- CuratedMeasurementsSetIcon,
- CuratedMeasurementsSetLineup,
- CuratedSetPicker,
- DesignOption,
- DesignOptionsMenu,
- DesignsView,
- DraftMenu,
- DraftView,
- ErrorView,
- SaveView,
- Flag,
- FlagsAccordionTitle,
- FlagsAccordionEntries,
- FlagTypeIcon,
- FormControl,
- HeaderMenu,
- HeaderMenuAllViews,
- HeaderMenuDraftView,
- HeaderMenuDraftViewDesignOptions,
- HeaderMenuDraftViewCoreSettings,
- HeaderMenuDraftViewUiPreferences,
- HeaderMenuDraftViewFlags,
- HeaderMenuDraftViewIcons,
- HeaderMenuButton,
- HeaderMenuDropdown,
- HeaderMenuIcon,
- HeaderMenuIconSpacer,
- HeaderMenuSaveIcons,
- HeaderMenuUndoIcons,
- HtmlSpan,
- LargeScreenOnly,
- Link,
- ListInput,
- Loading,
- LoadingStatus,
- Markdown,
- MarkdownInput,
- MeasurementInput,
- MeasurementsSetCard,
- MeasurementsView,
- MeasurementsEditor,
- MenuIcon,
- NumberInput,
- Null,
- PageLink,
- Pattern,
- PatternLayout,
- Popout,
- StringInput,
- SubAccordion,
- Spinner,
- SpinnerIcon,
- Tab,
- Tabs,
- TemporaryLoader,
- ToggleInput,
- Tooltip,
- UiPreferencesMenu,
- UiPreference,
- UndoStep,
- UndoStepTimeAgo,
- UndosView,
- UserSetPicker,
- Ux,
- HeaderMenuViewMenu,
- ViewPicker,
- ViewTypeIcon,
- WebLink,
- ZoomablePattern,
- ZoomContextProvider,
- // icons
- ApplyIcon,
- BeakerIcon,
- BookmarkIcon,
- BoolNoIcon,
- BoolYesIcon,
- CloseIcon,
- DesignIcon,
- DetailIcon,
- DocsIcon,
- DownIcon,
- EditIcon,
- ExpandIcon,
- ExportIcon,
- FailureIcon,
- FlagIcon,
- FlagNoteIcon,
- FlagInfoIcon,
- FlagTipIcon,
- FlagWarningIcon,
- FlagErrorIcon,
- FlagFixmeIcon,
- FlagExpandIcon,
- FlagOtionsIcon,
- GaugeIcon,
- GroupIcon,
- HelpIcon,
- IncludeIcon,
- KioskIcon,
- LeftIcon,
- ListIcon,
- LockIcon,
- MarginIcon,
- MeasurementsIcon,
- MeasurementsSetIcon,
- NoIcon,
- OkIcon,
- OptionsIcon,
- PaperlessIcon,
- PlusIcon,
- PrintIcon,
- ResetAllIcon,
- ResetIcon,
- RightIcon,
- RocketIcon,
- RotateIcon,
- SaIcon,
- SaveIcon,
- SaveAsIcon,
- ScaleIcon,
- SettingsIcon,
- SuccessIcon,
- TipIcon,
- TrashIcon,
- UiIcon,
- UndoIcon,
- UnitsIcon,
- UpIcon,
- UploadIcon,
- UxIcon,
- XrayIcon,
- ViewDraftIcon,
- ViewMeasurementsIcon,
- ViewTestIcon,
- ViewTimingIcon,
- ViewPrintLayoutIcon,
- ViewSaveIcon,
- ViewExportIcon,
- ViewEditSettingsIcon,
- ViewLogsIcon,
- ViewInspectIcon,
- ViewDocsIcon,
- ViewDesignsIcon,
- ViewViewPickerIcon,
- ViewUndosIcon,
- // menus
- MenuItem,
- MenuItemGroup,
- MenuItemTitle,
- MenuBoolInput,
- MenuConstantInput,
- MenuDegInput,
- MenuEditOption,
- MenuListInput,
- MenuListToggle,
- MenuMmInput,
- //MenuNumberInput,
- MenuUxSettingInput,
- MenuOnlySettingInput,
- MenuPctInput,
- MenuSliderInput,
- MenuBoolValue,
- MenuConstantOptionValue,
- MenuCountOptionValue,
- MenuDegOptionValue,
- MenuHighlightValue,
- MenuListOptionValue,
- MenuListValue,
- MenuMmOptionValue,
- MenuMmValue,
- MenuOnlySettingValue,
- MenuPctOptionValue,
- MenuScaleSettingValue,
- MenuShowValue,
-}
diff --git a/packages/react/components/Editor/swizzle/components/inputs.mjs b/packages/react/components/Editor/swizzle/components/inputs.mjs
deleted file mode 100644
index 9fa1b579575..00000000000
--- a/packages/react/components/Editor/swizzle/components/inputs.mjs
+++ /dev/null
@@ -1,349 +0,0 @@
-// Hooks
-import { useState } from 'react'
-
-/*
- * Helper component to wrap a form control with a label
- */
-export const FormControl = ({
- label, // the (top-left) label
- children, // Children to go inside the form control
- docs = false, // Optional top-right label
- labelBL = false, // Optional bottom-left label
- labelBR = false, // Optional bottom-right label
- forId = false, // ID of the for element we are wrapping
- Swizzled, // Object holding swizzled code
-}) => {
- if (labelBR && !labelBL) labelBL =
-
- const topLabelChildren = (
- <>
- {label}
- {docs ? (
-
-
- Swizzled.methods.setModal(
-
- {docs}
-
- )
- }
- >
-
-
-
- ) : null}
- >
- )
- const bottomLabelChildren = (
- <>
- {labelBL ? {labelBL} : null}
- {labelBR ? {labelBR} : null}
- >
- )
-
- return (
-
- {forId ? (
-
- {topLabelChildren}
-
- ) : (
-
{topLabelChildren}
- )}
- {children}
- {labelBL || labelBR ? (
- forId ? (
-
- {bottomLabelChildren}
-
- ) : (
-
{bottomLabelChildren}
- )
- ) : null}
-
- )
-}
-
-/*
- * Helper method to wrap content in a button
- */
-export const ButtonFrame = ({
- children, // Children of the button
- onClick, // onClick handler
- active, // Whether or not to render the button as active/selected
- accordion = false, // Set this to true to not set a background color when active
- dense = false, // Use less padding
-}) => (
-
- {children}
-
-)
-
-/*
- * Input for integers
- */
-export const NumberInput = ({
- label, // Label to use
- update, // onChange handler
- valid, // Method that should return whether the value is valid or not
- current, // The current value
- original, // The original value
- placeholder, // The placeholder text
- docs = false, // Docs to load, if any
- id = '', // An id to tie the input to the label
- labelBL = false, // Bottom-Left label
- labelBR = false, // Bottom-Right label
- max = 0,
- min = 220,
- step = 1,
- Swizzled, // Object holding swizzled code
-}) => (
-
- update(evt.target.value)}
- className={`input w-full input-bordered ${
- current === original ? 'input-secondary' : valid(current) ? 'input-success' : 'input-error'
- }`}
- {...{ max, min, step }}
- />
-
-)
-
-/*
- * Input for strings
- */
-export const StringInput = ({
- label, // Label to use
- update, // onChange handler
- valid, // Method that should return whether the value is valid or not
- current, // The current value
- original, // The original value
- placeholder, // The placeholder text
- docs = false, // Docs to load, if any
- id = '', // An id to tie the input to the label
- labelBL = false, // Bottom-Left label
- labelBR = false, // Bottom-Right label
- Swizzled, // Object holding swizzled code
-}) => (
-
- update(evt.target.value)}
- className={`input w-full input-bordered ${
- current === original ? 'input-secondary' : valid(current) ? 'input-success' : 'input-error'
- }`}
- />
-
-)
-
-/*
- * Input for a list of things to pick from
- */
-export const ListInput = ({
- update, // the onChange handler
- label, // The label
- list, // The list of items to present { val, label, desc }
- current, // The (value of the) current item
- docs = false, // Docs to load, if any
- Swizzled, // Object holding swizzled code
-}) => (
-
- {list.map((item, i) => (
- update(item.val)}
- >
-
-
{item.label}
- {item.desc ? (
-
- {item.desc}
-
- ) : null}
-
-
- ))}
-
-)
-
-/*
- * Input for markdown content
- */
-export const MarkdownInput = ({
- label, // The label
- current, // The current value (markdown)
- update, // The onChange handler
- placeholder, // The placeholder content
- docs = false, // Docs to load, if any
- id = '', // An id to tie the input to the label
- labelBL = false, // Bottom-Left label
- labelBR = false, // Bottom-Right label
- Swizzled, // Swizzled code
-}) => (
-
-
-
-
-
-
-
-
- {current}
-
-
-
-
-)
-
-export const MeasurementInput = ({
- imperial, // True for imperial, False for metric
- m, // The measurement name
- original, // The original value
- update, // The onChange handler
- placeholder, // The placeholder content
- docs = false, // Docs to load, if any
- id = '', // An id to tie the input to the label
- Swizzled, // Swizzled code
-}) => {
- const { t } = Swizzled.methods
- const isDegree = Swizzled.methods.isDegreeMeasurement(m)
- const units = imperial ? 'imperial' : 'metric'
-
- const [localVal, setLocalVal] = useState(
- typeof original === 'undefined'
- ? original
- : isDegree
- ? Number(original)
- : Swizzled.methods.measurementAsUnits(original, units)
- )
- const [validatedVal, setValidatedVal] = useState(
- Swizzled.methods.measurementAsUnits(original, units)
- )
- const [valid, setValid] = useState(null)
-
- // Update onChange
- const localUpdate = (newVal) => {
- setLocalVal(newVal)
- const parsedVal = isDegree
- ? Number(newVal)
- : Swizzled.methods.parseDistanceInput(newVal, imperial)
- if (parsedVal) {
- update(m, isDegree ? parsedVal : Swizzled.methods.measurementAsMm(parsedVal, units))
- setValid(true)
- setValidatedVal(parsedVal)
- } else setValid(false)
- }
-
- if (!m) return null
-
- // Various visual indicators for validating the input
- let inputClasses = 'input-secondary'
- let bottomLeftLabel = null
- if (valid === true) {
- inputClasses = 'input-success'
- const val = `${validatedVal}${isDegree ? '°' : imperial ? '"' : 'cm'}`
- bottomLeftLabel = {val}
- } else if (valid === false) {
- inputClasses = 'input-error'
- bottomLeftLabel = (
- ¯\_(ツ)_/¯
- )
- }
-
- /*
- * I'm on the fence here about using a text input rather than number
- * Obviously, number is the more correct option, but when the user enter
- * text, it won't fire an onChange event and thus they can enter text and it
- * will not be marked as invalid input.
- * See: https://github.com/facebook/react/issues/16554
- */
- return (
-
- localUpdate(evt.target.value)}
- className={`input w-full input-bordered ${inputClasses}`}
- />
-
- )
-}
-
-/*
- * Input for booleans
- */
-export const ToggleInput = ({
- label, // Label to use
- update, // onChange handler
- current, // The current value
- disabled = false, // Allows rendering a disabled view
- list = [true, false], // The values to chose between
- labels = ['Yes', 'No'], // The labels for the values
- on = true, // The value that should show the toggle in the 'on' state
- id = '', // An id to tie the input to the label
- labelTR = false, // Top-Right label
- labelBL = false, // Bottom-Left label
- labelBR = false, // Bottom-Right label
- Swizzled, // Object holding swizzled code
-}) => (
-
- update(list.indexOf(current) === 0 ? list[1] : list[0])}
- className="toggle my-3 toggle-primary"
- checked={list.indexOf(current) === 0 ? true : false}
- />
-
-)
diff --git a/packages/react/components/Editor/swizzle/components/large-screen-only.mjs b/packages/react/components/Editor/swizzle/components/large-screen-only.mjs
deleted file mode 100644
index e10119cfc44..00000000000
--- a/packages/react/components/Editor/swizzle/components/large-screen-only.mjs
+++ /dev/null
@@ -1 +0,0 @@
-export const LargeScreenOnly = ({ children }) => {children}
diff --git a/packages/react/components/Editor/swizzle/components/link.mjs b/packages/react/components/Editor/swizzle/components/link.mjs
deleted file mode 100644
index 91e05f0d4d3..00000000000
--- a/packages/react/components/Editor/swizzle/components/link.mjs
+++ /dev/null
@@ -1,48 +0,0 @@
-import Link from 'next/link'
-
-const AnchorLink = ({ id, txt = false, children, Swizzled }) => (
-
- {txt ? txt : children}
-
-)
-
-const PageLink = ({ href, txt = false, children, Swizzled }) => (
-
- {children ? children : txt}
-
-)
-
-const WebLink = ({ href, txt = false, children, Swizzled }) => (
-
- {children ? children : txt}
-
-)
-
-const CardLink = ({
- bg = 'bg-base-200',
- textColor = 'text-base-content',
- href,
- title,
- text,
- icon,
- Swizzled,
-}) => (
-
-
- {title}
- {icon}
-
- {text}
-
-)
-
-export { Link, AnchorLink, PageLink, WebLink, CardLink }
diff --git a/packages/react/components/Editor/swizzle/components/markdown.mjs b/packages/react/components/Editor/swizzle/components/markdown.mjs
deleted file mode 100644
index 6ff5cedafbf..00000000000
--- a/packages/react/components/Editor/swizzle/components/markdown.mjs
+++ /dev/null
@@ -1,3 +0,0 @@
-import Markdown from 'react-markdown'
-
-export { Markdown }
diff --git a/packages/react/components/Editor/swizzle/components/measurements-set-card.mjs b/packages/react/components/Editor/swizzle/components/measurements-set-card.mjs
deleted file mode 100644
index 213f2b8da85..00000000000
--- a/packages/react/components/Editor/swizzle/components/measurements-set-card.mjs
+++ /dev/null
@@ -1,94 +0,0 @@
-const sizes = { lg: 96, md: 52, sm: 36 }
-
-export const MeasurementsSetCard = ({
- set,
- onClick = false,
- href = false,
- useA = false,
- Design = false,
- language = false,
- size = 'lg',
- Swizzled,
-}) => {
- const s = sizes[size]
- const { t, hasRequiredMeasurements } = Swizzled.methods
- const { NoIcon, OkIcon } = Swizzled.components
-
- const wrapperProps = {
- className: `bg-base-300 aspect-square h-${s} w-${s} mb-2
- mx-auto flex flex-col items-start text-center justify-between rounded-none md:rounded shadow`,
- style: {
- backgroundImage: `url(${Swizzled.methods.cloudImageUrl({ type: 'w500', id: set.img })})`,
- backgroundSize: 'cover',
- backgroundRepeat: 'no-repeat',
- backgroundPosition: '50%',
- },
- }
- if (!set.img || set.img === 'default-avatar')
- wrapperProps.style.backgroundPosition = 'bottom right'
-
- let icon =
- let missingMeasies = ''
- let linebreak = ''
- const maxLength = 75
- if (Design) {
- const [hasMeasies, missing] = hasRequiredMeasurements(Design, set.measies)
- const iconClasses = 'w-8 h-8 p-1 rounded-full -mt-2 -ml-2 shadow'
- icon = hasMeasies ? (
-
- ) : (
-
- )
- if (missing.length > 0) {
- const translated = missing.map((m) => {
- return t(m)
- })
- let missingString = translated.join(', ')
- if (missingString.length > maxLength) {
- const lastSpace = missingString.lastIndexOf(', ', maxLength)
- missingString = missingString.substring(0, lastSpace) + ', ' + '...'
- }
- const measieClasses = 'font-normal text-xs'
- missingMeasies = {missingString}
- linebreak =
- }
- }
-
- const inner = (
- <>
- {icon}
-
- {language ? set[`name${Swizzled.methods.capitalize(language)}`] : set.name}
- {linebreak}
- {missingMeasies}
-
- >
- )
-
- // Is it a button with an onClick handler?
- if (onClick)
- return (
- onClick(set)}>
- {inner}
-
- )
-
- // Returns a link to an internal page
- if (href && !useA)
- return (
-
- {inner}
-
- )
-
- // Returns a link to an external page
- if (href && useA)
- return (
-
- {inner}
-
- )
-
- // Returns a div
- return {inner}
-}
diff --git a/packages/react/components/Editor/swizzle/components/popout.mjs b/packages/react/components/Editor/swizzle/components/popout.mjs
deleted file mode 100644
index 9eab3dd7ed7..00000000000
--- a/packages/react/components/Editor/swizzle/components/popout.mjs
+++ /dev/null
@@ -1,102 +0,0 @@
-import React, { useState } from 'react'
-
-const colors = {
- comment: 'secondary',
- note: 'primary',
- tip: 'accent',
- warning: 'error',
- error: 'error',
- fixme: 'warning',
- link: 'secondary',
- related: 'info',
- tldr: 'info',
- none: '',
-}
-
-/**
- * This popout component is a way to make some content stand out
- *
- * @param {object} components - Object holding possibly swizzled components
- * @param {object} methods - Object holding possibly swizzled methods
- */
-export const Popout = (props) => {
- /*
- * Load (swizzled) components
- */
- const { CloseIcon } = props.Swizzled.components
-
- /*
- * Load (swizzled) methods
- */
- const { t } = props.Swizzled.methods
-
- const [hide, setHide] = useState(false)
- if (hide) return null
-
- let type = 'none'
- for (const c in colors) {
- if (props[c]) type = c
- }
- const color = colors[type]
- const { className = '' } = props
-
- return props.compact ? (
-
-
-
- {props.title || (
- <>
- {t(`pe:${type}`).toUpperCase()}
- |
- >
- )}
-
-
{props.noP ? props.children :
{props.children}
}
-
-
- ) : (
-
-
-
-
-
- {type === 'tldr' ? 'TL;DR' : t(`pe:${type}`).toUpperCase()}
-
-
- {type === 'comment' && (
- <>
- {' '}
- by {props.by}
- >
- )}
-
-
- {props.hideable && (
-
setHide(true)} className="hover:text-secondary" title="Close">
-
-
- )}
-
-
{props.children}
- {type === 'comment' &&
{props.by}
}
-
-
- )
-}
diff --git a/packages/react/components/Editor/swizzle/components/spinner.mjs b/packages/react/components/Editor/swizzle/components/spinner.mjs
deleted file mode 100644
index 2c1f9ee445a..00000000000
--- a/packages/react/components/Editor/swizzle/components/spinner.mjs
+++ /dev/null
@@ -1,21 +0,0 @@
-export const Spinner = ({ className = 'h-6 w-6 animate-spin' }) => (
-
-
-
-
-)
-
-export const Loading = () => (
-
-)
diff --git a/packages/react/components/Editor/swizzle/components/tabs.mjs b/packages/react/components/Editor/swizzle/components/tabs.mjs
deleted file mode 100644
index 29c7ff1df6b..00000000000
--- a/packages/react/components/Editor/swizzle/components/tabs.mjs
+++ /dev/null
@@ -1,66 +0,0 @@
-import React, { useState } from 'react'
-
-export const Tabs = ({ tabs = '', active = 0, children, withModal = false, Swizzled }) => {
- // Keep active tab in state
- const [activeTab, setActiveTab] = useState(active)
-
- /*
- * In MDX, tabs are passed as a comma-seperated list.
- * In React, they come as an array.
- * So we need to handle both cases.
- */
- const tablist = Array.isArray(tabs) ? tabs : tabs.split(',').map((tab) => tab.trim())
-
- /*
- * Don't bother unless there's actual tabs to show
- */
- if (!tablist) return null
-
- /*
- * Pass down activeTab and tabId for conditional rendering
- */
- const childrenWithTabSetter = children.map((child, tabId) =>
- React.cloneElement(child, { activeTab, tabId, key: tabId })
- )
-
- return (
-
-
- {tablist.map((title, tabId) => {
- const btnClasses = `text-lg font-bold capitalize tab h-auto tab-bordered grow py-2 ${
- activeTab === tabId ? 'tab-active' : ''
- }`
-
- return withModal && activeTab === tabId ? (
-
- Swizzled.methods.setModal(
-
- {childrenWithTabSetter}
-
- )
- }
- >
- {title}
-
-
- ) : (
- setActiveTab(tabId)}>
- {title}
-
- )
- })}
-
-
{childrenWithTabSetter}
-
- )
-}
-
-export const Tab = ({ children, tabId, activeTab }) => (activeTab === tabId ? children : null)
diff --git a/packages/react/components/Editor/swizzle/hooks/index.mjs b/packages/react/components/Editor/swizzle/hooks/index.mjs
deleted file mode 100644
index ddde3bcc2e5..00000000000
--- a/packages/react/components/Editor/swizzle/hooks/index.mjs
+++ /dev/null
@@ -1,73 +0,0 @@
-/*************************************************************************
- * *
- * FreeSewing's pattern editor allows swizzling hooks *
- * *
- * To 'swizzle' means to replace the default implementation of a *
- * hook with a custom one. It allows one to customize *
- * the pattern editor. *
- * *
- * This file holds the 'swizzleHooks' method that will return *
- * the various hooks that can be swizzled, or their default *
- * implementation. *
- * *
- * To use a custom version, simply pas it as a prop into the editor *
- * under the 'hooks' key. So to pass a custom 'useAccount' method *
- * (used for loading the user's account data) you do: *
- * *
- * *
- * *
- *************************************************************************/
-
-/*
- * Import of components that can be swizzled
- */
-// useAccount
-import { useAccount } from './use-account.mjs'
-import { useBackend } from './use-backend.mjs'
-import {
- useReactEditorState,
- useStorageEditorState,
- useSessionEditorState,
- useUrlEditorState,
-} from './use-editor-state.mjs'
-
-/*
- * We support different state backend, so let's handle those
- */
-const stateBackends = {
- react: useReactEditorState,
- storage: useStorageEditorState,
- session: useSessionEditorState,
- url: useUrlEditorState,
-}
-
-/**
- * This object holds all hooks that can be swizzled
- */
-const defaultHooks = (config) => ({
- useAccount,
- useBackend,
- useEditorState: stateBackends[config.stateBackend] || useReactEditorState,
-})
-
-/*
- * This method returns hooks that can be swizzled
- * So either the passed-in methods, or the default ones
- */
-export const swizzleHooks = (hooks = {}, Swizzled) => {
- /*
- * We need to return the resulting hooks, swizzled or not
- * So we put this in this object so we can pass that down
- */
- const all = {}
- for (const [name, hook] of Object.entries(defaultHooks(Swizzled.config))) {
- all[name] = hooks[name]
- ? (...params) => hooks[name](Swizzled, ...params)
- : (...params) => hook(Swizzled, ...params)
- }
-
- /*
- * Return all hooks
- */
- return all
-}
diff --git a/packages/react/components/Editor/swizzle/hooks/use-account.mjs b/packages/react/components/Editor/swizzle/hooks/use-account.mjs
deleted file mode 100644
index 9e1b7e1a7f9..00000000000
--- a/packages/react/components/Editor/swizzle/hooks/use-account.mjs
+++ /dev/null
@@ -1,59 +0,0 @@
-import useLocalStorageState from 'use-local-storage-state'
-
-/*
- * Make it possible to always check for account.username and account.ux
- */
-const noAccount = { username: false, ux: 3 }
-
-/*
- * The useAccount hook
- */
-export function useAccount(Swizzled) {
- // (persisted) State (saved to local storage)
- const [account, setAccount] = useLocalStorageState('fs-account', { defaultValue: noAccount })
- const [admin, setAdmin] = useLocalStorageState('fs-admin', { defaultValue: noAccount })
- const [token, setToken] = useLocalStorageState('fs-token', { defaultValue: null })
- const [seenUser, setSeenUser] = useLocalStorageState('fs-seen-user', { defaultValue: false })
-
- // Clear user data. This gets called when signing out
- const signOut = () => {
- setAccount(noAccount)
- setToken(null)
- }
-
- // Impersonate a user.
- // Only admins can do this but that is enforced at the backend.
- const impersonate = (data) => {
- setAdmin({ token, account })
- const newAccount = {
- ...data.account,
- impersonatingAdmin: { id: account.id, username: account.username },
- }
- setAdmin({ token, account: { ...account } })
- setAccount(newAccount)
- setToken(data.token)
- }
-
- const stopImpersonating = () => {
- setAccount(admin.account)
- setToken(admin.token)
- clearAdmin()
- }
-
- const clearAdmin = () => setAdmin(noAccount)
-
- return {
- account,
- setAccount,
- token,
- setToken,
- seenUser,
- setSeenUser,
- signOut,
- admin,
- clearAdmin,
- impersonate,
- stopImpersonating,
- ux: account?.control || account?.ux || Swizzled.config.defaultUx,
- }
-}
diff --git a/packages/react/components/Editor/swizzle/hooks/use-backend.mjs b/packages/react/components/Editor/swizzle/hooks/use-backend.mjs
deleted file mode 100644
index c54b3087693..00000000000
--- a/packages/react/components/Editor/swizzle/hooks/use-backend.mjs
+++ /dev/null
@@ -1,633 +0,0 @@
-// Dependencies
-import axios from 'axios'
-// Hooks
-import { useMemo } from 'react'
-import { freeSewingConfig } from 'shared/config/freesewing.config.mjs'
-
-/*
- * Helper methods to interact with the FreeSewing backend
- */
-const apiHandler = axios.create({
- baseURL: freeSewingConfig.backend,
- timeout: 6660,
-})
-
-const auth = (token) =>
- token ? { headers: { Authorization: 'Bearer ' + token } } : { headers: {} }
-
-/*
- * This api object handles async code for different HTTP methods
- */
-const api = {
- get: async (uri, config = {}) => {
- let result
- try {
- result = await apiHandler.get(uri, config)
- return result
- } catch (err) {
- return err
- }
- },
- post: async (uri, data = null, config = {}) => {
- let result
- try {
- result = await apiHandler.post(uri, data, config)
- return result
- } catch (err) {
- return err
- }
- },
- put: async (uri, data = null, config = {}) => {
- let result
- try {
- result = await apiHandler.put(uri, data, config)
- return result
- } catch (err) {
- return err
- }
- },
- patch: async (uri, data = null, config = {}) => {
- let result
- try {
- result = await apiHandler.patch(uri, data, config)
- return result
- } catch (err) {
- return err
- }
- },
- delete: async (uri, config = {}) => {
- let result
- try {
- result = await apiHandler.delete(uri, config)
- return result
- } catch (err) {
- return err
- }
- },
-}
-
-/*
- * Helper method to handle the response and verify that it was successful
- */
-const responseHandler = (response, expectedStatus = 200, expectData = true) => {
- if (response && response.status === expectedStatus) {
- if (!expectData || response.data) {
- return { success: true, data: response.data, response }
- }
- return { success: true, response }
- }
-
- // Unpack axios errors
- if (response?.name === 'AxiosError')
- return {
- success: false,
- status: response.response?.status,
- data: response.response?.data,
- error: response.message,
- }
-
- return { success: false, response }
-}
-
-function Backend(auth) {
- this.auth = auth
-}
-
-/*
- * backend.signUp: User signup
- */
-Backend.prototype.signUp = async function ({ email, language }) {
- return responseHandler(await api.post('/signup', { email, language }), 201)
-}
-
-/*
- * backend.oauthInit: Init Oauth flow for oauth provider
- */
-Backend.prototype.oauthInit = async function ({ provider, language }) {
- return responseHandler(await api.post('/signin/oauth/init', { provider, language }))
-}
-
-/*
- * backend.oauthSignIn: User sign in via oauth provider
- */
-Backend.prototype.oauthSignIn = async function ({ state, code, provider }) {
- return responseHandler(await api.post('/signin/oauth', { state, code, provider }))
-}
-
-/*
- * Backend.prototype.loadConfirmation: Load a confirmation
- */
-Backend.prototype.loadConfirmation = async function ({ id, check }) {
- return responseHandler(await api.get(`/confirmations/${id}/${check}`))
-}
-/*
- * Backend.prototype.confirmSignup: Confirm a signup
- */
-Backend.prototype.confirmSignup = async function ({ id, consent }) {
- return responseHandler(await api.post(`/confirm/signup/${id}`, { consent }))
-}
-
-/*
- * Backend.prototype.signIn: User signin/login
- */
-Backend.prototype.signIn = async function ({ username, password = false, token = false }) {
- return password === false
- ? responseHandler(await api.post('/signinlink', { username }))
- : responseHandler(await api.post('/signin', { username, password, token }))
-}
-
-/*
- * Backend.prototype.signInFromLink: Trade in sign-in link id & check for JWT token
- */
-Backend.prototype.signInFromLink = async function ({ id, check }) {
- return responseHandler(await api.post(`/signinlink/${id}/${check}`))
-}
-
-/*
- * Generic update account method
- */
-Backend.prototype.updateAccount = async function (data) {
- return responseHandler(await api.patch(`/account/jwt`, data, this.auth))
-}
-
-/*
- * Update consent (uses the jwt-guest middleware)
- */
-Backend.prototype.updateConsent = async function (consent) {
- return responseHandler(await api.patch(`/consent/jwt`, { consent }, this.auth))
-}
-
-/*
- * Checks whether a username is available
- */
-Backend.prototype.isUsernameAvailable = async function (username) {
- const response = await api.post(`/available/username/jwt`, { username }, this.auth)
-
- // 404 means username is available, which is success in this case
- return response.status === 404
- ? { success: true, data: false, available: true, response }
- : { success: false, available: false, response }
-}
-
-/*
- * Remove account method
- */
-Backend.prototype.removeAccount = async function () {
- return responseHandler(await api.delete(`/account/jwt`, this.auth))
-}
-/*
- * Enable MFA
- */
-Backend.prototype.enableMfa = async function () {
- return responseHandler(await api.post(`/account/mfa/jwt`, { mfa: true }, this.auth))
-}
-
-/*
- * Confirm MFA
- */
-Backend.prototype.confirmMfa = async function (data) {
- return responseHandler(await api.post(`/account/mfa/jwt`, { ...data, mfa: true }, this.auth))
-}
-
-/*
- * Disable MFA
- */
-Backend.prototype.disableMfa = async function (data) {
- return responseHandler(await api.post(`/account/mfa/jwt`, { ...data, mfa: false }, this.auth))
-}
-
-/*
- * Reload account
- */
-Backend.prototype.reloadAccount = async function () {
- return responseHandler(await api.get(`/whoami/jwt`, this.auth))
-}
-
-/*
- * Export account data
- */
-Backend.prototype.exportAccount = async function () {
- return responseHandler(await api.get(`/account/export/jwt`, this.auth))
-}
-
-/*
- * Restrict processing of account data
- */
-Backend.prototype.restrictAccount = async function () {
- return responseHandler(await api.get(`/account/restrict/jwt`, this.auth))
-}
-
-/*
- * Remove account
- */
-Backend.prototype.restrictAccount = async function () {
- return responseHandler(await api.delete(`/account/jwt`, this.auth))
-}
-
-/*
- * Load all user data
- */
-Backend.prototype.getUserData = async function (uid) {
- return responseHandler(await api.get(`/users/${uid}/jwt`, this.auth))
-}
-
-/*
- * Load user profile
- */
-Backend.prototype.getProfile = async function (uid) {
- return responseHandler(await api.get(`/users/${uid}`))
-}
-
-/*
- * Load user count
- */
-Backend.prototype.getUserCount = async function () {
- return responseHandler(await api.get(`/info/users`))
-}
-
-/*
- * Load stats
- */
-Backend.prototype.getStats = async function () {
- return responseHandler(await api.get(`/info/stats`))
-}
-
-/*
- * Create bookmark
- */
-Backend.prototype.createBookmark = async function (data) {
- return responseHandler(await api.post(`/bookmarks/jwt`, data, this.auth), 201)
-}
-
-/*
- * Get bookmark
- */
-Backend.prototype.getBookmark = async function (id) {
- return responseHandler(await api.get(`/bookmarks/${id}/jwt`, this.auth))
-}
-/*
- * Get bookmarks
- */
-Backend.prototype.getBookmarks = async function () {
- return responseHandler(await api.get(`/bookmarks/jwt`, this.auth))
-}
-
-/*
- * Remove bookmark
- */
-Backend.prototype.removeBookmark = async function (id) {
- const response = await api.delete(`/bookmarks/${id}/jwt`, this.auth)
-
- return response && response.status === 204 ? true : false
-}
-
-/*
- * Create API key
- */
-Backend.prototype.createApikey = async function (data) {
- return responseHandler(await api.post(`/apikeys/jwt`, data, this.auth), 201)
-}
-
-/*
- * Get API key
- */
-Backend.prototype.getApikey = async function (id) {
- return responseHandler(await api.get(`/apikeys/${id}/jwt`, this.auth))
-}
-
-/*
- * Get API keys
- */
-Backend.prototype.getApikeys = async function () {
- return responseHandler(await api.get(`/apikeys/jwt`, this.auth))
-}
-
-/*
- * Remove API key
- */
-Backend.prototype.removeApikey = async function (id) {
- const response = await api.delete(`/apikeys/${id}/jwt`, this.auth)
-
- return response && response.status === 204 ? true : false
-}
-
-/*
- * Get measurements sets
- */
-Backend.prototype.getSets = async function () {
- return responseHandler(await api.get(`/sets/jwt`, this.auth))
-}
-
-/*
- * Get measurements set
- */
-Backend.prototype.getSet = async function (id) {
- return responseHandler(await api.get(`/sets/${id}/jwt`, this.auth))
-}
-
-/*
- * Get public measurements set
- */
-Backend.prototype.getPublicSet = async function (id) {
- return responseHandler(await api.get(`/sets/${id}.json`))
-}
-
-/*
- * Create measurements set
- */
-Backend.prototype.createSet = async function (data) {
- return responseHandler(await api.post(`/sets/jwt`, data, this.auth), 201)
-}
-
-/*
- * Remove measurements set
- */
-Backend.prototype.removeSet = async function (id) {
- const response = await api.delete(`/sets/${id}/jwt`, this.auth)
-
- return response && response.status === 204 ? true : false
-}
-
-/*
- * Generic update measurements set method
- */
-Backend.prototype.updateSet = async function (id, data) {
- return responseHandler(await api.patch(`/sets/${id}/jwt`, data, this.auth))
-}
-
-/*
- * Get curated measurements sets
- */
-Backend.prototype.getCuratedSets = async function () {
- return responseHandler(await api.get(`/curated-sets`))
-}
-
-/*
- * Get measurements sets suggested for curation
- */
-Backend.prototype.getSuggestedSets = async function () {
- return responseHandler(await api.get(`/suggested-sets/jwt`, this.auth))
-}
-
-/*
- * Get option packs suggested for curation
- */
-Backend.prototype.getSuggestedPacks = async function () {
- return responseHandler(await api.get(`/suggested-packs/jwt`, this.auth))
-}
-
-/*
- * Remove suggested measurements set
- */
-Backend.prototype.removeSuggestedMeasurementsSet = async function (id) {
- const response = await api.delete(`/suggested-sets/${id}/jwt`, this.auth)
-
- return response && response.status === 204 ? true : false
-}
-
-/*
- * Get curated measurements set
- */
-Backend.prototype.getCuratedSet = async function (id) {
- return responseHandler(await api.get(`/curated-sets/${id}`))
-}
-
-/*
- * Generic update curated measurements set method
- */
-Backend.prototype.updateCuratedSet = async function (id, data) {
- return responseHandler(await api.patch(`/curated-sets/${id}/jwt`, data, this.auth))
-}
-
-/*
- * Remove curated measurements set
- */
-Backend.prototype.removeCuratedMeasurementsSet = async function (id) {
- const response = await api.delete(`/curated-sets/${id}/jwt`, this.auth)
-
- return response && response.status === 204 ? true : false
-}
-
-/*
- * Get pattern
- */
-Backend.prototype.getPattern = async function (id) {
- return responseHandler(await api.get(`/patterns/${id}/jwt`, this.auth))
-}
-
-/*
- * Get public pattern
- */
-Backend.prototype.getPublicPattern = async function (id) {
- return responseHandler(await api.get(`/patterns/${id}.json`))
-}
-
-/*
- * Get patterns
- */
-Backend.prototype.getPatterns = async function () {
- return responseHandler(await api.get(`/patterns/jwt`, this.auth))
-}
-
-/*
- * Create pattern
- */
-Backend.prototype.createPattern = async function (data) {
- return responseHandler(await api.post(`/patterns/jwt`, data, this.auth), 201)
-}
-
-/*
- * Remove pattern
- */
-Backend.prototype.removePattern = async function (id) {
- const response = await api.delete(`/patterns/${id}/jwt`, this.auth)
-
- return response && response.status === 204 ? true : false
-}
-
-/*
- * Generic update pattern set method
- */
-Backend.prototype.updatePattern = async function (id, data) {
- return responseHandler(await api.patch(`/patterns/${id}/jwt`, data, this.auth))
-}
-
-/*
- * Create GitHub issue
- */
-Backend.prototype.createIssue = async function (data) {
- return responseHandler(await api.post(`/issues`, data), 201)
-}
-
-/*
- * Create GitHub discussion
- */
-Backend.prototype.createDiscussion = async function (data) {
- return responseHandler(await api.post(`/discussions`, data), 201)
-}
-
-/*
- * Check whether a slug is available
- */
-Backend.prototype.isSlugAvailable = async function ({ slug, type }) {
- const response = await api.get(`/slugs/${type}/${slug}/jwt`, this.auth)
-
- // 404 means username is available, which is success in this case
- return response.status === 200
- ? { success: false, available: false, response }
- : { success: true, data: false, available: true, response }
-}
-
-/*
- * Create showcase/blog post (pull request)
- */
-Backend.prototype.createPost = async function (type, data) {
- return responseHandler(await api.post(`/flows/pr/${type}/jwt`, data, this.auth), 201)
-}
-
-/*
- * Send translation invite
- */
-Backend.prototype.sendTranslatorInvite = async function (language) {
- return responseHandler(await api.post(`/flows/translator-invite/jwt`, { language }, this.auth))
-}
-
-/*
- * Send language suggestion
- */
-Backend.prototype.sendLanguageSuggestion = async function (data) {
- return responseHandler(await api.post(`/flows/language-suggestion/jwt`, data, this.auth))
-}
-
-/*
- * Subscribe to newsletter
- */
-Backend.prototype.newsletterSubscribe = async function ({ email, language }) {
- return responseHandler(await api.post('/subscriber', { email, language }))
-}
-
-/*
- * Confirm newsletter subscribe
- */
-Backend.prototype.confirmNewsletterSubscribe = async function ({ id, ehash }) {
- return responseHandler(await api.put('/subscriber', { id, ehash }))
-}
-
-/*
- * Newsletter unsubscribe
- */
-Backend.prototype.newsletterUnsubscribe = async function (ehash) {
- return responseHandler(await api.delete(`/subscriber/${ehash}`))
-}
-
-/*
- * Upload an image
- */
-Backend.prototype.uploadImage = async function (body) {
- return responseHandler(await api.post('/images/jwt', body, this.auth))
-}
-
-/*
- * Upload an image anonymously
- */
-Backend.prototype.uploadAnonImage = async function (body) {
- return responseHandler(await api.post('/images', body))
-}
-
-/*
- * Remove an (uploaded) image
- */
-Backend.prototype.removeImage = async function (id) {
- return responseHandler(await api.delete(`/images/${id}/jwt`, this.auth))
-}
-
-/*
- * Suggest a measurements set for curation
- */
-Backend.prototype.suggestCset = async function (data) {
- return responseHandler(await api.post(`/curated-sets/suggest/jwt`, data, this.auth))
-}
-
-/*
- * Suggest an option pack
- */
-Backend.prototype.suggestOpack = async function (data) {
- return responseHandler(await api.post(`/option-packs/suggest/jwt`, data, this.auth))
-}
-
-/*
- * Create a curated set from a suggested set
- */
-Backend.prototype.csetFromSuggestedSet = async function (id) {
- return responseHandler(await api.post(`/curated-sets/from/${id}/jwt`, {}, this.auth))
-}
-
-/*
- * Ping backend to see if current token is still valid
- */
-Backend.prototype.ping = async function () {
- return responseHandler(await api.get(`/whoami/jwt`, this.auth))
-}
-
-/*
- * Search user (admin method)
- */
-Backend.prototype.adminSearchUsers = async function (q) {
- return responseHandler(await api.post('/admin/search/users/jwt', { q }, this.auth))
-}
-
-/*
- * Load user (admin method)
- */
-Backend.prototype.adminLoadUser = async function (id) {
- return responseHandler(await api.get(`/admin/user/${id}/jwt`, this.auth))
-}
-
-/*
- * Update user (admin method)
- */
-Backend.prototype.adminUpdateUser = async function ({ id, data }) {
- return responseHandler(await api.patch(`/admin/user/${id}/jwt`, data, this.auth))
-}
-
-/*
- * Impersonate user (admin method)
- */
-Backend.prototype.adminImpersonateUser = async function (id) {
- return responseHandler(await api.get(`/admin/impersonate/${id}/jwt`, this.auth))
-}
-
-/*
- * Load newsletter subscribers (admin method)
- */
-Backend.prototype.adminLoadSubscribers = async function () {
- return responseHandler(await api.get(`/admin/subscribers/jwt`, this.auth))
-}
-
-/*
- * Verify an admin account while impersonating another user
- */
-Backend.prototype.adminPing = async function (token) {
- return responseHandler(await api.get(`/whoami/jwt`, auth(token)))
-}
-
-/*
- * backend.img: Generate a social media image
- */
-Backend.prototype.img = async function (data) {
- return responseHandler(await api.post('/img', data, { responseType: 'arraybuffer' }))
-}
-
-export function useBackend(Swizzled) {
- /*
- * Load swizzled useAccount hook and use it
- */
- const { token } = Swizzled.hooks.useAccount()
-
- /*
- * This backend object is what we'll end up returning
- */
- const backend = useMemo(() => new Backend(auth(token)), [token])
-
- return backend
-}