@sanity/document-internationalization 0.0.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +30 -0
  3. package/config.dist.json +4 -0
  4. package/lib/actions/DeleteWithi18nAction.d.ts +16 -0
  5. package/lib/actions/DuplicateWithi18nAction.d.ts +8 -0
  6. package/lib/actions/PublishWithi18nAction.d.ts +9 -0
  7. package/lib/actions/index.d.ts +8 -0
  8. package/lib/actions/index.js +19549 -0
  9. package/lib/actions/index.js.map +1 -0
  10. package/lib/badges/LanguageBadge.d.ts +5 -0
  11. package/lib/badges/index.d.ts +5 -0
  12. package/lib/badges/index.js +17324 -0
  13. package/lib/badges/index.js.map +1 -0
  14. package/lib/constants/I18nDelimiter.d.ts +1 -0
  15. package/lib/constants/I18nPrefix.d.ts +1 -0
  16. package/lib/constants/IdStructure.d.ts +4 -0
  17. package/lib/constants/LanguageCultures.d.ts +4 -0
  18. package/lib/constants/ReferenceBehavior.d.ts +5 -0
  19. package/lib/constants/UiMessages.d.ts +34 -0
  20. package/lib/constants/index.d.ts +6 -0
  21. package/lib/constants/index.js +736 -0
  22. package/lib/constants/index.js.map +1 -0
  23. package/lib/structure/IDefaultDocumentNodeStructureProps.d.ts +4 -0
  24. package/lib/structure/components/Flag/Flag.d.ts +6 -0
  25. package/lib/structure/components/Flag/allEmojiFlagCodes.d.ts +1 -0
  26. package/lib/structure/components/Flag/index.d.ts +1 -0
  27. package/lib/structure/components/MaintenanceTab/MaintenanceTab.d.ts +2 -0
  28. package/lib/structure/components/MaintenanceTab/index.d.ts +1 -0
  29. package/lib/structure/components/MaintenanceTabResult/MaintenanceTabResult.d.ts +10 -0
  30. package/lib/structure/components/MaintenanceTabResult/index.d.ts +1 -0
  31. package/lib/structure/components/MaintenanceTabTypeSelector/MaintenanceTabTypeSelector.d.ts +8 -0
  32. package/lib/structure/components/MaintenanceTabTypeSelector/index.d.ts +1 -0
  33. package/lib/structure/components/TranslationLink/TranslationLink.d.ts +12 -0
  34. package/lib/structure/components/TranslationLink/index.d.ts +1 -0
  35. package/lib/structure/components/TranslationsComponentFactory/TranslationsComponentFactory.d.ts +5 -0
  36. package/lib/structure/components/TranslationsComponentFactory/index.d.ts +1 -0
  37. package/lib/structure/hooks/index.d.ts +1 -0
  38. package/lib/structure/hooks/useDocumentsInformation.d.ts +20 -0
  39. package/lib/structure/index.d.ts +13 -0
  40. package/lib/structure/index.js +20464 -0
  41. package/lib/structure/index.js.map +1 -0
  42. package/lib/structure/utils/fixBaseDocumentRefs.d.ts +2 -0
  43. package/lib/structure/utils/fixBaseLanguageMismatch.d.ts +2 -0
  44. package/lib/structure/utils/fixIdStructureMismatchDocuments.d.ts +2 -0
  45. package/lib/structure/utils/fixLanguageFields.d.ts +2 -0
  46. package/lib/structure/utils/fixOrphanedDocuments.d.ts +2 -0
  47. package/lib/structure/utils/fixReferenceBehaviorMismatch.d.ts +2 -0
  48. package/lib/structure/utils/fixTranslationRefs.d.ts +2 -0
  49. package/lib/structure/utils/index.d.ts +6 -0
  50. package/lib/types/IEditState.d.ts +5 -0
  51. package/lib/types/ILanguageObject.d.ts +6 -0
  52. package/lib/types/ILanguageQuery.d.ts +10 -0
  53. package/lib/types/IResolverProps.d.ts +9 -0
  54. package/lib/types/ITranslationRef.d.ts +6 -0
  55. package/lib/types/IType.d.ts +38 -0
  56. package/lib/types/IUseDocumentOperationResult.d.ts +11 -0
  57. package/lib/types/TFieldNamesConfig.d.ts +5 -0
  58. package/lib/types/TLanguage.d.ts +2 -0
  59. package/lib/types/TLanguagesOption.d.ts +3 -0
  60. package/lib/types/TSchema.d.ts +6 -0
  61. package/lib/types/Ti18nConfig.d.ts +10 -0
  62. package/lib/types/Ti18nDocument.d.ts +13 -0
  63. package/lib/types/Ti18nSchema.d.ts +5 -0
  64. package/lib/types/index.d.ts +14 -0
  65. package/lib/utils/baseToTop.d.ts +1 -0
  66. package/lib/utils/batch.d.ts +1 -0
  67. package/lib/utils/buildDocId.d.ts +1 -0
  68. package/lib/utils/createSanityReference.d.ts +5 -0
  69. package/lib/utils/getAllSchemas.d.ts +2 -0
  70. package/lib/utils/getBaseIdFromId.d.ts +1 -0
  71. package/lib/utils/getBaseLanguage.d.ts +2 -0
  72. package/lib/utils/getConfig.d.ts +6 -0
  73. package/lib/utils/getFlag.d.ts +2 -0
  74. package/lib/utils/getLanguageFromId.d.ts +1 -0
  75. package/lib/utils/getLanguagesFromOption.d.ts +3 -0
  76. package/lib/utils/getSanityClient.d.ts +1 -0
  77. package/lib/utils/getSchema.d.ts +2 -0
  78. package/lib/utils/getTranslationsForId.d.ts +2 -0
  79. package/lib/utils/index.d.ts +16 -0
  80. package/lib/utils/index.js +18425 -0
  81. package/lib/utils/index.js.map +1 -0
  82. package/lib/utils/makeObjectKey.d.ts +1 -0
  83. package/lib/utils/normalizeLanguageList.d.ts +6 -0
  84. package/lib/utils/serializePath.d.ts +2 -0
  85. package/lib/utils/updateIntlFieldsForDocument.d.ts +2 -0
  86. package/lib/validators/index.d.ts +1 -0
  87. package/lib/validators/index.js +17309 -0
  88. package/lib/validators/index.js.map +1 -0
  89. package/lib/validators/isSlugUnique.d.ts +2 -0
  90. package/package.json +151 -0
  91. package/sanity.json +28 -0
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright © 2020 Liam Martens
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # Document Internationalization Plugin for Sanity
2
+ [![npm version](https://img.shields.io/npm/v/@sanity/document-internationalization.svg?style=flat)](https://www.npmjs.com/package/@sanity/document-internationalization)
3
+
4
+ ## Default solution
5
+ When you want to create translations in Sanity they suggest [following approach](https://www.sanity.io/docs/localization).
6
+ This definitely works, but makes the UI very clunky as you get more fields that require translations.
7
+
8
+ ![Default Solution](https://raw.githubusercontent.com/sanity-io/document-internationalization/main/docs/img/default-solution.gif)
9
+
10
+ ## With intl-plugin
11
+ With the intl plugin you will get a cleaner UI for creating translatable documents as the translations are managed document wide.
12
+ ![Intl Plugin Document Translation](https://raw.githubusercontent.com/sanity-io/document-internationalization/main/docs/img/intl-plugin-document.gif)
13
+
14
+ ## Important notice before getting started
15
+ An important decision you will need to make is whether to use subpath or delimiter based IDs. Subpaths are slightly easier to query using GROQ, but they also make documents Private, meaning they can only be accessed using an Access Token. Requests with Access Tokens cannot be cached, and so API usage will dramatically increase.
16
+
17
+ ## Documentation
18
+ 1. [Installation Instructions](docs/installation.md)
19
+ 2. [General Configuration](docs/general-configuration.md)
20
+ 3. [How to use](docs/usage-intl-doc.md)
21
+ 4. [Datastructure](docs/datastructure-intl-doc.md)
22
+ 5. [Translation Maintenance](docs/translation-maintenance.md)
23
+ 6. [GraphQL support](docs/graphql-intl-doc.md)
24
+ 7. [Advanced languages](docs/advanced-languages.md)
25
+ 8. [Usage with custom publish action](docs/usage-with-custom-publish.md)
26
+ 9. [GROQ Cheatsheet](/docs/groq-cheatsheet.md)
27
+ 10. [Coming from sanity-plugin-intl-input](docs/coming-from-sanity-plugin-intl-input.md)
28
+ ## Other resources
29
+ * [Great guide by nilsnh](https://nilsnh.no/2021/08/22/guide-localizing-sanity-cms-with-the-intl-input-plugin/)
30
+ * [Sanity Starter](https://www.sanity.io/create?template=sanity-io%2Fsanity-template-translation-examples)
@@ -0,0 +1,4 @@
1
+ {
2
+ "idStructure": "delimiter",
3
+ "referenceBehavior": "hard"
4
+ }
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ import { IResolverProps } from '../types';
3
+ export declare const DeleteWithi18nAction: ({ id, type, onComplete }: IResolverProps) => {
4
+ onHandle: () => void;
5
+ color: string;
6
+ icon: any;
7
+ disabled: boolean;
8
+ title: any;
9
+ label: string;
10
+ dialog: false | {
11
+ type: string;
12
+ onClose: (() => void) | undefined;
13
+ title: string;
14
+ content: JSX.Element | null;
15
+ };
16
+ };
@@ -0,0 +1,8 @@
1
+ import { IResolverProps } from '../types';
2
+ export declare const DuplicateWithi18nAction: (props: IResolverProps) => {
3
+ icon: any;
4
+ disabled: boolean;
5
+ title: any;
6
+ label: string;
7
+ onHandle: () => Promise<void>;
8
+ };
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ import { IResolverProps } from '../types';
3
+ export declare const PublishWithi18nAction: ({ type, id, onComplete }: IResolverProps) => {
4
+ disabled: string | boolean;
5
+ label: string;
6
+ icon: React.ForwardRefExoticComponent<Pick<React.SVGProps<SVGSVGElement>, "string" | "id" | "lang" | "name" | "type" | "className" | "color" | "height" | "max" | "media" | "method" | "min" | "style" | "target" | "width" | "role" | "tabIndex" | "crossOrigin" | "accentHeight" | "accumulate" | "additive" | "alignmentBaseline" | "allowReorder" | "alphabetic" | "amplitude" | "arabicForm" | "ascent" | "attributeName" | "attributeType" | "autoReverse" | "azimuth" | "baseFrequency" | "baselineShift" | "baseProfile" | "bbox" | "begin" | "bias" | "by" | "calcMode" | "capHeight" | "clip" | "clipPath" | "clipPathUnits" | "clipRule" | "colorInterpolation" | "colorInterpolationFilters" | "colorProfile" | "colorRendering" | "contentScriptType" | "contentStyleType" | "cursor" | "cx" | "cy" | "d" | "decelerate" | "descent" | "diffuseConstant" | "direction" | "display" | "divisor" | "dominantBaseline" | "dur" | "dx" | "dy" | "edgeMode" | "elevation" | "enableBackground" | "end" | "exponent" | "externalResourcesRequired" | "fill" | "fillOpacity" | "fillRule" | "filter" | "filterRes" | "filterUnits" | "floodColor" | "floodOpacity" | "focusable" | "fontFamily" | "fontSize" | "fontSizeAdjust" | "fontStretch" | "fontStyle" | "fontVariant" | "fontWeight" | "format" | "from" | "fx" | "fy" | "g1" | "g2" | "glyphName" | "glyphOrientationHorizontal" | "glyphOrientationVertical" | "glyphRef" | "gradientTransform" | "gradientUnits" | "hanging" | "horizAdvX" | "horizOriginX" | "href" | "ideographic" | "imageRendering" | "in2" | "in" | "intercept" | "k1" | "k2" | "k3" | "k4" | "k" | "kernelMatrix" | "kernelUnitLength" | "kerning" | "keyPoints" | "keySplines" | "keyTimes" | "lengthAdjust" | "letterSpacing" | "lightingColor" | "limitingConeAngle" | "local" | "markerEnd" | "markerHeight" | "markerMid" | "markerStart" | "markerUnits" | "markerWidth" | "mask" | "maskContentUnits" | "maskUnits" | "mathematical" | "mode" | "numOctaves" | "offset" | "opacity" | "operator" | "order" | "orient" | "orientation" | "origin" | "overflow" | "overlinePosition" | "overlineThickness" | "paintOrder" | "panose1" | "path" | "pathLength" | "patternContentUnits" | "patternTransform" | "patternUnits" | "pointerEvents" | "points" | "pointsAtX" | "pointsAtY" | "pointsAtZ" | "preserveAlpha" | "preserveAspectRatio" | "primitiveUnits" | "r" | "radius" | "refX" | "refY" | "renderingIntent" | "repeatCount" | "repeatDur" | "requiredExtensions" | "requiredFeatures" | "restart" | "result" | "rotate" | "rx" | "ry" | "scale" | "seed" | "shapeRendering" | "slope" | "spacing" | "specularConstant" | "specularExponent" | "speed" | "spreadMethod" | "startOffset" | "stdDeviation" | "stemh" | "stemv" | "stitchTiles" | "stopColor" | "stopOpacity" | "strikethroughPosition" | "strikethroughThickness" | "stroke" | "strokeDasharray" | "strokeDashoffset" | "strokeLinecap" | "strokeLinejoin" | "strokeMiterlimit" | "strokeOpacity" | "strokeWidth" | "surfaceScale" | "systemLanguage" | "tableValues" | "targetX" | "targetY" | "textAnchor" | "textDecoration" | "textLength" | "textRendering" | "to" | "transform" | "u1" | "u2" | "underlinePosition" | "underlineThickness" | "unicode" | "unicodeBidi" | "unicodeRange" | "unitsPerEm" | "vAlphabetic" | "values" | "vectorEffect" | "version" | "vertAdvY" | "vertOriginX" | "vertOriginY" | "vHanging" | "vIdeographic" | "viewBox" | "viewTarget" | "visibility" | "vMathematical" | "widths" | "wordSpacing" | "writingMode" | "x1" | "x2" | "x" | "xChannelSelector" | "xHeight" | "xlinkActuate" | "xlinkArcrole" | "xlinkHref" | "xlinkRole" | "xlinkShow" | "xlinkTitle" | "xlinkType" | "xmlBase" | "xmlLang" | "xmlns" | "xmlnsXlink" | "xmlSpace" | "y1" | "y2" | "y" | "yChannelSelector" | "z" | "zoomAndPan" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key"> & React.RefAttributes<SVGSVGElement>>;
7
+ shortcut: string | null;
8
+ onHandle: () => void;
9
+ };
@@ -0,0 +1,8 @@
1
+ import 'regenerator-runtime';
2
+ import { IResolverProps } from '../types';
3
+ import { PublishWithi18nAction } from './PublishWithi18nAction';
4
+ import { DeleteWithi18nAction } from './DeleteWithi18nAction';
5
+ import { DuplicateWithi18nAction } from './DuplicateWithi18nAction';
6
+ export { PublishWithi18nAction, DeleteWithi18nAction, DuplicateWithi18nAction };
7
+ declare const _default: (props: IResolverProps) => any;
8
+ export default _default;