@@ -16,31 +16,35 @@ import DiffableTextKit
1616public struct PatternTextStyle < Value> : DiffableTextStyle where Value: Equatable ,
1717Value: RangeReplaceableCollection , Value. Element == Character {
1818
19+ public typealias Placeholders = PatternTextPlaceholders
20+
1921 //=------------------------------------------------------------------------=
2022 // MARK: State
2123 //=------------------------------------------------------------------------=
2224
23- @ usableFromInline let pattern : String
24- @ usableFromInline var placeholders = Placeholders ( )
25- @ usableFromInline var hidden = false
25+ public var pattern : String
26+ public var placeholders : Placeholders
27+ public var hidden : Bool
2628
2729 //=------------------------------------------------------------------------=
2830 // MARK: Initializers
2931 //=------------------------------------------------------------------------=
3032
31- @inlinable public init ( _ pattern: String ) { self . pattern = pattern }
33+ @inlinable public init ( _ pattern: String , placeholders: Placeholders = . init( ) , hidden: Bool = false ) {
34+ self . pattern = pattern; self . placeholders = placeholders; self . hidden = hidden
35+ }
3236
3337 //=------------------------------------------------------------------------=
3438 // MARK: Transformations
3539 //=------------------------------------------------------------------------=
3640
37- /// Marks a single character as a placeholder.
41+ /// Marks a single character as the style's placeholder.
3842 @inlinable public func placeholders( _ character: Character ,
3943 where predicate: @escaping ( Character ) -> Bool ) -> Self {
4044 var S0 = self ; S0 . placeholders = . init( ( character, predicate) ) ; return S0
4145 }
4246
43- /// Marks multiple characters as placeholders.
47+ /// Marks multiple characters as the style's placeholders.
4448 @inlinable public func placeholders( _ placeholders: [ Character : ( Character ) -> Bool ] ) -> Self {
4549 var S0 = self ; S0 . placeholders = . init( placeholders) ; return S0
4650 }
@@ -250,29 +254,8 @@ extension PatternTextStyle {
250254//*============================================================================*
251255// MARK: * Style x Init
252256//*============================================================================*
253- //=----------------------------------------------------------------------------=
254- // MARK: + String
255- //=----------------------------------------------------------------------------=
256-
257- extension DiffableTextStyle where Self == PatternTextStyle < String > {
258-
259- /// Creates a `PatternTextStyle` without placeholders.
260- ///
261- /// ```
262- /// DiffableTextField(value: $number) {
263- /// .pattern("+## (###) ###-##-##")
264- /// .placeholders("#") { $0.isASCII && $0.isNumber }
265- /// }
266- /// ```
267- ///
268- @inlinable public static func pattern( _ pattern: String ) -> Self { Self ( pattern) }
269- }
270257
271- //=----------------------------------------------------------------------------=
272- // MARK: + Array<Character>
273- //=----------------------------------------------------------------------------=
274-
275- extension DiffableTextStyle where Self == PatternTextStyle < [ Character ] > {
258+ extension DiffableTextStyle {
276259
277260 /// Creates a `PatternTextStyle` without placeholders.
278261 ///
@@ -283,5 +266,7 @@ extension DiffableTextStyle where Self == PatternTextStyle<[Character]> {
283266 /// }
284267 /// ```
285268 ///
286- @inlinable public static func pattern( _ pattern: String ) -> Self { Self ( pattern) }
269+ @inlinable public static func pattern< T> ( _ pattern: String ) -> Self where Self == PatternTextStyle < T > {
270+ Self ( pattern)
271+ }
287272}
0 commit comments